2022-03-31初始化
This commit is contained in:
194
yyd-base/yyd-base-jdbc/pom.xml
Normal file
194
yyd-base/yyd-base-jdbc/pom.xml
Normal file
@@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-base-jdbc</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-jaxrpc</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
|
||||
<dependency>
|
||||
<groupId>wsdl4j</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
<version>1.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.73</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.14</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 二维码 -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--极光推送-->
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jiguang-common</artifactId>
|
||||
<version>1.1.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.6.Final</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- 拼音 -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--工具包-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,67 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.jdbc;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: MybatisPlusConfig.java <br/>
|
||||
* Class: com.yxt.common.base.config.MybatisPlusConfig <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/24 下午12:42 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
/*
|
||||
* 分页插件,自动识别数据库类型 多租户,请参考官网【插件扩展】
|
||||
*/
|
||||
// @Bean
|
||||
// public MybatisPlusInterceptor paginationInterceptor() {
|
||||
// return new MybatisPlusInterceptor();
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
|
||||
// paginationInterceptor.setOverflow(false);
|
||||
// 设置最大单页限制数量,默认 500 条,-1 不受限制
|
||||
// paginationInterceptor.setLimit(500);
|
||||
// 开启 count 的 join 优化,只针对部分 left join
|
||||
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
|
||||
return paginationInterceptor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.jdbc.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yyd.base.common.domain.BaseEntity;
|
||||
import com.yyd.base.common.dto.Dto;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.query.Query;
|
||||
import com.yyd.base.common.utils.PagerUtil;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: MybatisBaseService.java <br/>
|
||||
* Class: PACKAGE_NAME.MybatisBaseService <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/24 下午2:41 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class MybatisBaseService<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T entity() {
|
||||
T instance = null;
|
||||
Class<T> entityClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
.getActualTypeArguments()[1];
|
||||
try {
|
||||
instance = entityClass.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
protected Long checkId(Map<String, Object> map) {
|
||||
Object object = map.get("id");
|
||||
if (object == null)
|
||||
return 0L;
|
||||
String sId = object.toString();
|
||||
if (StringUtils.isBlank(sId))
|
||||
return 0L;
|
||||
Long id = Long.valueOf(sId);
|
||||
return id;
|
||||
}
|
||||
|
||||
protected String checkSid(Map<String, Object> map) {
|
||||
Object object = map.get("sid");
|
||||
if (object == null)
|
||||
return null;
|
||||
// if (StringUtils.isBlank(object.toString()))
|
||||
// return null;
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : 将Map转换为实体对象. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param map
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected T map2entity(Map<String, Object> map, T t) {
|
||||
map.remove("id");
|
||||
map.remove("sid");
|
||||
map.remove("createTime");
|
||||
map.remove("modifyTime");
|
||||
if (t instanceof BaseEntity) {
|
||||
((BaseEntity) t).setModifyTime(new Date());
|
||||
t = (T) (BaseEntity) t;
|
||||
}
|
||||
BeanUtil.fillBeanWithMapIgnoreCase(map, t, false);
|
||||
return t;
|
||||
}
|
||||
|
||||
public int insert(T paramT) {
|
||||
return baseMapper.insert(paramT);
|
||||
}
|
||||
|
||||
public int insert(Map<String, Object> map) {
|
||||
T t = entity();
|
||||
t = map2entity(map, t);
|
||||
return insert(t);
|
||||
}
|
||||
|
||||
public int deleteBySid(String sid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sid", sid);
|
||||
return baseMapper.deleteByMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public int delByIds(String ids) {
|
||||
String[] split = ids.split(",");
|
||||
if (split.length < 1) {
|
||||
return 0;
|
||||
} else if (split.length == 1) {
|
||||
return baseMapper.deleteById(Long.valueOf(ids));
|
||||
} else {
|
||||
List<Long> list = new ArrayList<>();
|
||||
for (String id : split) {
|
||||
list.add(Long.valueOf(id));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param sids
|
||||
* @return
|
||||
*/
|
||||
public int delBySids(String[] sids) {
|
||||
if (sids == null || sids.length < 1)
|
||||
return 0;
|
||||
else if (sids.length == 1) {
|
||||
String sid = sids[0];
|
||||
return deleteBySid(sid);
|
||||
} else {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String sid : sids) {
|
||||
list.add(sid);
|
||||
}
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.in("sid", list);
|
||||
return baseMapper.delete(qw);
|
||||
}
|
||||
}
|
||||
|
||||
public int updateById(Map<String, Object> map) {
|
||||
Long id = checkId(map);
|
||||
if (id.equals(0L))
|
||||
return 0;
|
||||
return updateById(map, id);
|
||||
}
|
||||
|
||||
public int updateById(Map<String, Object> map, Serializable id) {
|
||||
T t = fetchById(id);
|
||||
if (t == null)
|
||||
return -1;
|
||||
t = map2entity(map, t);
|
||||
|
||||
if (t instanceof BaseEntity) {
|
||||
if(((BaseEntity) t).getLockVersion()!=null) {
|
||||
((BaseEntity) t).setLockVersion(((BaseEntity) t).getLockVersion() + 1);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(t);
|
||||
}
|
||||
|
||||
public int updateBySid(Map<String, Object> map) {
|
||||
String sid = checkSid(map);
|
||||
if (StringUtils.isBlank(sid))
|
||||
return 0;
|
||||
return updateBySid(map, sid);
|
||||
}
|
||||
|
||||
public int updateBySid(Dto dto, String sid) {
|
||||
T t = fetchBySid(sid);
|
||||
if (t == null)
|
||||
return -1;
|
||||
BeanUtil.copyProperties(dto,t);
|
||||
if (t instanceof BaseEntity) {
|
||||
if(((BaseEntity) t).getLockVersion()!=null) {
|
||||
((BaseEntity) t).setLockVersion(((BaseEntity) t).getLockVersion() + 1);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(t);
|
||||
}
|
||||
|
||||
public int updateBySid(Map<String, Object> map, String sid) {
|
||||
T t = fetchBySid(sid);
|
||||
if (t == null)
|
||||
return -1;
|
||||
t = map2entity(map, t);
|
||||
|
||||
if (t instanceof BaseEntity) {
|
||||
if(((BaseEntity) t).getLockVersion()!=null) {
|
||||
((BaseEntity) t).setLockVersion(((BaseEntity) t).getLockVersion() + 1);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(t);
|
||||
}
|
||||
|
||||
public int insertOrUpdateById(Map<String, Object> map) {
|
||||
Long id = checkId(map);
|
||||
if (id.equals(0L))
|
||||
return insert(map);
|
||||
return updateById(map, id);
|
||||
}
|
||||
|
||||
public int insertOrUpdateBySid(Map<String, Object> map) {
|
||||
String sid = checkSid(map);
|
||||
if (StringUtils.isBlank(sid))
|
||||
return insert(map);
|
||||
return updateBySid(map, sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public T fetchById(Serializable id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
public T fetchBySid(String sid) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq("sid", sid);
|
||||
return baseMapper.selectOne(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param page
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public IPage<T> pagging(IPage<T> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return pagging(page, qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param page
|
||||
* @param qw
|
||||
* @return
|
||||
*/
|
||||
public IPage<T> pagging(IPage<T> page, QueryWrapper<T> qw) {
|
||||
IPage<T> selectPage = baseMapper.selectPage(page, qw);
|
||||
if (selectPage.getPages() < selectPage.getCurrent()) {
|
||||
page.setCurrent(selectPage.getPages());
|
||||
page.setTotal(selectPage.getTotal());
|
||||
selectPage = baseMapper.selectPage(page, qw);
|
||||
}
|
||||
return selectPage;
|
||||
}
|
||||
|
||||
public IPage<Map<String, Object>> paggingMap(IPage<Map<String, Object>> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return paggingMap(page, qw);
|
||||
}
|
||||
|
||||
|
||||
public IPage<Map<String, Object>> paggingMap(IPage<Map<String, Object>> page, QueryWrapper<T> qw) {
|
||||
IPage<Map<String, Object>> selectMapsPage = baseMapper.selectMapsPage(page, qw);
|
||||
|
||||
if (selectMapsPage.getPages() < selectMapsPage.getCurrent()) {
|
||||
page.setCurrent(selectMapsPage.getPages());
|
||||
page.setTotal(selectMapsPage.getTotal());
|
||||
selectMapsPage = baseMapper.selectMapsPage(page, qw);
|
||||
}
|
||||
|
||||
return selectMapsPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
private QueryWrapper<T> defaultPageQueryWrapper(Map<String, Object> params) {
|
||||
if (params == null || params.isEmpty())
|
||||
return Wrappers.emptyWrapper();
|
||||
|
||||
QueryWrapper<T> qw = new QueryWrapper<T>();
|
||||
for (String key : params.keySet()) {
|
||||
qw.like(key, params.get(key));
|
||||
}
|
||||
return qw;
|
||||
}
|
||||
|
||||
public IPage<T> page(IPage<T> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return super.page(page, qw);
|
||||
}
|
||||
|
||||
public IPage<Map<String, Object>> pageMaps(IPage<Map<String, Object>> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return super.pageMaps(page, qw);
|
||||
}
|
||||
|
||||
public <V extends Vo, Q extends Query> PagerVo<V> page(PagerQuery<Q> pagerQuery) {
|
||||
Q params = pagerQuery.getParams();
|
||||
IPage<T> page = PagerUtil.queryToPage(pagerQuery);
|
||||
Map<String, Object> paramsMap = null;
|
||||
if (params != null)
|
||||
paramsMap = params.toMap();
|
||||
IPage pageResult = this.page(page, paramsMap);
|
||||
PagerVo<V> pv = PagerUtil.pageToVo(pageResult, null);
|
||||
return pv;
|
||||
}
|
||||
|
||||
public <Q extends Query> PagerVo<Map<String, Object>> pageMaps(PagerQuery<Q> pagerQuery) {
|
||||
Q params = pagerQuery.getParams();
|
||||
IPage<T> page = PagerUtil.queryToPage(pagerQuery);
|
||||
Map<String, Object> paramsMap = null;
|
||||
if (params != null)
|
||||
paramsMap = params.toMap();
|
||||
IPage pageResult = this.page(page, paramsMap);
|
||||
PagerVo<Map<String, Object>> pv = PagerUtil.pageToVo(pageResult, new PagerVo<>());
|
||||
return pv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询与某一字段值相等的数据列表
|
||||
*
|
||||
* @param filedName 字段名
|
||||
* @param filedValue 相等的值
|
||||
* @return
|
||||
*/
|
||||
public List<T> listEqFiled(String filedName, String filedValue) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq(filedName, filedValue);
|
||||
return list(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询与某一字段值相等,但不等于id的数据列表
|
||||
*
|
||||
* @param filedName 字段名
|
||||
* @param filedValue 相等的值
|
||||
* @param id id的值
|
||||
* @return
|
||||
*/
|
||||
public List<T> listEqFiledNeId(String filedName, String filedValue, Serializable id) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq(filedName, filedValue);
|
||||
qw.ne("id", id);
|
||||
return list(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询与某一字段值相等,但与另一字段的值不相等的数据列表
|
||||
*
|
||||
* @param filedName 相等的字段名
|
||||
* @param filedValue 相等的值
|
||||
* @param neName 不相等的字段名
|
||||
* @param neValue 不相等的值
|
||||
* @return
|
||||
*/
|
||||
public List<T> listEqFiledWithNe(String filedName, String filedValue, String neName, String neValue) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq(filedName, filedValue);
|
||||
qw.ne(neName, neValue);
|
||||
return list(qw);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user