2022-03-31初始化
This commit is contained in:
21
yyd-base/pom.xml
Normal file
21
yyd-base/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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>ttvictory</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yyd-base-common</module>
|
||||
<module>yyd-base-redis</module>
|
||||
<module>yyd-base-jdbc</module>
|
||||
<module>yyd-base-handler</module>
|
||||
</modules>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
191
yyd-base/yyd-base-common/pom.xml
Normal file
191
yyd-base/yyd-base-common/pom.xml
Normal file
@@ -0,0 +1,191 @@
|
||||
<?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-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<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,158 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: BaseEntity.java <br/>
|
||||
* Class: com.yxt.common.core.domain.BaseEntity <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/4 1:01 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BaseEntity extends EntityWithId {
|
||||
|
||||
public String getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(String sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
public Integer getLockVersion() {
|
||||
return lockVersion;
|
||||
}
|
||||
|
||||
public void setLockVersion(Integer lockVersion) {
|
||||
this.lockVersion = lockVersion;
|
||||
}
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Integer getIsEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
public void setIsEnable(Integer isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
}
|
||||
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(Integer isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public String getCreateBySid() {
|
||||
return createBySid;
|
||||
}
|
||||
|
||||
public void setCreateBySid(String createBySid) {
|
||||
this.createBySid = createBySid;
|
||||
}
|
||||
|
||||
public String getUpdateBySid() {
|
||||
return updateBySid;
|
||||
}
|
||||
|
||||
public void setUpdateBySid(String updateBySid) {
|
||||
this.updateBySid = updateBySid;
|
||||
}
|
||||
|
||||
@ApiModelProperty("字符型编号")
|
||||
private String sid = UUID.randomUUID().toString();
|
||||
|
||||
// @Version
|
||||
@ApiModelProperty("记录版本,锁")
|
||||
private Integer lockVersion = 0;
|
||||
|
||||
@ApiModelProperty("记录创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime = new Date();
|
||||
@ApiModelProperty("记录最后修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date modifyTime = new Date();
|
||||
@ApiModelProperty("记录状态值")
|
||||
private Integer state = 1;
|
||||
@ApiModelProperty("记录是否可用,1:可用(默认),0:不可用")
|
||||
private Integer isEnable = 1;
|
||||
|
||||
// @TableLogic
|
||||
@ApiModelProperty("记录是否被删除,0:未删除(默认),1:已经删除")
|
||||
private Integer isDelete = 0;
|
||||
|
||||
@ApiModelProperty("备注信息")
|
||||
private String remarks;
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBySid;
|
||||
@ApiModelProperty("更新者")
|
||||
private String updateBySid;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.yyd.base.common.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Entity implements Serializable {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yyd.base.common.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class EntityWithId extends Entity {
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ApiModelProperty("ID值的字符串形式")
|
||||
public String getIdStr() {
|
||||
if (null == id) {
|
||||
return "";
|
||||
}
|
||||
return "" + id;
|
||||
}
|
||||
|
||||
@ApiModelProperty("ID,唯一编号")
|
||||
private Integer id;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClassName:" + getClass().getName() + ";id:" + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int id2 = Long.hashCode(getId());
|
||||
return super.hashCode() + id2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof EntityWithId)) {
|
||||
return false;
|
||||
}
|
||||
EntityWithId entity = (EntityWithId) obj;
|
||||
return this.getId().equals(entity.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.dto;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.yyd.base.common.domain.Entity;
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Dto.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.dto.Dto <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/17 23:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Dto extends Vo {
|
||||
|
||||
default <E extends Entity> void fillEntity(E e) {
|
||||
BeanUtil.copyProperties(this, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.query;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: PagerQuery.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.query.PagerQuery <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:58 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class PagerQuery<T extends Query> implements Serializable {
|
||||
|
||||
public PagerQuery() {
|
||||
}
|
||||
|
||||
public PagerQuery(long current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public PagerQuery(long current, long size) {
|
||||
this.size = size;
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
// @ApiModelProperty("总记录数")
|
||||
//private long total = 0L; //总记录数
|
||||
@ApiModelProperty(value = "每页记录数", example = "10")
|
||||
private long size = 10L; //每页记录数
|
||||
@ApiModelProperty(value = "当前页号", example = "1")
|
||||
private long current = 1L; //当前页号
|
||||
@ApiModelProperty("查询条件的项")
|
||||
private T params;
|
||||
|
||||
// @ApiModelProperty("每页记录数,size的别名,默认值为10")
|
||||
// public PagerQuery set_p_size(long _p_size) {
|
||||
// this.size = _p_size;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @ApiModelProperty("当前页号,current的别名,默认值为1")
|
||||
// public PagerQuery set_p_no(long _p_no) {
|
||||
// this.current = _p_no;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @ApiModelProperty("总记录数,total的别名,默认值为0")
|
||||
// public PagerQuery set_p_total(long _p_total) {
|
||||
// this.total = _p_total;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/* public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public PagerQuery setTotal(long total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public PagerQuery setSize(long size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public PagerQuery setCurrent(long current) {
|
||||
this.current = current;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public PagerQuery setParams(T params) {
|
||||
this.params = params;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void fromPagerQuery(PagerQuery s_query)
|
||||
{
|
||||
this.setCurrent(s_query.getCurrent()).setSize(s_query.getSize()).setParams(params.fromMap(s_query.getParams().toMap()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.query;
|
||||
|
||||
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Query.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.query.Query <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:24 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Query extends Vo {
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author liuguohui
|
||||
* @Date 2021/10/11
|
||||
*/
|
||||
@ApiModel(description = "手机端返回数据结构(同查询数据字典)")
|
||||
@Data
|
||||
public class AppResultData {
|
||||
|
||||
@ApiModelProperty(value = "数据字典项sid")
|
||||
private String sid;
|
||||
|
||||
@ApiModelProperty(value = "数据字典项key")
|
||||
private String dictKey;
|
||||
|
||||
@ApiModelProperty(value = "数据字典类型")
|
||||
private String dictType;
|
||||
|
||||
@ApiModelProperty(value = "数据字典项名称")
|
||||
private String dictValue;
|
||||
@ApiModelProperty(value = "父级sid:0为第一级")
|
||||
private String parentSid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2021/6/16 10:50
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class HttpStatus {
|
||||
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
public static final int ERROR = 500;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: IResultCodeMsg.java <br/>
|
||||
* Class: com.yxt.common.core.result.IResultCodeMsg <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021/9/11 下午11:00 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface IResultCodeMsg {
|
||||
String getCode();
|
||||
String getMsg();
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: yxt-common-core <br/>
|
||||
* File: ResultBean.java <br/>
|
||||
* Class: com.yxt.common.core.result.ResultBean <br/>
|
||||
* Description: 通过接口、Rest、逻辑处理执行后的结果信息. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/4 0:51 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(description = "返回结果")
|
||||
public class ResultBean<T> implements Serializable {
|
||||
private static final long serialVersionUID = 4529658978692424234L;
|
||||
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private Class<T> clazz() {
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[0];
|
||||
//// if(targetClass==null)
|
||||
//// targetClass=Object.class;
|
||||
// return targetClass;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private T obj() {
|
||||
// T instance = null;
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[1];
|
||||
// try {
|
||||
// instance = targetClass.newInstance();
|
||||
// } catch (InstantiationException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return instance;
|
||||
// }
|
||||
|
||||
@ApiModelProperty("对象创建的时间戳")
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
// 是否成功
|
||||
@ApiModelProperty("是否成功: true or false")
|
||||
private boolean success;
|
||||
|
||||
// 消息 返回结果的说明
|
||||
@ApiModelProperty("返回结果的说明")
|
||||
private String msg;
|
||||
|
||||
// 结果状态码
|
||||
@ApiModelProperty("结果状态码")
|
||||
private String code;
|
||||
|
||||
// 数据
|
||||
@ApiModelProperty("业务数据")
|
||||
private T data;
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ResultBean<T> setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean() {
|
||||
}
|
||||
|
||||
public ResultBean(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public ResultBean(boolean success, String msg) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResultBean(boolean success, String msg, String code) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ResultBean(T data) {
|
||||
this.success = true;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBean(String code, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBean(String code, String msg, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public ResultBean<T> setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public ResultBean<T> setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ResultBean<T> setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
// if (this.data == null && this.map != null && !this.map.isEmpty()) {
|
||||
//// Object t = new Object();
|
||||
//// Object r = (Object)this.map;map
|
||||
//// BeanUtil.fillBeanWithMap(this.map, t, false);
|
||||
// this.data = obj();
|
||||
// BeanUtil.copyProperties(this.map, this.data, true);
|
||||
//// this.data = (T) t;
|
||||
//// return t;
|
||||
// }
|
||||
return data;
|
||||
}
|
||||
|
||||
public ResultBean<T> setData(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> successOne() {
|
||||
this.setSuccess(true);
|
||||
this.setCode("0");
|
||||
this.setMessage("成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> failOne() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMessage("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> success() {
|
||||
this.setSuccess(true);
|
||||
this.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
this.setMsg("操作成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> fail() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMsg("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> fireSuccess() {
|
||||
ResultBean<T> rb = new ResultBean<T>();
|
||||
rb.setSuccess(true);
|
||||
rb.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
rb.setMsg("操作成功!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> fireFail() {
|
||||
ResultBean<T> rb = new ResultBean<T>();
|
||||
rb.setSuccess(false);
|
||||
rb.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
rb.setMsg("操作失败!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
// @ApiModelProperty("无类型的业务数据对象")
|
||||
//// @JsonIgnore
|
||||
// private Map<String, Object> map = Collections.emptyMap();
|
||||
//
|
||||
// public ResultBean<T> clear() {
|
||||
// this.map = null;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Object get(String key) {
|
||||
// if (this.map == null)
|
||||
// return null;
|
||||
// return this.map.get(key);
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> remove(String key) {
|
||||
// if (this.map == null)
|
||||
// return this;
|
||||
// this.map.remove(key);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> put(String key, Object value) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.put(key, value);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Map<String, Object> getMap() {
|
||||
// return this.map;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> setMap(Map<String, Object> map) {
|
||||
// this.map = map;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> putAll(Map<String, Object> map) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.putAll(map);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 设置返回code及msg
|
||||
*
|
||||
* @param codeMsg Code和Msg的枚举
|
||||
* @return
|
||||
*/
|
||||
public ResultBean<T> setCode(IResultCodeMsg codeMsg) {
|
||||
this.code = codeMsg.getCode();
|
||||
this.msg = codeMsg.getMsg();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败信息,并指定结果code
|
||||
* @param codeMsg Code和Msg的枚举
|
||||
* @return
|
||||
*/
|
||||
public ResultBean<T> fail(IResultCodeMsg codeMsg) {
|
||||
this.setSuccess(false);
|
||||
this.code = codeMsg.getCode();
|
||||
this.msg = codeMsg.getMsg();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: yxt-common-core <br/>
|
||||
* File: ResultBean.java <br/>
|
||||
* Class: com.yxt.common.core.result.ResultBean <br/>
|
||||
* Description: 通过接口、Rest、逻辑处理执行后的结果信息. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/4 0:51 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(description = "返回结果")
|
||||
public class ResultBeanOfEnum<T> implements Serializable {
|
||||
private static final long serialVersionUID = 4529658978692424234L;
|
||||
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private Class<T> clazz() {
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[0];
|
||||
//// if(targetClass==null)
|
||||
//// targetClass=Object.class;
|
||||
// return targetClass;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private T obj() {
|
||||
// T instance = null;
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[1];
|
||||
// try {
|
||||
// instance = targetClass.newInstance();
|
||||
// } catch (InstantiationException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return instance;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("对象创建的时间戳")
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
// 是否成功
|
||||
@ApiModelProperty("是否成功: true or false")
|
||||
private boolean success;
|
||||
|
||||
// 消息 返回结果的说明
|
||||
@ApiModelProperty("返回结果的说明")
|
||||
private String msg;
|
||||
|
||||
// 结果状态码
|
||||
@ApiModelProperty("结果状态码")
|
||||
private String code;
|
||||
|
||||
// 数据
|
||||
@ApiModelProperty("业务数据")
|
||||
private T data;
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum() {
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(boolean success, String msg) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(boolean success, String msg, String code) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(T data) {
|
||||
this.success = true;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(String code, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(String code, String msg, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setCode(CodeMsg codeMsg) {
|
||||
// this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
// if (this.data == null && this.map != null && !this.map.isEmpty()) {
|
||||
//// Object t = new Object();
|
||||
//// Object r = (Object)this.map;map
|
||||
//// BeanUtil.fillBeanWithMap(this.map, t, false);
|
||||
// this.data = obj();
|
||||
// BeanUtil.copyProperties(this.map, this.data, true);
|
||||
//// this.data = (T) t;
|
||||
//// return t;
|
||||
// }
|
||||
return data;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setData(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
public ResultBeanOfEnum<T> successOne() {
|
||||
this.setSuccess(true);
|
||||
this.setCode("0");
|
||||
this.setMessage("成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> failOne() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMessage("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> success() {
|
||||
this.setSuccess(true);
|
||||
this.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
this.setMsg("操作成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> fail() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMsg("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static <T> ResultBeanOfEnum<T> fireSuccess() {
|
||||
ResultBeanOfEnum<T> rb = new ResultBeanOfEnum<T>();
|
||||
rb.setSuccess(true);
|
||||
rb.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
rb.setMsg("操作成功!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
public static <T> ResultBeanOfEnum<T> fireFail() {
|
||||
ResultBeanOfEnum<T> rb = new ResultBeanOfEnum<T>();
|
||||
rb.setSuccess(false);
|
||||
rb.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
rb.setMsg("操作失败!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
// @ApiModelProperty("无类型的业务数据对象")
|
||||
//// @JsonIgnore
|
||||
// private Map<String, Object> map = Collections.emptyMap();
|
||||
//
|
||||
// public ResultBean<T> clear() {
|
||||
// this.map = null;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Object get(String key) {
|
||||
// if (this.map == null)
|
||||
// return null;
|
||||
// return this.map.get(key);
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> remove(String key) {
|
||||
// if (this.map == null)
|
||||
// return this;
|
||||
// this.map.remove(key);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> put(String key, Object value) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.put(key, value);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Map<String, Object> getMap() {
|
||||
// return this.map;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> setMap(Map<String, Object> map) {
|
||||
// this.map = map;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> putAll(Map<String, Object> map) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.putAll(map);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
public enum CodeMsg{
|
||||
/**
|
||||
* 返回正常
|
||||
*/
|
||||
HTML200("200","返回正常"),
|
||||
|
||||
/**
|
||||
* 页面不存在
|
||||
*/
|
||||
HTML404("404","页面不存在"),
|
||||
|
||||
/**
|
||||
* 服务器错误
|
||||
*/
|
||||
HTML500("500","服务器错误");
|
||||
|
||||
private String code;
|
||||
private String msg;
|
||||
|
||||
private CodeMsg(String code,String msg){
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getMsg(){
|
||||
return msg;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code得到枚举实例
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static CodeMsg byCode(String code){
|
||||
for(CodeMsg cm: CodeMsg.values()){
|
||||
if(cm.getCode().equals(code)){
|
||||
return cm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: PagerUtil.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.base.utils.PagerUtil <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/22 上午9:35 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class PagerUtil {
|
||||
|
||||
public static <T> IPage<T> queryToPage(PagerQuery pq) {
|
||||
IPage<T> page = new Page<>();
|
||||
page.setSize(pq.getSize()).setCurrent(pq.getCurrent());
|
||||
return page;
|
||||
}
|
||||
|
||||
public static <V, T> PagerVo<V> pageToVo(IPage pr, PagerVo<V> pv) {
|
||||
if (pv == null)
|
||||
pv = new PagerVo<V>();
|
||||
pv.setCurrent(pr.getCurrent()).setSize(pr.getSize())
|
||||
.setTotal(pr.getTotal()).setPages(pr.getPages())
|
||||
.setRecords(pr.getRecords());
|
||||
return pv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换pagerVo
|
||||
*
|
||||
* @param soure
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static <S extends Vo, T extends Vo> PagerVo<T> switchPagerVo(
|
||||
PagerVo<S> soure) {
|
||||
if (soure == null)
|
||||
return null;
|
||||
|
||||
PagerVo<T> target = new PagerVo<>();
|
||||
target.setCurrent(soure.getCurrent()).setPages(soure.getPages())
|
||||
.setSize(soure.getSize()).setTotal(soure.getTotal());
|
||||
target.setRecords(new ArrayList<T>());
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
/*
|
||||
* public static <S, V> PagerVo<V> pageVoToVo(PagerVo<S> pvs, PagerVo<V>
|
||||
* pvt) { if (pvt == null) pvt = new PagerVo<V>();
|
||||
* pvt.setCurrent(pvs.getCurrent
|
||||
* ()).setSize(pvs.getSize()).setTotal(pvs.getTotal
|
||||
* ()).setPages(pvs.getPages());
|
||||
*
|
||||
* for(int i=0;i<pvs.getRecords().size();i++) { WfTaskAppVo taskAppVo=new
|
||||
* WfTaskAppVo();
|
||||
*
|
||||
* pvt.getRecords().add(taskAppVo.fromMap(pvs.getRecords().get(i).toMap()));
|
||||
* }
|
||||
*
|
||||
*
|
||||
* return pv; }
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel(description = "返回的分页结果")
|
||||
public class PagerVo<T> implements Serializable {
|
||||
|
||||
@ApiModelProperty("总页数")
|
||||
private long pages = 1L; //总页数
|
||||
@ApiModelProperty("总记录数")
|
||||
private long total = 0L; //总记录数
|
||||
@ApiModelProperty("每页记录数")
|
||||
private long size = 10L; //每页记录数
|
||||
@ApiModelProperty("当前页号")
|
||||
private long current = 1L; //当前页号
|
||||
|
||||
@ApiModelProperty("当前页的数据")
|
||||
private List<T> records = Collections.emptyList(); //当前页的数据
|
||||
@ApiModelProperty("统计信息")
|
||||
private String msg = "";
|
||||
@ApiModelProperty("其它信息")
|
||||
private Map<String, Object> map = Collections.emptyMap();
|
||||
|
||||
|
||||
public PagerVo() {
|
||||
this.pages = 1L; //总页数
|
||||
this.total = 0L; //总记录数
|
||||
this.size = 10L; //每页记录数
|
||||
this.current = 1L; //当前页号
|
||||
this.records = Collections.emptyList(); //当前页的数据
|
||||
}
|
||||
|
||||
public PagerVo(long current) {
|
||||
this.pages = 1L; //总页数
|
||||
this.total = 0L; //总记录数
|
||||
this.size = 10L; //每页记录数
|
||||
this.current = current; //当前页号
|
||||
this.records = Collections.emptyList(); //当前页的数据
|
||||
}
|
||||
|
||||
public long getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public PagerVo<T> setPages(long pages) {
|
||||
this.pages = pages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public PagerVo<T> setTotal(long total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public PagerVo<T> setSize(long size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public PagerVo<T> setCurrent(long current) {
|
||||
this.current = current;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<T> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public PagerVo<T> setRecords(List<T> records) {
|
||||
this.records = records;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Map<String, Object> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map<String, Object> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Tail.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.vo.Tail <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:22 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Tail extends Serializable {
|
||||
public Object get(String key);
|
||||
public void set(String key,Object value);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: TailBean.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.vo.TailBean <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:22 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class TailBean implements Tail {
|
||||
|
||||
protected Map<String, Object> extMap = new HashMap<String, Object>();
|
||||
|
||||
public Object get(String key) {
|
||||
return extMap.get(key);
|
||||
}
|
||||
|
||||
public void set(String key, Object value) {
|
||||
this.extMap.put(key, value);
|
||||
}
|
||||
|
||||
public Map<String, Object> getTails() {
|
||||
return extMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.yyd.base.common.domain.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Vo.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.vo.Vo <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/18 0:03 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Vo extends Serializable {
|
||||
|
||||
default Map<String, Object> toMap() {
|
||||
return BeanUtil.beanToMap(this);
|
||||
}
|
||||
|
||||
default <V extends Vo> V fromMap(Map<String, Object> map) {
|
||||
return (V) BeanUtil.fillBeanWithMap(map, this, false);
|
||||
}
|
||||
default <E extends Entity> void fromEntity(E e) {
|
||||
BeanUtil.copyProperties(e, this);
|
||||
|
||||
}
|
||||
}
|
||||
202
yyd-base/yyd-base-handler/pom.xml
Normal file
202
yyd-base/yyd-base-handler/pom.xml
Normal file
@@ -0,0 +1,202 @@
|
||||
<?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-handler</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>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,99 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.handler;
|
||||
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: GlobalExceptionHandler.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.base.config.handler.GlobalExceptionHandler <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/17 上午10:34 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger L = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
/**
|
||||
* 路径错误
|
||||
*
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public ResultBean handlerNoFoundException(Exception e) {
|
||||
L.error(e.getMessage(), e);
|
||||
return ResultBean.fireFail().setCode("404").setMsg("路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResultBean handleException(Exception e) {
|
||||
L.error(e.getMessage(), e);
|
||||
//发送邮件
|
||||
return ResultBean.fireFail().setMsg("系统异常::" + e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public ResultBean validatedBindException(BindException e) {
|
||||
L.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return ResultBean.fireFail().setCode("405").setMsg(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法参数验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResultBean validExceptionHandler(MethodArgumentNotValidException e) {
|
||||
L.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
return ResultBean.fireFail().setCode("405").setMsg(message);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
39
yyd-base/yyd-base-redis/pom.xml
Normal file
39
yyd-base/yyd-base-redis/pom.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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-redis</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</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>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.yyd.base.redis;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/9/18 19:37
|
||||
* @description
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Value("${spring.redis.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.redis.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.redis.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${spring.redis.timeout}")
|
||||
private int timeout;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-active}")
|
||||
private int redisPoolMaxActive;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-wait}")
|
||||
private int redisPoolMaxWait;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-idle}")
|
||||
private int redisPoolMaxIdle;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.min-idle}")
|
||||
private int redisPoolMinIdle;
|
||||
@Value("${spring.redis.database}")
|
||||
private int database;
|
||||
|
||||
@Bean
|
||||
public JedisPoolConfig getJedisPoolConfig() {
|
||||
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||
//最大空闲数
|
||||
jedisPoolConfig.setMaxIdle(redisPoolMaxIdle);
|
||||
//最小空闲数
|
||||
jedisPoolConfig.setMinIdle(redisPoolMinIdle);
|
||||
//最大建立连接等待时间
|
||||
jedisPoolConfig.setMaxWaitMillis(redisPoolMaxWait);
|
||||
//连接池的最大数据库连接数
|
||||
jedisPoolConfig.setMaxTotal(redisPoolMaxActive);
|
||||
return jedisPoolConfig;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
|
||||
|
||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(jedisPoolConfig);
|
||||
jedisConnectionFactory.setDatabase(database);
|
||||
//IP地址
|
||||
jedisConnectionFactory.setHostName(host);
|
||||
//如果redis设置有密码
|
||||
jedisConnectionFactory.setPassword(password);
|
||||
//端口号
|
||||
jedisConnectionFactory.setPort(port);
|
||||
//客户端超时时间单位是毫秒
|
||||
jedisConnectionFactory.setTimeout(timeout);
|
||||
// jedisConnectionFactory.afterPropertiesSet(); //记得添加这行!
|
||||
return jedisConnectionFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
// 使用Jackson2JsonRedisSerialize 替换默认序列化
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
// key采用String的序列化方式
|
||||
//redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
// hash的key也采用String的序列化方式
|
||||
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
||||
// value序列化方式采用jackson
|
||||
// redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
redisTemplate.setValueSerializer(stringRedisSerializer);
|
||||
// hash的value序列化方式采用jackson
|
||||
redisTemplate.setHashValueSerializer(stringRedisSerializer);
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package com.yyd.base.redis;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/9/9 17:35
|
||||
* @description redis工具类
|
||||
*/
|
||||
@Service
|
||||
public class RedisUtil {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 字符串类型:根据key设置value值,如果key中的value存在,那么返回false
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Boolean setnx(final String key, final String value, final long expration, final TimeUnit timeUnit) {
|
||||
return (Boolean) redisTemplate.execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection redisConnection) throws DataAccessException {
|
||||
RedisSerializer<String> redisSerializer = redisTemplate.getStringSerializer();
|
||||
byte keys[] = redisSerializer.serialize(key);
|
||||
byte values[] = redisSerializer.serialize(value);
|
||||
return redisConnection.set(keys, values, Expiration.from(expration, timeUnit), RedisStringCommands.SetOption.SET_IF_ABSENT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入缓存
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public boolean set(final String key, final String value) {
|
||||
|
||||
boolean result = (boolean) redisTemplate.execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
|
||||
connection.set(serializer.serialize(key), serializer.serialize(value));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入缓存设置时效时间
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public boolean set(final String key, Object value, Long expireTime) {
|
||||
boolean result = false;
|
||||
try {
|
||||
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value);
|
||||
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
|
||||
result = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean expire(String key, long expire) {
|
||||
return redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取缓存
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public String get(final String key) {
|
||||
String result = (String) redisTemplate.execute(new RedisCallback<String>() {
|
||||
@Override
|
||||
public String doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
|
||||
byte[] value = connection.get(serializer.serialize(key));
|
||||
return serializer.deserialize(value);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则获取key集合
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public Set<String> keys(String pattern) {
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除对应的value
|
||||
*
|
||||
* @param keys
|
||||
*/
|
||||
public void remove(final String... keys) {
|
||||
for (String key : keys) {
|
||||
remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除key
|
||||
*
|
||||
* @param pattern
|
||||
*/
|
||||
public void removePattern(final String pattern) {
|
||||
Set<Serializable> keys = redisTemplate.keys(pattern);
|
||||
if (keys.size() > 0) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Long remove(final String key) {
|
||||
return (Long) redisTemplate.execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection redisConnection) throws DataAccessException {
|
||||
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
|
||||
byte keys[] = serializer.serialize(key);
|
||||
return redisConnection.del(keys);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断缓存中是否有对应的value
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public boolean exists(final String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 哈希 添加
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @param value
|
||||
*/
|
||||
public void hmSet(String key, Object hashKey, Object value) {
|
||||
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
|
||||
hash.put(key, hashKey, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 哈希获取数据
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @return
|
||||
*/
|
||||
public String hmGet(String key, Object hashKey) {
|
||||
HashOperations<String, String, String> hash = redisTemplate.opsForHash();
|
||||
return hash.get(key, hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取哈希 keys
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Set<String> hmGetKeys(String key) {
|
||||
HashOperations<String, String, String> hash = redisTemplate.opsForHash();
|
||||
return hash.keys(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集合中的key
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
*/
|
||||
public void hmDelete(String key, Object hashKey) {
|
||||
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
|
||||
hash.delete(key, hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表添加
|
||||
*
|
||||
* @param k
|
||||
* @param v
|
||||
*/
|
||||
public void lPush(String k, Object v) {
|
||||
ListOperations<String, Object> list = redisTemplate.opsForList();
|
||||
list.rightPush(k, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表获取
|
||||
*
|
||||
* @param k
|
||||
* @param l
|
||||
* @param l1
|
||||
* @return
|
||||
*/
|
||||
public List<Object> lRange(String k, long l, long l1) {
|
||||
ListOperations<String, Object> list = redisTemplate.opsForList();
|
||||
return list.range(k, l, l1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 集合添加
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public void add(String key, Object value) {
|
||||
SetOperations<String, Object> set = redisTemplate.opsForSet();
|
||||
set.add(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 集合获取
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> setMembers(String key) {
|
||||
SetOperations<String, Object> set = redisTemplate.opsForSet();
|
||||
return set.members(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有序集合添加
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param scoure
|
||||
*/
|
||||
public void zAdd(String key, Object value, double scoure) {
|
||||
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
|
||||
zset.add(key, value, scoure);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有序集合获取
|
||||
*
|
||||
* @param key
|
||||
* @param scoure
|
||||
* @param scoure1
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> rangeByScore(String key, double scoure, double scoure1) {
|
||||
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
|
||||
return zset.rangeByScore(key, scoure, scoure1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现命令:TTL key 以秒为单位,返回给定key的剩余生存时间
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public long ttl(String key) {
|
||||
return redisTemplate.getExpire(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyPrefix: key前缀
|
||||
* @description: 根据前缀获取所有的符合该keyvalue值
|
||||
* @author: dimengzhe
|
||||
* @date: 2021/11/6 16:16
|
||||
* @return: java.util.List<java.lang.String>
|
||||
*/
|
||||
public List<String> getValuesByPrefix(String keyPrefix) {
|
||||
List<String> keys = getKeysByPrefix(keyPrefix);
|
||||
List<Object> values = redisTemplate.opsForValue().multiGet(keys);
|
||||
return (List<String>) (List) values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyPrefix: key前缀
|
||||
* @description: 根据前缀获取所有的符合该key的所有key值集合
|
||||
* @author: dimengzhe
|
||||
* @date: 2021/11/6 16:17
|
||||
* @return: java.util.List<java.lang.String>
|
||||
*/
|
||||
public List<String> getKeysByPrefix(String keyPrefix) {
|
||||
Set<String> keys = redisTemplate.keys(keyPrefix + "*");
|
||||
return Arrays.asList(keys.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user