已删除284个文件
已添加284个文件
已修改25个文件
| | |
| | | <relativePath/> |
| | | </parent> |
| | | |
| | | <groupId>com.lunhan.xxx</groupId> |
| | | <artifactId>xxx-yyy</artifactId> |
| | | <groupId>com.fengdu.gas</groupId> |
| | | <artifactId>fengdu_gases</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>xxx-yyy-service</name> |
| | | <name>fengdu_gases-service</name> |
| | | <description>The service which yyy of xxx project</description> |
| | | |
| | | <properties> |
| | |
| | | |
| | | cd %currPath% |
| | | |
| | | mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :xxx-yyy -am |
| | | mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :xxx-yyy -am |
| | | mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :fengdu_gases -am |
| | | mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :fengdu_gases -am |
| | | |
| | | pause>nul |
| | |
| | | |
| | | echo $project_name |
| | | |
| | | mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :xxx-yyy -am |
| | | mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :xxx-yyy -am |
| | | mvn smart-doc:html -Dfile.encoding=UTF-8 -pl :fengdu_gases -am |
| | | mvn smart-doc:openapi -Dfile.encoding=UTF-8 -pl :fengdu_gases -am |
| | | |
| | | #echo 按任意键退出 |
| | | #read -n 1 |
对比新文件 |
| | |
| | | package com.fengdu.gas.common; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public final class ConstantFactory { |
| | | private ConstantFactory() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | //********************************** msgCode ********************************** |
| | | /** |
| | | * msgCode - token错误 |
| | | */ |
| | | public static final String MCODE_TOKENERROR = "SYS000003"; |
| | | //********************************** msgCode ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //********************************** 字符串 ********************************** |
| | | /** |
| | | * 获取字符串换行符 |
| | | */ |
| | | public static final String STR_NEWLINE = "\r\n"; |
| | | /** |
| | | * 获取html换行符 |
| | | */ |
| | | public static final String STR_HTMLBR = "<br />"; |
| | | /** |
| | | * 1个空格字符串 |
| | | */ |
| | | public static final String STR_SPACE = " "; |
| | | /** |
| | | * 正则中的1个空格字符串 |
| | | */ |
| | | public static final String STR_REGEX_SPACE = "\\s"; |
| | | /** |
| | | * ~ |
| | | */ |
| | | public static final String STR_TIME_RANGE = " ~ "; |
| | | /** |
| | | * ; |
| | | */ |
| | | public static final String STR_SEMICOLON = ";"; |
| | | //********************************** 字符串 ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //********************************** 时间日期 相关 ********************************** |
| | | /** |
| | | * 日期格式“yyyy-MM-dd” |
| | | */ |
| | | public static final String STR_DATE = "yyyy-MM-dd"; |
| | | /** |
| | | * 时间格式“yyyy-MM-dd HH:mm:ss” |
| | | */ |
| | | public static final String STR_DATE_FULL = "yyyy-MM-dd HH:mm:ss"; |
| | | /** |
| | | * 时间格式“yyyy-MM-dd HH:mm:ss.SSS” |
| | | */ |
| | | public static final String STR_DATE_FULLMS = "yyyy-MM-dd HH:mm:ss.SSS"; |
| | | /** |
| | | * “ 00:00:00” |
| | | */ |
| | | public static final String STR_DATE_DAYSTART = " 00:00:00"; |
| | | /** |
| | | * “ 23:59:59” |
| | | */ |
| | | public static final String STR_DATE_DAYEND = " 23:59:59"; |
| | | /** |
| | | * “1970-01-01” |
| | | */ |
| | | public static final String STR_DATE_DEFAULT_DATE = "1970-01-01"; |
| | | /** |
| | | * “1970-01-01 00:00:00” |
| | | */ |
| | | public static final String STR_DATE_DEFAULT = "1970-01-01 00:00:00"; |
| | | /** |
| | | * “1970-01-01 08:00:01” |
| | | */ |
| | | public static final String STR_DATE_DEFAULT_UTC8 = "1970-01-01 08:00:01"; |
| | | /** |
| | | * “1970-01-01 00:00:00” |
| | | */ |
| | | public static final String STR_DATE_DEFAULT_FULL = "1970-01-01 00:00:00.000"; |
| | | //********************************** 时间日期 相关 ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //********************************** SQL关键字 相关 ********************************** |
| | | /** |
| | | * 等于“ = ?” |
| | | */ |
| | | public static final String SQL_EQUAL = " = ?"; |
| | | /** |
| | | * 不等于 |
| | | */ |
| | | public static final String SQL_NOTEQUAL = " <> ?"; |
| | | /** |
| | | * 大于 |
| | | */ |
| | | public static final String SQL_GREATER = " > ?"; |
| | | /** |
| | | * 大于等于 |
| | | */ |
| | | public static final String SQL_GREATERTHAN = " >= ?"; |
| | | /** |
| | | * 小于 |
| | | */ |
| | | public static final String SQL_LESS = " < ?"; |
| | | /** |
| | | * 小于等于 |
| | | */ |
| | | public static final String SQL_LESSTHAN = " <= ?"; |
| | | /** |
| | | * 模糊等于“ like ?” |
| | | */ |
| | | public static final String SQL_LIKE = " like ?"; |
| | | /** |
| | | * 模糊不等于“ not like ?” |
| | | */ |
| | | public static final String SQL_NOTLIKE = " not like ?"; |
| | | /** |
| | | * “ IN” |
| | | */ |
| | | public static final String SQL_IN = " IN"; |
| | | //public static final String SQL_IN = " FIND_IN_SET(%s, ?) > 0";//由于“FIND_IN_SET”无法使用索引 2020-06-17 改为“in”语法 lin.liu |
| | | /** |
| | | * “ NOT IN” |
| | | */ |
| | | public static final String SQL_NOTIN = " NOT IN"; |
| | | //public static final String SQL_NOTIN = " FIND_IN_SET(%s, ?) = 0";//由于“FIND_IN_SET”无法使用索引 2020-06-17 改为“not in”语法 lin.liu |
| | | |
| | | |
| | | /** |
| | | * 并且“AND” |
| | | */ |
| | | public static final String SQL_AND = " AND"; |
| | | /** |
| | | * 或者“OR” |
| | | */ |
| | | public static final String SQL_OR = " OR"; |
| | | |
| | | /** |
| | | * 逗号“,” |
| | | */ |
| | | public static final String SQL_STR_COMMA = " ,"; |
| | | /** |
| | | * “ ASC” |
| | | */ |
| | | public static final String SQL_ASC = " ASC"; |
| | | /** |
| | | * “ DESC” |
| | | */ |
| | | public static final String SQL_DESC = " DESC"; |
| | | public static final String TB_A = "a."; |
| | | public static final String TB_B = "b."; |
| | | //********************************** SQL关键字 相关 ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //********************************** redis 相关 ********************************** |
| | | /** |
| | | * 分布式锁前缀 |
| | | */ |
| | | public static final String REDIS_LOCKPREFIX = "lock_"; |
| | | /** |
| | | * 分布式锁超时时间10秒 |
| | | */ |
| | | public static final Long REDIS_LOCKTIMEOUT = 10 * 1000L; |
| | | /** |
| | | * token哈希key |
| | | */ |
| | | public static final String REDIS_HASH_TOKEN = "HASH_TOKEN"; |
| | | /** |
| | | * 分布式锁超时时间24小时 |
| | | */ |
| | | public static final Long REDIS_EXPIRE_DEFAULT = 24 * 60 * 60L; |
| | | //********************************** redis 相关 ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //********************************** request请求 相关 ********************************** |
| | | /** |
| | | * token存在于headers的键值 |
| | | */ |
| | | public static final String REQUEST_TOKENKEY = "tokencode"; |
| | | /** |
| | | * token过期时间 |
| | | */ |
| | | public static final Long TOKEN_EXPIRE_DEFAULT = 2 * 60 * 60L; |
| | | /** |
| | | * 刷新token过期时间 |
| | | */ |
| | | public static final Long LONG_TOKEN_EXPIRE_DEFAULT = 7 * 24 * 60 * 60L; |
| | | //********************************** request请求 相关 ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //********************************** 正则表达式相关 ********************************** |
| | | /** |
| | | * 字符串格式为日期“yyyy-MM-dd”的正则 |
| | | */ |
| | | public static final String REGEX_DATE = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))$"; |
| | | /** |
| | | * 字符串格式为时间“yyyy-MM-dd HH:mm:ss”的正则 |
| | | */ |
| | | public static final String REGEX_DATETIME = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|([12][0-9])|(3[0-1]))\\s((0[0-9])|(1[0-9])|(2[0-3]))(\\:((0[0-9])|([1-5][0-9]))){2}$"; |
| | | /** |
| | | * 字符串格式为完整时间“yyyy-MM-dd HH:mm:ss.SSS”的正则 |
| | | */ |
| | | public static final String REGEX_DATETIME_FULL = "^[0-9]{4}\\-((0[1-9])|(1[0-2]))\\-((0[1-9])|([12][0-9])|(3[0-1]))\\s((0[0-9])|(1[0-9])|(2[0-3]))(\\:((0[0-9])|([1-5][0-9]))){2}\\.([0-9]){3}$"; |
| | | /** |
| | | * 字符串格式为时间“/Date(1585790902913+0800)/”的正则 |
| | | */ |
| | | public static final String REGEX_DATETIME_JAVA = "^/Date\\((?<timestamp>[0-9]{13})\\+([^\\)]+)\\)/$"; |
| | | |
| | | //********************************** 正则表达式相关 ********************************** |
| | | /** |
| | | * 缴费成功微信模版 |
| | | */ |
| | | public static final String PAY_THE_FEES_SUCCEED="D_m6GtEG-JQspqFuAvjcvzWCQDCtJAKxtq4pqFzgF54"; |
| | | /** |
| | | * 欠费催缴通知 |
| | | */ |
| | | public static final String ARREARAGE_INFORM="suK97dUCdCqQzwgQ90_DRfzI3TFExmEL1n9DAK3oTDE"; |
| | | /** |
| | | * 水费账单提醒 |
| | | */ |
| | | public static final String WATER_RATE_BILL="qqGUVvz3_rcqpDwJ6LywFOsbZhIHV-0oA6sLbHl1pQ4"; |
| | | /** |
| | | * 用水号绑定成功通知 |
| | | */ |
| | | public static final String ACCOUNT_BINDING_SUCCEED="l1wUD1hkSN16sQxsJ6dcm04BnmiO5-cRGgpsjuoSbLY"; |
| | | /** |
| | | * 预付费充值成功提醒 |
| | | */ |
| | | public static final String TOP_UP_SUCCEED="P29GhSpqsvVdIvEvCabpSD47lNjS5J_jw0tYm5GSKpw"; |
| | | |
| | | |
| | | |
| | | //********************************** 正则表达式相关 ********************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public static final BigDecimal FEE_MAX = new BigDecimal("99999999999999999999.99"); |
| | | public static final BigDecimal FEE_PRICE_MAX = new BigDecimal("999.99"); |
| | | public static final BigDecimal FEE_AMOUNT_MAX = new BigDecimal("999999.99"); |
| | | public static final BigDecimal FEE_PERCENTAGE_MAX = new BigDecimal("100"); |
| | | public static final Integer NUM0 = 0; |
| | | public static final Integer NUM1 = 1; |
| | | public static final Integer NUM2 = 2; |
| | | public static final Integer NUM3 = 3; |
| | | public static final Integer NUM4 = 4; |
| | | public static final Integer NUM5 = 5; |
| | | public static final Integer NUM10 = 10; |
| | | public static final Integer NUM15 = 15; |
| | | public static final Integer NUM20 = 20; |
| | | public static final Integer NUM30 = 30; |
| | | public static final Integer NUM50 = 50; |
| | | public static final Integer NUM100 = 100; |
| | | public static final Integer NUM200 = 200; |
| | | public static final Integer NUM500 = 500; |
| | | public static final Integer NUM1000 = 1000; |
| | | public static final Integer NUM2000 = 2000; |
| | | public static final Integer NUM5000 = 5000; |
| | | public static final Integer NUM10000 = 10000; |
| | | public static final Integer LENGTH_MAX10000 = 10000; |
| | | public static final Integer LENGTH_MAX7000 = 7000; |
| | | public static final Integer LENGTH_MAX5000 = 5000; |
| | | public static final Integer LENGTH_MAX2000 = 2000; |
| | | public static final Integer LENGTH_MAX1000 = 1000; |
| | | public static final Integer LENGTH_MAX500 = 500; |
| | | public static final Integer LENGTH_MAX200 = 200; |
| | | public static final Integer LENGTH_MAX100 = 100; |
| | | public static final Integer LENGTH_MAX50 = 50; |
| | | public static final Integer LENGTH_MAX20 = 20; |
| | | public static final Integer LENGTH_MAX11 = 11; |
| | | public static final Integer MONEY_MAX_LENGTH = 2; |
| | | public static final Integer MAX_PAGE_SIZE = 999999; |
| | | public static final Integer PAGE_SIZE_DEFAULT = 20; |
| | | public static final Integer DEFAULT_NUM_PRECISION = 2; |
| | | public static final Integer FILE_UNIT = 1024; |
| | | public static final Integer FILE_SIZE_1M = 1024; |
| | | public static final Integer FILE_SIZE_2M = 2 * 1024; |
| | | public static final Integer FILE_SIZE_5M = 5 * 1024; |
| | | public static final Integer FILE_SIZE_10M = 10 * 1024; |
| | | public static final Integer FILE_SIZE_20M = 20 * 1024; |
| | | public static final Integer FILE_SIZE_50M = 50 * 1024; |
| | | public static final Integer FILE_SIZE_100M = 100 * 1024; |
| | | public static final Integer FILE_SIZE_200M = 200 * 1024; |
| | | public static final Integer TIME_LEN_1S = 1000; |
| | | public static final Integer TIME_LEN_10S = 10 * 1000; |
| | | public static final Integer TIME_LEN_1MIN = 60 * 1000; |
| | | public static final Integer TIME_LEN_5MIN = 5 * 60 * 1000; |
| | | public static final Integer TIME_LEN_10MIN = 10 * 60 * 1000; |
| | | public static final Integer TIME_LEN_20MIN = 20 * 60 * 1000; |
| | | public static final Integer TIME_LEN_50MIN = 50 * 60 * 1000; |
| | | public static final Integer TIME_LEN_100MIN = 100 * 60 * 1000; |
| | | public static final Integer TIME_LEN_1H = 60 * 60 * 1000; |
| | | public static final Integer TIME_LEN_2H = 2 * 60 * 60 * 1000; |
| | | public static final Integer TIME_LEN_12H = 12 * 60 * 60 * 1000; |
| | | public static final Integer TIME_LEN_24H = 24 * 60 * 60 * 1000; |
| | | public static final String KEY_PASSWORD = "lunhan_wcI32U+F5cSF1AL2321UoelnZNYQWxCd_hard_ware"; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fengdu.gas.common.enums.EResultCode; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 执行结果实体 |
| | | * @author lin.liu |
| | | * @date 2019-01-08 |
| | | * @param <T> 数据包类型 |
| | | */ |
| | | public class ExecutedResult<T> { |
| | | private static final String STR_SUCCESS = "success."; |
| | | private static final String STR_FAILED = "failed."; |
| | | |
| | | /** |
| | | * 请求响应状态码 EResultCode |
| | | */ |
| | | private Integer code = EResultCode.FAILED.getCode(); |
| | | /** |
| | | * 错误消息 |
| | | */ |
| | | private String msg = STR_FAILED; |
| | | /** |
| | | * 数据包 |
| | | */ |
| | | private T data = null; |
| | | /** |
| | | * 错误码 |
| | | * @ignore |
| | | */ |
| | | @JsonIgnore |
| | | private String msgCode = ""; |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | public void setCode(Integer code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public T getData() { |
| | | return data; |
| | | } |
| | | public void setData(T data) { |
| | | this.data = data; |
| | | } |
| | | |
| | | public String getMsgCode() { |
| | | return msgCode; |
| | | } |
| | | public void setMsgCode(String msgCode) { |
| | | this.msgCode = msgCode; |
| | | } |
| | | |
| | | public ExecutedResult(){} |
| | | |
| | | public ExecutedResult(EResultCode code, T data){ |
| | | this.code = code.getCode(); |
| | | this.data = data; |
| | | } |
| | | |
| | | public ExecutedResult(EResultCode code, T data, String msg){ |
| | | this.code = code.getCode(); |
| | | this.data = data; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public ExecutedResult(EResultCode code, T data, String msg, String msgCode){ |
| | | this.code = code.getCode(); |
| | | this.data = data; |
| | | this.msg = msg; |
| | | this.msgCode = msgCode; |
| | | } |
| | | |
| | | @JsonIgnore |
| | | public Boolean isSuccess(){ |
| | | return Objects.equals(this.code, EResultCode.SUCCESS.getCode()); |
| | | } |
| | | |
| | | @JsonIgnore |
| | | public Boolean isFailed(){ |
| | | return !this.isSuccess(); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> success(){ |
| | | return new ExecutedResult<>(EResultCode.SUCCESS, null, STR_SUCCESS); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> success(T data){ |
| | | return new ExecutedResult<>(EResultCode.SUCCESS, data, STR_SUCCESS); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> success(T data, String msg){ |
| | | if(StringUtil.isNullOrEmpty(msg)){ |
| | | msg = STR_SUCCESS; |
| | | } |
| | | return new ExecutedResult<>(EResultCode.SUCCESS, data, msg); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> failed(){ |
| | | return ExecutedResult.failed(""); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> failed(String msg){ |
| | | return ExecutedResult.failed(msg, ""); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> failed(String msg, String msgCode){ |
| | | return ExecutedResult.failed(null, msg, msgCode); |
| | | } |
| | | |
| | | public static <T> ExecutedResult<T> failed(T data, String msg, String msgCode){ |
| | | if(StringUtil.isNullOrEmpty(msg)){ |
| | | msg = STR_FAILED; |
| | | } |
| | | return new ExecutedResult<>(EResultCode.FAILED, data, msg, msgCode); |
| | | } |
| | | |
| | | /** |
| | | * 参数验证失败返回结果 |
| | | * @param message 提示信息 |
| | | */ |
| | | public static <T> ExecutedResult<T> validateFailed(String message) { |
| | | return new ExecutedResult<>(EResultCode.VALIDATE_FAILED, null, message); |
| | | } |
| | | |
| | | /** |
| | | * 未登录返回结果 |
| | | */ |
| | | public static <T> ExecutedResult<T> unauthorized(T data) { |
| | | return new ExecutedResult<>(EResultCode.UNAUTHORIZED, data, EResultCode.UNAUTHORIZED.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 未授权返回结果 |
| | | */ |
| | | public static <T> ExecutedResult<T> forbidden() { |
| | | return new ExecutedResult<>(EResultCode.FORBIDDEN, null, EResultCode.FORBIDDEN.getMessage()); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 分页结果 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param <T> 数据包数据类型 |
| | | */ |
| | | public class PagerResult<T> { |
| | | /** |
| | | * 页大小(每页返回的记录条数) |
| | | **/ |
| | | private Number limit = 10; |
| | | /** |
| | | * 页号(第几页, 从1开始) |
| | | **/ |
| | | private Number page = 1; |
| | | /** |
| | | * 记录总条数 |
| | | **/ |
| | | private Number total = 0L; |
| | | /** |
| | | * 上一次请求最后一条数据的id |
| | | * |
| | | **/ |
| | | private Long lastId = 0L; |
| | | /** |
| | | * 数据包 |
| | | **/ |
| | | private List<T> list = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 构造方法 |
| | | */ |
| | | public PagerResult() { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param limit 页大小(每页显示记录数) |
| | | * @param page 页号(第几页, 从1开始) |
| | | * @param total 记录总条数 |
| | | * @param list 数据包 |
| | | */ |
| | | public PagerResult(Number limit, Number page, Number total, List<T> list) { |
| | | this.limit = limit; |
| | | this.page = page; |
| | | this.total = total; |
| | | this.list = list; |
| | | } |
| | | |
| | | public Number getLimit() { |
| | | return limit; |
| | | } |
| | | public void setLimit(Number limit) { |
| | | this.limit = limit; |
| | | } |
| | | |
| | | public Number getPage() { |
| | | return page; |
| | | } |
| | | |
| | | public void setPage(Number page) { |
| | | this.page = page; |
| | | } |
| | | |
| | | public Long getTotal() { |
| | | return total.longValue(); |
| | | } |
| | | |
| | | public void setTotal(Number total) { |
| | | this.total = total; |
| | | } |
| | | |
| | | public List<T> getList() { |
| | | return list; |
| | | } |
| | | |
| | | public void setList(List<T> list) { |
| | | this.list = list; |
| | | } |
| | | |
| | | public Long getLastId() { |
| | | return lastId; |
| | | } |
| | | |
| | | public void setLastId(Long lastId) { |
| | | this.lastId = lastId; |
| | | } |
| | | |
| | | /** |
| | | * 总页数 |
| | | */ |
| | | public Long getTotalPage() { |
| | | Long page = this.total.longValue() / this.limit.longValue(); |
| | | if(this.total.longValue() % this.limit.longValue() != 0){ |
| | | page++; |
| | | } |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * 是否还有上一页 |
| | | */ |
| | | public boolean getIsHasPrePage() { |
| | | return this.getPage().longValue() > 1L; |
| | | } |
| | | |
| | | /** |
| | | * 是否还有下一页 |
| | | */ |
| | | public boolean getIsHasNextPage() { |
| | | return this.getPage().longValue() < this.getTotalPage(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class PagerResultMore<T, M> extends PagerResult<T> { |
| | | /** |
| | | * 其他信息 |
| | | */ |
| | | private M other; |
| | | |
| | | public M getOther() { |
| | | return other; |
| | | } |
| | | |
| | | public void setOther(M other) { |
| | | this.other = other; |
| | | } |
| | | |
| | | public PagerResultMore() { |
| | | } |
| | | |
| | | public PagerResultMore(Integer limit, Integer page, Number total, List<T> list, M other) { |
| | | super(limit, page, total, list); |
| | | this.other = other; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @FunctionalInterface |
| | | public interface ToBigDecimalFunction<T> { |
| | | BigDecimal applyAsBigDecimal(T value); |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.cache; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import org.springframework.cache.CacheManager; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Primary; |
| | | import org.springframework.data.redis.cache.RedisCacheConfiguration; |
| | | import org.springframework.data.redis.cache.RedisCacheManager; |
| | | import org.springframework.data.redis.connection.RedisConnectionFactory; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.serializer.*; |
| | | |
| | | import java.time.Duration; |
| | | |
| | | @Configuration |
| | | public class CacheManagerConfig { |
| | | @Bean |
| | | @Primary |
| | | public CacheManager json4RedisCacheManager(RedisConnectionFactory redisConnectionFactory) { |
| | | RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() |
| | | //设置24小时过期 |
| | | .entryTtl(Duration.ofMillis(ConstantFactory.TIME_LEN_24H)) |
| | | //设置key的序列化方式 |
| | | .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new RedisKeySerializer())) |
| | | //设置值的序列化方式 |
| | | .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())); |
| | | |
| | | |
| | | RedisCacheManager.RedisCacheManagerBuilder builder = |
| | | RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(redisConnectionFactory); |
| | | |
| | | //返回构造的cacheManager |
| | | return builder.transactionAware().cacheDefaults(config).build(); |
| | | } |
| | | |
| | | @Bean |
| | | public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) { |
| | | StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(redisConnectionFactory); |
| | | stringRedisTemplate.setKeySerializer(new RedisKeySerializer()); |
| | | return stringRedisTemplate; |
| | | } |
| | | |
| | | @Bean |
| | | public RedisTemplate<String, Object> objectRedisTemplate(RedisConnectionFactory redisConnectionFactory) { |
| | | RedisSerializer<String> serializer = new StringRedisSerializer(); |
| | | Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); |
| | | RedisTemplate<String, Object> template = new RedisTemplate<>(); |
| | | template.setConnectionFactory(redisConnectionFactory); |
| | | template.setKeySerializer(new RedisKeySerializer()); |
| | | template.setValueSerializer(jackson2JsonRedisSerializer); |
| | | template.setHashKeySerializer(serializer); |
| | | template.setHashValueSerializer(jackson2JsonRedisSerializer); |
| | | template.afterPropertiesSet(); |
| | | |
| | | return template; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.cache; |
| | | |
| | | import com.fengdu.gas.common.config.SysConfig; |
| | | import org.springframework.data.redis.serializer.RedisSerializer; |
| | | import org.springframework.lang.Nullable; |
| | | |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | public class RedisKeySerializer implements RedisSerializer<String> { |
| | | private static final Charset charset = StandardCharsets.UTF_8; |
| | | |
| | | /* |
| | | * (non-Javadoc) |
| | | * @see org.springframework.data.redis.serializer.RedisSerializer#deserialize(byte[]) |
| | | */ |
| | | @Override |
| | | public String deserialize(@Nullable byte[] bytes) { |
| | | return (bytes == null ? null : new String(bytes, charset).replaceFirst(SysConfig.redis.getKeyPrefix(), "")); |
| | | } |
| | | |
| | | /* |
| | | * (non-Javadoc) |
| | | * @see org.springframework.data.redis.serializer.RedisSerializer#serialize(java.lang.Object) |
| | | */ |
| | | @Override |
| | | public byte[] serialize(@Nullable String string) { |
| | | return (string == null ? null : (SysConfig.redis.getKeyPrefix() + string).getBytes(charset)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @ConfigurationProperties(prefix = "file") |
| | | public class FileConfig { |
| | | private String uploadBasicPath; |
| | | private String fileBasicUrl; |
| | | private String disturbStr; |
| | | |
| | | public String getUploadBasicPath() { |
| | | return uploadBasicPath; |
| | | } |
| | | |
| | | public void setUploadBasicPath(String uploadBasicPath) { |
| | | this.uploadBasicPath = uploadBasicPath; |
| | | } |
| | | |
| | | public String getFileBasicUrl() { |
| | | return fileBasicUrl; |
| | | } |
| | | |
| | | public void setFileBasicUrl(String fileBasicUrl) { |
| | | this.fileBasicUrl = fileBasicUrl; |
| | | } |
| | | |
| | | public String getDisturbStr() { |
| | | return disturbStr; |
| | | } |
| | | |
| | | public void setDisturbStr(String disturbStr) { |
| | | this.disturbStr = disturbStr; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @ConfigurationProperties(prefix = "jwt") |
| | | public class JWTConfig { |
| | | private String head; |
| | | private String tokenHeader; |
| | | private String secret; |
| | | private Long expiration; |
| | | |
| | | public String getHead() { |
| | | return head; |
| | | } |
| | | |
| | | public void setHead(String head) { |
| | | this.head = head; |
| | | } |
| | | |
| | | public String getTokenHeader() { |
| | | return tokenHeader; |
| | | } |
| | | |
| | | public void setTokenHeader(String tokenHeader) { |
| | | this.tokenHeader = tokenHeader; |
| | | } |
| | | |
| | | public String getSecret() { |
| | | return secret; |
| | | } |
| | | |
| | | public void setSecret(String secret) { |
| | | this.secret = secret; |
| | | } |
| | | |
| | | public Long getExpiration() { |
| | | return expiration; |
| | | } |
| | | |
| | | public void setExpiration(Long expiration) { |
| | | this.expiration = expiration; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @ConfigurationProperties(prefix = "jdbc-set") |
| | | public class JdbcSetConfig { |
| | | private String sqlLog; |
| | | |
| | | public String getSqlLog() { |
| | | return sqlLog; |
| | | } |
| | | |
| | | public void setSqlLog(String sqlLog) { |
| | | this.sqlLog = sqlLog; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @ConfigurationProperties(prefix = "spring.redis") |
| | | public class RedisConfig { |
| | | private String keyPrefix; |
| | | |
| | | public String getKeyPrefix() { |
| | | return keyPrefix; |
| | | } |
| | | |
| | | public void setKeyPrefix(String keyPrefix) { |
| | | this.keyPrefix = keyPrefix; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.config; |
| | | |
| | | import com.fengdu.gas.common.util.SpringUtil; |
| | | |
| | | /** |
| | | * 获取系统配置 读取“config.properties” |
| | | */ |
| | | public final class SysConfig { |
| | | public static JWTConfig jwt = SpringUtil.getBean(JWTConfig.class); |
| | | public static JdbcSetConfig jdbc = SpringUtil.getBean(JdbcSetConfig.class); |
| | | public static FileConfig file = SpringUtil.getBean(FileConfig.class); |
| | | public static RedisConfig redis = SpringUtil.getBean(RedisConfig.class); |
| | | |
| | | public static String getTokenHeader() { |
| | | return jwt.getTokenHeader(); |
| | | //return properties.getProperty("jwt.tokenHeader", ""); |
| | | } |
| | | |
| | | public static String getJwtHead() { |
| | | return jwt.getHead(); |
| | | //return properties.getProperty("jwt.tokenHead", ""); |
| | | } |
| | | |
| | | public static String getTJwtHeader() { |
| | | return jwt.getTokenHeader(); |
| | | //return properties.getProperty("jwt.tokenHeader", ""); |
| | | } |
| | | |
| | | public static boolean isSqlLog() { |
| | | return "true".equalsIgnoreCase(jdbc.getSqlLog()); |
| | | //return properties.getProperty("mail.sendEmail", ""); |
| | | } |
| | | |
| | | public static String fileUploadBasic() { |
| | | return file.getUploadBasicPath(); |
| | | } |
| | | |
| | | public static String fileViewBasic() { |
| | | return file.getFileBasicUrl(); |
| | | } |
| | | |
| | | public static String fileDisturbStr() { |
| | | return file.getDisturbStr(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @ConfigurationProperties(prefix = "token") |
| | | public class TokenConfig { |
| | | private String tokenHeader; |
| | | private String expiredTime; |
| | | private String longExpiredTime; |
| | | |
| | | public String getTokenHeader() { |
| | | return tokenHeader; |
| | | } |
| | | |
| | | public void setTokenHeader(String tokenHeader) { |
| | | this.tokenHeader = tokenHeader; |
| | | } |
| | | |
| | | public String getExpiredTime() { |
| | | return expiredTime; |
| | | } |
| | | |
| | | public void setExpiredTime(String expiredTime) { |
| | | this.expiredTime = expiredTime; |
| | | } |
| | | |
| | | public String getLongExpiredTime() { |
| | | return longExpiredTime; |
| | | } |
| | | |
| | | public void setLongExpiredTime(String longExpiredTime) { |
| | | this.longExpiredTime = longExpiredTime; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * ContentType 枚举 |
| | | */ |
| | | public enum EContentType { |
| | | /** |
| | | * application/json |
| | | */ |
| | | JSON("application/json", "application/json"), |
| | | /** |
| | | * application/x-www-form-urlencoded |
| | | */ |
| | | FORM("application/x-www-form-urlencoded", "application/x-www-form-urlencoded"), |
| | | /** |
| | | * multipart/form-data |
| | | */ |
| | | FORMDATA("multipart/form-data", "multipart/form-data"), |
| | | /** |
| | | * application/xml |
| | | */ |
| | | XML("application/xml", "application/xml"), |
| | | /** |
| | | * text/plain |
| | | */ |
| | | TEXT("text/plain", "text/plain"), |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * application/vnd.ms-excel |
| | | */ |
| | | EXCEL("application/vnd.ms-excel", "application/vnd.ms-excel"), |
| | | /** |
| | | * application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| | | */ |
| | | EXCELX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), |
| | | /** |
| | | * application/msword |
| | | */ |
| | | WORD("application/msword", "application/msword"), |
| | | /** |
| | | * application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| | | */ |
| | | WORDX("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), |
| | | /** |
| | | * application/vnd.ms-powerpoint |
| | | */ |
| | | PPT("application/vnd.ms-powerpoint", "application/vnd.ms-powerpoint"), |
| | | /** |
| | | * application/vnd.openxmlformats-officedocument.presentationml.presentation |
| | | */ |
| | | PPTX("application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.presentation"), |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * image/jpeg |
| | | */ |
| | | JPEG("image/jpeg", "image/jpeg"), |
| | | /** |
| | | * image/jpg |
| | | */ |
| | | JPG("image/jpg", "image/jpg"), |
| | | /** |
| | | * image/gif |
| | | */ |
| | | GIF("image/gif", "image/gif"), |
| | | /** |
| | | * image/png |
| | | */ |
| | | PNG("image/png", "image/png"), |
| | | /** |
| | | * image/bmp |
| | | */ |
| | | BMP("image/bmp", "image/bmp"), |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * application/zip |
| | | */ |
| | | ZIP("application/zip", "application/zip"), |
| | | /** |
| | | * application/x-rar |
| | | */ |
| | | RAR("application/x-rar", "application/x-rar"), |
| | | /** |
| | | * application/x-7z-compressed |
| | | */ |
| | | X7Z("application/x-7z-compressed", "application/x-7z-compressed"), |
| | | /** |
| | | * application/x-gzip |
| | | */ |
| | | GZ("application/x-gzip", "application/x-gzip"), |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * video/mpeg |
| | | */ |
| | | MP2("video/mpeg", "video/mpeg"), |
| | | /** |
| | | * audio/mpeg |
| | | */ |
| | | MP3("audio/mpeg", "audio/mpeg"), |
| | | /** |
| | | * aaudio/x-flac |
| | | */ |
| | | FLAC("audio/x-flac", "audio/x-flac"), |
| | | /** |
| | | * video/x-flv |
| | | */ |
| | | FLV("video/x-flv", "video/x-flv"), |
| | | /** |
| | | * video/3gpp |
| | | */ |
| | | X3GP("video/3gpp", "video/3gpp"), |
| | | /** |
| | | * video/mp4 |
| | | */ |
| | | MP4("video/mp4", "video/mp4"), |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * application/pdf |
| | | */ |
| | | PDF("application/pdf", "application/pdf") |
| | | ; |
| | | |
| | | private String desc;//枚举描述 |
| | | private String value;//枚举值 |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EContentType(String desc, String value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EContentType getByValue(String value) { |
| | | return Arrays.stream(EContentType.values()) |
| | | .filter(e -> e.getValue().equals(value)) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EContentType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 水平位置 枚举 |
| | | */ |
| | | public enum EHorizontalLocation { |
| | | /** |
| | | * 靠左 |
| | | */ |
| | | LEFT("LEFT", 1), |
| | | |
| | | /** |
| | | * 居中 |
| | | */ |
| | | CENTRE("CENTRE", 2), |
| | | |
| | | /** |
| | | * 靠右 |
| | | */ |
| | | RIGHT("RIGHT", 3); |
| | | |
| | | private String desc;//枚举描述 |
| | | private int value;//枚举值 |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EHorizontalLocation(String desc, int value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EHorizontalLocation getByValue(int value) { |
| | | return Arrays.stream(EHorizontalLocation.values()) |
| | | .filter(e -> e.getValue() == value) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EHorizontalLocation{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * http请求类型 枚举 |
| | | * @author linliu |
| | | * @date 2019-01-08 |
| | | */ |
| | | public enum EHttpContentType { |
| | | /** |
| | | * application/json |
| | | */ |
| | | JSON("application/json", "application/json"), |
| | | /** |
| | | * application/x-www-form-urlencoded |
| | | */ |
| | | FORM("application/x-www-form-urlencoded", "application/x-www-form-urlencoded"), |
| | | /** |
| | | * multipart/form-data |
| | | */ |
| | | FORMDATA("multipart/form-data", "multipart/form-data"), |
| | | /** |
| | | * application/xml |
| | | */ |
| | | XML("application/xml", "application/xml"); |
| | | |
| | | private String desc;//枚举描述 |
| | | private String value;//枚举值 |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EHttpContentType(String desc, String value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EHttpContentType getByValue(String value) { |
| | | return Arrays.stream(EHttpContentType.values()) |
| | | .filter(e -> e.getValue().equals(value)) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EHttpContentType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | public enum ELogger { |
| | | DEBUG("debug"), |
| | | INFO("info"), |
| | | API_REQUEST("apiRequest"), |
| | | |
| | | SQL_LOG("sqlLog"), |
| | | SYS_ERROR("sysError"), |
| | | PAY_SERVICE("payService") |
| | | ; |
| | | |
| | | private String logFileName; |
| | | |
| | | ELogger(String logFileName) { |
| | | this.logFileName = logFileName; |
| | | } |
| | | |
| | | public String getLogFileName() { |
| | | return this.logFileName; |
| | | } |
| | | |
| | | public static ELogger getByLoggerName(String loggerName) { |
| | | ELogger[] arr = values(); |
| | | return Arrays.stream(arr) |
| | | .filter(c -> Objects.equals(c.getLogFileName(), loggerName)) |
| | | .findAny().orElse(null); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * token存放地方 枚举 |
| | | * @author linliu |
| | | * @date 2019-06-04 |
| | | */ |
| | | public enum ERequestTokenFrom { |
| | | /** |
| | | * token从 headers 传输 |
| | | */ |
| | | HEADERS("headers", 1), |
| | | /** |
| | | * token从 urls 传输 |
| | | */ |
| | | URLS("urls", 2); |
| | | |
| | | private String desc;//枚举描述 |
| | | private int value;//枚举值 |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | ERequestTokenFrom(String desc, int value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static ERequestTokenFrom getByValue(int value) { |
| | | return Arrays.stream(ERequestTokenFrom.values()) |
| | | .filter(e -> e.getValue() == value) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ERequestTokenFrom{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | /** |
| | | * 执行结果 枚举 |
| | | * @author linliu |
| | | * @date 2019-01-08 |
| | | */ |
| | | public enum EResultCode implements IErrorCode { |
| | | /** |
| | | * 操作成功=200, |
| | | **/ |
| | | SUCCESS(200, "操作成功"), |
| | | /** |
| | | * 部分成功=210 |
| | | */ |
| | | PARTIAL_SUCCESS(210, "部分成功"), |
| | | /** |
| | | * 操作失败=300, |
| | | **/ |
| | | FAILED(300, "操作失败"), |
| | | /** |
| | | * 参数检验失败=301, |
| | | **/ |
| | | VALIDATE_FAILED(301, "参数检验失败"), |
| | | /** |
| | | * 相关需要支付:未付费 |
| | | */ |
| | | UNPAID(302,"未付费"), |
| | | /** |
| | | * 积分不足,充值提示 |
| | | */ |
| | | INTEGRAL(303,"积分不足,请充值。"), |
| | | /** |
| | | * 未登录或token已经过期=401, |
| | | **/ |
| | | UNAUTHORIZED(401, "未登录或token已经过期"), |
| | | /** |
| | | * 没有相关权限=403, |
| | | **/ |
| | | FORBIDDEN(403, "没有相关权限"), |
| | | /** |
| | | * 找不到相关资源=404, |
| | | **/ |
| | | NOT_FOUND(404, "找不到相关资源"), |
| | | /** |
| | | * 签名验证失败=407, |
| | | */ |
| | | SIGN_NOT_PASS(407, "签名验证失败"), |
| | | /** |
| | | * 系统繁忙=500, |
| | | **/ |
| | | ERROR(500, "系统繁忙"); |
| | | |
| | | private Integer code; |
| | | private String message; |
| | | |
| | | EResultCode(Integer code, String message) { |
| | | this.code = code; |
| | | this.message = message; |
| | | } |
| | | |
| | | @Override |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return message; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 垂直位置 枚举 |
| | | */ |
| | | public enum EVerticalLocation { |
| | | /** |
| | | * 靠顶端 |
| | | */ |
| | | TOP("TOP", 1), |
| | | |
| | | /** |
| | | * 居中 |
| | | */ |
| | | MIDDLE("MIDDLE", 2), |
| | | |
| | | /** |
| | | * 靠底部 |
| | | */ |
| | | BOTTOM("BOTTOM", 3); |
| | | |
| | | private String desc;//枚举描述 |
| | | private int value;//枚举值 |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EVerticalLocation(String desc, int value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EVerticalLocation getByValue(int value) { |
| | | return Arrays.stream(EVerticalLocation.values()) |
| | | .filter(e -> e.getValue() == value) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EVerticalLocation{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | public enum EYesOrNo { |
| | | /** |
| | | * 否 |
| | | */ |
| | | NO("否", 0), |
| | | |
| | | /** |
| | | * 是=1 |
| | | */ |
| | | YES("是", 1) |
| | | ; |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EYesOrNo(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EYesOrNo getByValue(Integer value) { |
| | | return Arrays.stream(EYesOrNo.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EYesOrNo{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | /** |
| | | * 枚举基类 |
| | | * @author linliu |
| | | * @date 2019-01-08 |
| | | */ |
| | | public interface EnumBasic { |
| | | int getValue(); |
| | | String getColumnName(); |
| | | String getTableName(); |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.enums; |
| | | |
| | | /** |
| | | * @Author lin.liu |
| | | * @Description 错误编码 接口 |
| | | * @Date 2021/4/16 |
| | | **/ |
| | | public interface IErrorCode { |
| | | /** |
| | | * 错误编码 |
| | | **/ |
| | | Integer getCode(); |
| | | |
| | | /** |
| | | * 错误信息 |
| | | **/ |
| | | String getMessage(); |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.exceptions; |
| | | |
| | | import com.fengdu.gas.common.enums.EResultCode; |
| | | |
| | | /** |
| | | * 自定义业务异常 |
| | | */ |
| | | public class BusinessException extends RuntimeException { |
| | | private EResultCode code; |
| | | |
| | | public EResultCode getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(EResultCode code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public BusinessException() { |
| | | super(); |
| | | } |
| | | |
| | | public BusinessException(String message) { |
| | | super(message); |
| | | this.code = EResultCode.ERROR; |
| | | } |
| | | |
| | | public BusinessException(EResultCode code, String message) { |
| | | super(message); |
| | | this.code = code; |
| | | } |
| | | |
| | | public BusinessException(String message, Throwable cause) { |
| | | super(message, cause); |
| | | } |
| | | |
| | | public BusinessException(Throwable cause) { |
| | | super(cause); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.extend; |
| | | |
| | | import com.fengdu.gas.common.ToBigDecimalFunction; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.ConcurrentMap; |
| | | import java.util.function.*; |
| | | import java.util.stream.Collector; |
| | | import java.util.stream.Stream; |
| | | |
| | | public class CollectorsPlus { |
| | | static final Set<Collector.Characteristics> CH_CONCURRENT_ID |
| | | = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT, |
| | | Collector.Characteristics.UNORDERED, |
| | | Collector.Characteristics.IDENTITY_FINISH)); |
| | | static final Set<Collector.Characteristics> CH_CONCURRENT_NOID |
| | | = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT, |
| | | Collector.Characteristics.UNORDERED)); |
| | | static final Set<Collector.Characteristics> CH_ID |
| | | = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH)); |
| | | static final Set<Collector.Characteristics> CH_UNORDERED_ID |
| | | = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED, |
| | | Collector.Characteristics.IDENTITY_FINISH)); |
| | | static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet(); |
| | | |
| | | private CollectorsPlus() { } |
| | | |
| | | /** |
| | | * Returns a merge function, suitable for use in |
| | | * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or |
| | | * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always |
| | | * throws {@code IllegalStateException}. This can be used to enforce the |
| | | * assumption that the elements being collected are distinct. |
| | | * |
| | | * @param <T> the type of input arguments to the merge function |
| | | * @return a merge function which always throw {@code IllegalStateException} |
| | | */ |
| | | private static <T> BinaryOperator<T> throwingMerger() { |
| | | return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private static <I, R> Function<I, R> castingIdentity() { |
| | | return i -> (R) i; |
| | | } |
| | | |
| | | /** |
| | | * Simple implementation class for {@code Collector}. |
| | | * |
| | | * @param <T> the type of elements to be collected |
| | | * @param <R> the type of the result |
| | | */ |
| | | static class CollectorImpl<T, A, R> implements Collector<T, A, R> { |
| | | private final Supplier<A> supplier; |
| | | private final BiConsumer<A, T> accumulator; |
| | | private final BinaryOperator<A> combiner; |
| | | private final Function<A, R> finisher; |
| | | private final Set<Characteristics> characteristics; |
| | | |
| | | CollectorImpl(Supplier<A> supplier, |
| | | BiConsumer<A, T> accumulator, |
| | | BinaryOperator<A> combiner, |
| | | Function<A,R> finisher, |
| | | Set<Characteristics> characteristics) { |
| | | this.supplier = supplier; |
| | | this.accumulator = accumulator; |
| | | this.combiner = combiner; |
| | | this.finisher = finisher; |
| | | this.characteristics = characteristics; |
| | | } |
| | | |
| | | CollectorImpl(Supplier<A> supplier, |
| | | BiConsumer<A, T> accumulator, |
| | | BinaryOperator<A> combiner, |
| | | Set<Characteristics> characteristics) { |
| | | this(supplier, accumulator, combiner, castingIdentity(), characteristics); |
| | | } |
| | | |
| | | @Override |
| | | public BiConsumer<A, T> accumulator() { |
| | | return accumulator; |
| | | } |
| | | |
| | | @Override |
| | | public Supplier<A> supplier() { |
| | | return supplier; |
| | | } |
| | | |
| | | @Override |
| | | public BinaryOperator<A> combiner() { |
| | | return combiner; |
| | | } |
| | | |
| | | @Override |
| | | public Function<A, R> finisher() { |
| | | return finisher; |
| | | } |
| | | |
| | | @Override |
| | | public Set<Characteristics> characteristics() { |
| | | return characteristics; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that accumulates the input elements into a |
| | | * new {@code Collection}, in encounter order. The {@code Collection} is |
| | | * created by the provided factory. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <C> the type of the resulting {@code Collection} |
| | | * @param collectionFactory a {@code Supplier} which returns a new, empty |
| | | * {@code Collection} of the appropriate type |
| | | * @return a {@code Collector} which collects all the input elements into a |
| | | * {@code Collection}, in encounter order |
| | | */ |
| | | public static <T, C extends Collection<T>> |
| | | Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) { |
| | | return new CollectorImpl<>(collectionFactory, Collection<T>::add, |
| | | (r1, r2) -> { r1.addAll(r2); return r1; }, |
| | | CH_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that accumulates the input elements into a |
| | | * new {@code List}. There are no guarantees on the type, mutability, |
| | | * serializability, or thread-safety of the {@code List} returned; if more |
| | | * control over the returned {@code List} is required, use {@link #toCollection(Supplier)}. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @return a {@code Collector} which collects all the input elements into a |
| | | * {@code List}, in encounter order |
| | | */ |
| | | public static <T> |
| | | Collector<T, ?, List<T>> toList() { |
| | | return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add, |
| | | (left, right) -> { left.addAll(right); return left; }, |
| | | CH_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that accumulates the input elements into a |
| | | * new {@code Set}. There are no guarantees on the type, mutability, |
| | | * serializability, or thread-safety of the {@code Set} returned; if more |
| | | * control over the returned {@code Set} is required, use |
| | | * {@link #toCollection(Supplier)}. |
| | | * |
| | | * <p>This is an {@link Collector.Characteristics#UNORDERED unordered} |
| | | * Collector. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @return a {@code Collector} which collects all the input elements into a |
| | | * {@code Set} |
| | | */ |
| | | public static <T> |
| | | Collector<T, ?, Set<T>> toSet() { |
| | | return new CollectorImpl<>((Supplier<Set<T>>) HashSet::new, Set::add, |
| | | (left, right) -> { left.addAll(right); return left; }, |
| | | CH_UNORDERED_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that concatenates the input elements into a |
| | | * {@code String}, in encounter order. |
| | | * |
| | | * @return a {@code Collector} that concatenates the input elements into a |
| | | * {@code String}, in encounter order |
| | | */ |
| | | public static Collector<CharSequence, ?, String> joining() { |
| | | return new CollectorImpl<CharSequence, StringBuilder, String>( |
| | | StringBuilder::new, StringBuilder::append, |
| | | (r1, r2) -> { r1.append(r2); return r1; }, |
| | | StringBuilder::toString, CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that concatenates the input elements, |
| | | * separated by the specified delimiter, in encounter order. |
| | | * |
| | | * @param delimiter the delimiter to be used between each element |
| | | * @return A {@code Collector} which concatenates CharSequence elements, |
| | | * separated by the specified delimiter, in encounter order |
| | | */ |
| | | public static Collector<CharSequence, ?, String> joining(CharSequence delimiter) { |
| | | return joining(delimiter, "", ""); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that concatenates the input elements, |
| | | * separated by the specified delimiter, with the specified prefix and |
| | | * suffix, in encounter order. |
| | | * |
| | | * @param delimiter the delimiter to be used between each element |
| | | * @param prefix the sequence of characters to be used at the beginning |
| | | * of the joined result |
| | | * @param suffix the sequence of characters to be used at the end |
| | | * of the joined result |
| | | * @return A {@code Collector} which concatenates CharSequence elements, |
| | | * separated by the specified delimiter, in encounter order |
| | | */ |
| | | public static Collector<CharSequence, ?, String> joining(CharSequence delimiter, |
| | | CharSequence prefix, |
| | | CharSequence suffix) { |
| | | return new CollectorImpl<>( |
| | | () -> new StringJoiner(delimiter, prefix, suffix), |
| | | StringJoiner::add, StringJoiner::merge, |
| | | StringJoiner::toString, CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * {@code BinaryOperator<Map>} that merges the contents of its right |
| | | * argument into its left argument, using the provided merge function to |
| | | * handle duplicate keys. |
| | | * |
| | | * @param <K> type of the map keys |
| | | * @param <V> type of the map values |
| | | * @param <M> type of the map |
| | | * @param mergeFunction A merge function suitable for |
| | | * {@link Map#merge(Object, Object, BiFunction) Map.merge()} |
| | | * @return a merge function for two maps |
| | | */ |
| | | private static <K, V, M extends Map<K,V>> |
| | | BinaryOperator<M> mapMerger(BinaryOperator<V> mergeFunction) { |
| | | return (m1, m2) -> { |
| | | for (Map.Entry<K,V> e : m2.entrySet()) { |
| | | m1.merge(e.getKey(), e.getValue(), mergeFunction); |
| | | } |
| | | return m1; |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Adapts a {@code Collector} accepting elements of type {@code U} to one |
| | | * accepting elements of type {@code T} by applying a mapping function to |
| | | * each input element before accumulation. |
| | | * |
| | | * @apiNote |
| | | * The {@code mapping()} collectors are most useful when used in a |
| | | * multi-level reduction, such as downstream of a {@code groupingBy} or |
| | | * {@code partitioningBy}. For example, given a stream of |
| | | * {@code Person}, to accumulate the set of last names in each city: |
| | | * <pre>{@code |
| | | * Map<City, Set<String>> lastNamesByCity |
| | | * = people.stream().collect(groupingBy(Person::getCity, |
| | | * mapping(Person::getLastName, toSet()))); |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <U> type of elements accepted by downstream collector |
| | | * @param <A> intermediate accumulation type of the downstream collector |
| | | * @param <R> result type of collector |
| | | * @param mapper a function to be applied to the input elements |
| | | * @param downstream a collector which will accept mapped values |
| | | * @return a collector which applies the mapping function to the input |
| | | * elements and provides the mapped results to the downstream collector |
| | | */ |
| | | public static <T, U, A, R> |
| | | Collector<T, ?, R> mapping(Function<? super T, ? extends U> mapper, |
| | | Collector<? super U, A, R> downstream) { |
| | | BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator(); |
| | | return new CollectorImpl<>(downstream.supplier(), |
| | | (r, t) -> downstreamAccumulator.accept(r, mapper.apply(t)), |
| | | downstream.combiner(), downstream.finisher(), |
| | | downstream.characteristics()); |
| | | } |
| | | |
| | | /** |
| | | * Adapts a {@code Collector} to perform an additional finishing |
| | | * transformation. For example, one could adapt the {@link #toList()} |
| | | * collector to always produce an immutable list with: |
| | | * <pre>{@code |
| | | * List<String> people |
| | | * = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList)); |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <A> intermediate accumulation type of the downstream collector |
| | | * @param <R> result type of the downstream collector |
| | | * @param <RR> result type of the resulting collector |
| | | * @param downstream a collector |
| | | * @param finisher a function to be applied to the final result of the downstream collector |
| | | * @return a collector which performs the action of the downstream collector, |
| | | * followed by an additional finishing step |
| | | */ |
| | | public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream, |
| | | Function<R,RR> finisher) { |
| | | Set<Collector.Characteristics> characteristics = downstream.characteristics(); |
| | | if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) { |
| | | if (characteristics.size() == 1) |
| | | characteristics = CollectorsPlus.CH_NOID; |
| | | else { |
| | | characteristics = EnumSet.copyOf(characteristics); |
| | | characteristics.remove(Collector.Characteristics.IDENTITY_FINISH); |
| | | characteristics = Collections.unmodifiableSet(characteristics); |
| | | } |
| | | } |
| | | return new CollectorImpl<>(downstream.supplier(), |
| | | downstream.accumulator(), |
| | | downstream.combiner(), |
| | | downstream.finisher().andThen(finisher), |
| | | characteristics); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} accepting elements of type {@code T} that |
| | | * counts the number of input elements. If no elements are present, the |
| | | * result is 0. |
| | | * |
| | | * @implSpec |
| | | * This produces a result equivalent to: |
| | | * <pre>{@code |
| | | * reducing(0L, e -> 1L, Long::sum) |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @return a {@code Collector} that counts the input elements |
| | | */ |
| | | public static <T> Collector<T, ?, Long> |
| | | counting() { |
| | | return reducing(0L, e -> 1L, Long::sum); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the minimal element according |
| | | * to a given {@code Comparator}, described as an {@code Optional<T>}. |
| | | * |
| | | * @implSpec |
| | | * This produces a result equivalent to: |
| | | * <pre>{@code |
| | | * reducing(BinaryOperator.minBy(comparator)) |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param comparator a {@code Comparator} for comparing elements |
| | | * @return a {@code Collector} that produces the minimal value |
| | | */ |
| | | public static <T> Collector<T, ?, Optional<T>> |
| | | minBy(Comparator<? super T> comparator) { |
| | | return reducing(BinaryOperator.minBy(comparator)); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the maximal element according |
| | | * to a given {@code Comparator}, described as an {@code Optional<T>}. |
| | | * |
| | | * @implSpec |
| | | * This produces a result equivalent to: |
| | | * <pre>{@code |
| | | * reducing(BinaryOperator.maxBy(comparator)) |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param comparator a {@code Comparator} for comparing elements |
| | | * @return a {@code Collector} that produces the maximal value |
| | | */ |
| | | public static <T> Collector<T, ?, Optional<T>> |
| | | maxBy(Comparator<? super T> comparator) { |
| | | return reducing(BinaryOperator.maxBy(comparator)); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the sum of a integer-valued |
| | | * function applied to the input elements. If no elements are present, |
| | | * the result is 0. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a function extracting the property to be summed |
| | | * @return a {@code Collector} that produces the sum of a derived property |
| | | */ |
| | | public static <T> Collector<T, ?, Integer> |
| | | summingInt(ToIntFunction<? super T> mapper) { |
| | | return new CollectorImpl<>( |
| | | () -> new int[1], |
| | | (a, t) -> { a[0] += mapper.applyAsInt(t); }, |
| | | (a, b) -> { a[0] += b[0]; return a; }, |
| | | a -> a[0], CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the sum of a long-valued |
| | | * function applied to the input elements. If no elements are present, |
| | | * the result is 0. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a function extracting the property to be summed |
| | | * @return a {@code Collector} that produces the sum of a derived property |
| | | */ |
| | | public static <T> Collector<T, ?, Long> |
| | | summingLong(ToLongFunction<? super T> mapper) { |
| | | return new CollectorImpl<>( |
| | | () -> new long[1], |
| | | (a, t) -> { a[0] += mapper.applyAsLong(t); }, |
| | | (a, b) -> { a[0] += b[0]; return a; }, |
| | | a -> a[0], CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the sum of a double-valued |
| | | * function applied to the input elements. If no elements are present, |
| | | * the result is 0. |
| | | * |
| | | * <p>The sum returned can vary depending upon the order in which |
| | | * values are recorded, due to accumulated rounding error in |
| | | * addition of values of differing magnitudes. Values sorted by increasing |
| | | * absolute magnitude tend to yield more accurate results. If any recorded |
| | | * value is a {@code NaN} or the sum is at any point a {@code NaN} then the |
| | | * sum will be {@code NaN}. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a function extracting the property to be summed |
| | | * @return a {@code Collector} that produces the sum of a derived property |
| | | */ |
| | | public static <T> Collector<T, ?, Double> |
| | | summingDouble(ToDoubleFunction<? super T> mapper) { |
| | | /* |
| | | * In the arrays allocated for the collect operation, index 0 |
| | | * holds the high-order bits of the running sum, index 1 holds |
| | | * the low-order bits of the sum computed via compensated |
| | | * summation, and index 2 holds the simple sum used to compute |
| | | * the proper result if the stream contains infinite values of |
| | | * the same sign. |
| | | */ |
| | | return new CollectorImpl<>( |
| | | () -> new double[3], |
| | | (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); |
| | | a[2] += mapper.applyAsDouble(t);}, |
| | | (a, b) -> { sumWithCompensation(a, b[0]); |
| | | a[2] += b[2]; |
| | | return sumWithCompensation(a, b[1]); }, |
| | | a -> computeFinalSum(a), |
| | | CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Incorporate a new double value using Kahan summation / |
| | | * compensation summation. |
| | | * |
| | | * High-order bits of the sum are in intermediateSum[0], low-order |
| | | * bits of the sum are in intermediateSum[1], any additional |
| | | * elements are application-specific. |
| | | * |
| | | * @param intermediateSum the high-order and low-order words of the intermediate sum |
| | | * @param value the name value to be included in the running sum |
| | | */ |
| | | static double[] sumWithCompensation(double[] intermediateSum, double value) { |
| | | double tmp = value - intermediateSum[1]; |
| | | double sum = intermediateSum[0]; |
| | | double velvel = sum + tmp; // Little wolf of rounding error |
| | | intermediateSum[1] = (velvel - sum) - tmp; |
| | | intermediateSum[0] = velvel; |
| | | return intermediateSum; |
| | | } |
| | | |
| | | /** |
| | | * If the compensated sum is spuriously NaN from accumulating one |
| | | * or more same-signed infinite values, return the |
| | | * correctly-signed infinity stored in the simple sum. |
| | | */ |
| | | static double computeFinalSum(double[] summands) { |
| | | // Better error bounds to add both terms as the final sum |
| | | double tmp = summands[0] + summands[1]; |
| | | double simpleSum = summands[summands.length - 1]; |
| | | if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) { |
| | | return simpleSum; |
| | | } else { |
| | | return tmp; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the arithmetic mean of an integer-valued |
| | | * function applied to the input elements. If no elements are present, |
| | | * the result is 0. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a function extracting the property to be summed |
| | | * @return a {@code Collector} that produces the sum of a derived property |
| | | */ |
| | | public static <T> Collector<T, ?, Double> |
| | | averagingInt(ToIntFunction<? super T> mapper) { |
| | | return new CollectorImpl<>( |
| | | () -> new long[2], |
| | | (a, t) -> { a[0] += mapper.applyAsInt(t); a[1]++; }, |
| | | (a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; }, |
| | | a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the arithmetic mean of a long-valued |
| | | * function applied to the input elements. If no elements are present, |
| | | * the result is 0. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a function extracting the property to be summed |
| | | * @return a {@code Collector} that produces the sum of a derived property |
| | | */ |
| | | public static <T> Collector<T, ?, Double> |
| | | averagingLong(ToLongFunction<? super T> mapper) { |
| | | return new CollectorImpl<>( |
| | | () -> new long[2], |
| | | (a, t) -> { a[0] += mapper.applyAsLong(t); a[1]++; }, |
| | | (a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; }, |
| | | a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that produces the arithmetic mean of a double-valued |
| | | * function applied to the input elements. If no elements are present, |
| | | * the result is 0. |
| | | * |
| | | * <p>The average returned can vary depending upon the order in which |
| | | * values are recorded, due to accumulated rounding error in |
| | | * addition of values of differing magnitudes. Values sorted by increasing |
| | | * absolute magnitude tend to yield more accurate results. If any recorded |
| | | * value is a {@code NaN} or the sum is at any point a {@code NaN} then the |
| | | * average will be {@code NaN}. |
| | | * |
| | | * @implNote The {@code double} format can represent all |
| | | * consecutive integers in the range -2<sup>53</sup> to |
| | | * 2<sup>53</sup>. If the pipeline has more than 2<sup>53</sup> |
| | | * values, the divisor in the average computation will saturate at |
| | | * 2<sup>53</sup>, leading to additional numerical errors. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a function extracting the property to be summed |
| | | * @return a {@code Collector} that produces the sum of a derived property |
| | | */ |
| | | public static <T> Collector<T, ?, Double> |
| | | averagingDouble(ToDoubleFunction<? super T> mapper) { |
| | | /* |
| | | * In the arrays allocated for the collect operation, index 0 |
| | | * holds the high-order bits of the running sum, index 1 holds |
| | | * the low-order bits of the sum computed via compensated |
| | | * summation, and index 2 holds the number of values seen. |
| | | */ |
| | | return new CollectorImpl<>( |
| | | () -> new double[4], |
| | | (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); a[2]++; a[3]+= mapper.applyAsDouble(t);}, |
| | | (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; }, |
| | | a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]), |
| | | CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which performs a reduction of its |
| | | * input elements under a specified {@code BinaryOperator} using the |
| | | * provided identity. |
| | | * |
| | | * @apiNote |
| | | * The {@code reducing()} collectors are most useful when used in a |
| | | * multi-level reduction, downstream of {@code groupingBy} or |
| | | * {@code partitioningBy}. To perform a simple reduction on a stream, |
| | | * use {@link Stream#reduce(Object, BinaryOperator)}} instead. |
| | | * |
| | | * @param <T> element type for the input and output of the reduction |
| | | * @param identity the identity value for the reduction (also, the value |
| | | * that is returned when there are no input elements) |
| | | * @param op a {@code BinaryOperator<T>} used to reduce the input elements |
| | | * @return a {@code Collector} which implements the reduction operation |
| | | * |
| | | * @see #reducing(BinaryOperator) |
| | | * @see #reducing(Object, Function, BinaryOperator) |
| | | */ |
| | | public static <T> Collector<T, ?, T> |
| | | reducing(T identity, BinaryOperator<T> op) { |
| | | return new CollectorImpl<>( |
| | | boxSupplier(identity), |
| | | (a, t) -> { a[0] = op.apply(a[0], t); }, |
| | | (a, b) -> { a[0] = op.apply(a[0], b[0]); return a; }, |
| | | a -> a[0], |
| | | CH_NOID); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private static <T> Supplier<T[]> boxSupplier(T identity) { |
| | | return () -> (T[]) new Object[] { identity }; |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which performs a reduction of its |
| | | * input elements under a specified {@code BinaryOperator}. The result |
| | | * is described as an {@code Optional<T>}. |
| | | * |
| | | * @apiNote |
| | | * The {@code reducing()} collectors are most useful when used in a |
| | | * multi-level reduction, downstream of {@code groupingBy} or |
| | | * {@code partitioningBy}. To perform a simple reduction on a stream, |
| | | * use {@link Stream#reduce(BinaryOperator)} instead. |
| | | * |
| | | * <p>For example, given a stream of {@code Person}, to calculate tallest |
| | | * person in each city: |
| | | * <pre>{@code |
| | | * Comparator<Person> byHeight = Comparator.comparing(Person::getHeight); |
| | | * Map<City, Person> tallestByCity |
| | | * = people.stream().collect(groupingBy(Person::getCity, reducing(BinaryOperator.maxBy(byHeight)))); |
| | | * }</pre> |
| | | * |
| | | * @param <T> element type for the input and output of the reduction |
| | | * @param op a {@code BinaryOperator<T>} used to reduce the input elements |
| | | * @return a {@code Collector} which implements the reduction operation |
| | | * |
| | | * @see #reducing(Object, BinaryOperator) |
| | | * @see #reducing(Object, Function, BinaryOperator) |
| | | */ |
| | | public static <T> Collector<T, ?, Optional<T>> |
| | | reducing(BinaryOperator<T> op) { |
| | | class OptionalBox implements Consumer<T> { |
| | | T value = null; |
| | | boolean present = false; |
| | | |
| | | @Override |
| | | public void accept(T t) { |
| | | if (present) { |
| | | value = op.apply(value, t); |
| | | } |
| | | else { |
| | | value = t; |
| | | present = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return new CollectorImpl<T, OptionalBox, Optional<T>>( |
| | | OptionalBox::new, OptionalBox::accept, |
| | | (a, b) -> { if (b.present) a.accept(b.value); return a; }, |
| | | a -> Optional.ofNullable(a.value), CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which performs a reduction of its |
| | | * input elements under a specified mapping function and |
| | | * {@code BinaryOperator}. This is a generalization of |
| | | * {@link #reducing(Object, BinaryOperator)} which allows a transformation |
| | | * of the elements before reduction. |
| | | * |
| | | * @apiNote |
| | | * The {@code reducing()} collectors are most useful when used in a |
| | | * multi-level reduction, downstream of {@code groupingBy} or |
| | | * {@code partitioningBy}. To perform a simple map-reduce on a stream, |
| | | * use {@link Stream#map(Function)} and {@link Stream#reduce(Object, BinaryOperator)} |
| | | * instead. |
| | | * |
| | | * <p>For example, given a stream of {@code Person}, to calculate the longest |
| | | * last name of residents in each city: |
| | | * <pre>{@code |
| | | * Comparator<String> byLength = Comparator.comparing(String::length); |
| | | * Map<City, String> longestLastNameByCity |
| | | * = people.stream().collect(groupingBy(Person::getCity, |
| | | * reducing(Person::getLastName, BinaryOperator.maxBy(byLength)))); |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <U> the type of the mapped values |
| | | * @param identity the identity value for the reduction (also, the value |
| | | * that is returned when there are no input elements) |
| | | * @param mapper a mapping function to apply to each input value |
| | | * @param op a {@code BinaryOperator<U>} used to reduce the mapped values |
| | | * @return a {@code Collector} implementing the map-reduce operation |
| | | * |
| | | * @see #reducing(Object, BinaryOperator) |
| | | * @see #reducing(BinaryOperator) |
| | | */ |
| | | public static <T, U> |
| | | Collector<T, ?, U> reducing(U identity, |
| | | Function<? super T, ? extends U> mapper, |
| | | BinaryOperator<U> op) { |
| | | return new CollectorImpl<>( |
| | | boxSupplier(identity), |
| | | (a, t) -> { a[0] = op.apply(a[0], mapper.apply(t)); }, |
| | | (a, b) -> { a[0] = op.apply(a[0], b[0]); return a; }, |
| | | a -> a[0], CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} implementing a "group by" operation on |
| | | * input elements of type {@code T}, grouping elements according to a |
| | | * classification function, and returning the results in a {@code Map}. |
| | | * |
| | | * <p>The classification function maps elements to some key type {@code K}. |
| | | * The collector produces a {@code Map<K, List<T>>} whose keys are the |
| | | * values resulting from applying the classification function to the input |
| | | * elements, and whose corresponding values are {@code List}s containing the |
| | | * input elements which map to the associated key under the classification |
| | | * function. |
| | | * |
| | | * <p>There are no guarantees on the type, mutability, serializability, or |
| | | * thread-safety of the {@code Map} or {@code List} objects returned. |
| | | * @implSpec |
| | | * This produces a result similar to: |
| | | * <pre>{@code |
| | | * groupingBy(classifier, toList()); |
| | | * }</pre> |
| | | * |
| | | * @implNote |
| | | * The returned {@code Collector} is not concurrent. For parallel stream |
| | | * pipelines, the {@code combiner} function operates by merging the keys |
| | | * from one map into another, which can be an expensive operation. If |
| | | * preservation of the order in which elements appear in the resulting {@code Map} |
| | | * collector is not required, using {@link #groupingByConcurrent(Function)} |
| | | * may offer better parallel performance. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the type of the keys |
| | | * @param classifier the classifier function mapping input elements to keys |
| | | * @return a {@code Collector} implementing the group-by operation |
| | | * |
| | | * @see #groupingBy(Function, Collector) |
| | | * @see #groupingBy(Function, Supplier, Collector) |
| | | * @see #groupingByConcurrent(Function) |
| | | */ |
| | | public static <T, K> Collector<T, ?, Map<K, List<T>>> |
| | | groupingBy(Function<? super T, ? extends K> classifier) { |
| | | return groupingBy(classifier, toList()); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} implementing a cascaded "group by" operation |
| | | * on input elements of type {@code T}, grouping elements according to a |
| | | * classification function, and then performing a reduction operation on |
| | | * the values associated with a given key using the specified downstream |
| | | * {@code Collector}. |
| | | * |
| | | * <p>The classification function maps elements to some key type {@code K}. |
| | | * The downstream collector operates on elements of type {@code T} and |
| | | * produces a result of type {@code D}. The resulting collector produces a |
| | | * {@code Map<K, D>}. |
| | | * |
| | | * <p>There are no guarantees on the type, mutability, |
| | | * serializability, or thread-safety of the {@code Map} returned. |
| | | * |
| | | * <p>For example, to compute the set of last names of people in each city: |
| | | * <pre>{@code |
| | | * Map<City, Set<String>> namesByCity |
| | | * = people.stream().collect(groupingBy(Person::getCity, |
| | | * mapping(Person::getLastName, toSet()))); |
| | | * }</pre> |
| | | * |
| | | * @implNote |
| | | * The returned {@code Collector} is not concurrent. For parallel stream |
| | | * pipelines, the {@code combiner} function operates by merging the keys |
| | | * from one map into another, which can be an expensive operation. If |
| | | * preservation of the order in which elements are presented to the downstream |
| | | * collector is not required, using {@link #groupingByConcurrent(Function, Collector)} |
| | | * may offer better parallel performance. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the type of the keys |
| | | * @param <A> the intermediate accumulation type of the downstream collector |
| | | * @param <D> the result type of the downstream reduction |
| | | * @param classifier a classifier function mapping input elements to keys |
| | | * @param downstream a {@code Collector} implementing the downstream reduction |
| | | * @return a {@code Collector} implementing the cascaded group-by operation |
| | | * @see #groupingBy(Function) |
| | | * |
| | | * @see #groupingBy(Function, Supplier, Collector) |
| | | * @see #groupingByConcurrent(Function, Collector) |
| | | */ |
| | | public static <T, K, A, D> |
| | | Collector<T, ?, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier, |
| | | Collector<? super T, A, D> downstream) { |
| | | return groupingBy(classifier, HashMap::new, downstream); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} implementing a cascaded "group by" operation |
| | | * on input elements of type {@code T}, grouping elements according to a |
| | | * classification function, and then performing a reduction operation on |
| | | * the values associated with a given key using the specified downstream |
| | | * {@code Collector}. The {@code Map} produced by the Collector is created |
| | | * with the supplied factory function. |
| | | * |
| | | * <p>The classification function maps elements to some key type {@code K}. |
| | | * The downstream collector operates on elements of type {@code T} and |
| | | * produces a result of type {@code D}. The resulting collector produces a |
| | | * {@code Map<K, D>}. |
| | | * |
| | | * <p>For example, to compute the set of last names of people in each city, |
| | | * where the city names are sorted: |
| | | * <pre>{@code |
| | | * Map<City, Set<String>> namesByCity |
| | | * = people.stream().collect(groupingBy(Person::getCity, TreeMap::new, |
| | | * mapping(Person::getLastName, toSet()))); |
| | | * }</pre> |
| | | * |
| | | * @implNote |
| | | * The returned {@code Collector} is not concurrent. For parallel stream |
| | | * pipelines, the {@code combiner} function operates by merging the keys |
| | | * from one map into another, which can be an expensive operation. If |
| | | * preservation of the order in which elements are presented to the downstream |
| | | * collector is not required, using {@link #groupingByConcurrent(Function, Supplier, Collector)} |
| | | * may offer better parallel performance. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the type of the keys |
| | | * @param <A> the intermediate accumulation type of the downstream collector |
| | | * @param <D> the result type of the downstream reduction |
| | | * @param <M> the type of the resulting {@code Map} |
| | | * @param classifier a classifier function mapping input elements to keys |
| | | * @param downstream a {@code Collector} implementing the downstream reduction |
| | | * @param mapFactory a function which, when called, produces a new empty |
| | | * {@code Map} of the desired type |
| | | * @return a {@code Collector} implementing the cascaded group-by operation |
| | | * |
| | | * @see #groupingBy(Function, Collector) |
| | | * @see #groupingBy(Function) |
| | | * @see #groupingByConcurrent(Function, Supplier, Collector) |
| | | */ |
| | | public static <T, K, D, A, M extends Map<K, D>> |
| | | Collector<T, ?, M> groupingBy(Function<? super T, ? extends K> classifier, |
| | | Supplier<M> mapFactory, |
| | | Collector<? super T, A, D> downstream) { |
| | | Supplier<A> downstreamSupplier = downstream.supplier(); |
| | | BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); |
| | | BiConsumer<Map<K, A>, T> accumulator = (m, t) -> { |
| | | K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); |
| | | A container = m.computeIfAbsent(key, k -> downstreamSupplier.get()); |
| | | downstreamAccumulator.accept(container, t); |
| | | }; |
| | | BinaryOperator<Map<K, A>> merger = CollectorsPlus.<K, A, Map<K, A>>mapMerger(downstream.combiner()); |
| | | @SuppressWarnings("unchecked") |
| | | Supplier<Map<K, A>> mangledFactory = (Supplier<Map<K, A>>) mapFactory; |
| | | |
| | | if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { |
| | | return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_ID); |
| | | } |
| | | else { |
| | | @SuppressWarnings("unchecked") |
| | | Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher(); |
| | | Function<Map<K, A>, M> finisher = intermediate -> { |
| | | intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); |
| | | @SuppressWarnings("unchecked") |
| | | M castResult = (M) intermediate; |
| | | return castResult; |
| | | }; |
| | | return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_NOID); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a concurrent {@code Collector} implementing a "group by" |
| | | * operation on input elements of type {@code T}, grouping elements |
| | | * according to a classification function. |
| | | * |
| | | * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and |
| | | * {@link Collector.Characteristics#UNORDERED unordered} Collector. |
| | | * |
| | | * <p>The classification function maps elements to some key type {@code K}. |
| | | * The collector produces a {@code ConcurrentMap<K, List<T>>} whose keys are the |
| | | * values resulting from applying the classification function to the input |
| | | * elements, and whose corresponding values are {@code List}s containing the |
| | | * input elements which map to the associated key under the classification |
| | | * function. |
| | | * |
| | | * <p>There are no guarantees on the type, mutability, or serializability |
| | | * of the {@code Map} or {@code List} objects returned, or of the |
| | | * thread-safety of the {@code List} objects returned. |
| | | * @implSpec |
| | | * This produces a result similar to: |
| | | * <pre>{@code |
| | | * groupingByConcurrent(classifier, toList()); |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the type of the keys |
| | | * @param classifier a classifier function mapping input elements to keys |
| | | * @return a concurrent, unordered {@code Collector} implementing the group-by operation |
| | | * |
| | | * @see #groupingBy(Function) |
| | | * @see #groupingByConcurrent(Function, Collector) |
| | | * @see #groupingByConcurrent(Function, Supplier, Collector) |
| | | */ |
| | | public static <T, K> |
| | | Collector<T, ?, ConcurrentMap<K, List<T>>> |
| | | groupingByConcurrent(Function<? super T, ? extends K> classifier) { |
| | | return groupingByConcurrent(classifier, ConcurrentHashMap::new, toList()); |
| | | } |
| | | |
| | | /** |
| | | * Returns a concurrent {@code Collector} implementing a cascaded "group by" |
| | | * operation on input elements of type {@code T}, grouping elements |
| | | * according to a classification function, and then performing a reduction |
| | | * operation on the values associated with a given key using the specified |
| | | * downstream {@code Collector}. |
| | | * |
| | | * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and |
| | | * {@link Collector.Characteristics#UNORDERED unordered} Collector. |
| | | * |
| | | * <p>The classification function maps elements to some key type {@code K}. |
| | | * The downstream collector operates on elements of type {@code T} and |
| | | * produces a result of type {@code D}. The resulting collector produces a |
| | | * {@code Map<K, D>}. |
| | | * |
| | | * <p>For example, to compute the set of last names of people in each city, |
| | | * where the city names are sorted: |
| | | * <pre>{@code |
| | | * ConcurrentMap<City, Set<String>> namesByCity |
| | | * = people.stream().collect(groupingByConcurrent(Person::getCity, |
| | | * mapping(Person::getLastName, toSet()))); |
| | | * }</pre> |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the type of the keys |
| | | * @param <A> the intermediate accumulation type of the downstream collector |
| | | * @param <D> the result type of the downstream reduction |
| | | * @param classifier a classifier function mapping input elements to keys |
| | | * @param downstream a {@code Collector} implementing the downstream reduction |
| | | * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation |
| | | * |
| | | * @see #groupingBy(Function, Collector) |
| | | * @see #groupingByConcurrent(Function) |
| | | * @see #groupingByConcurrent(Function, Supplier, Collector) |
| | | */ |
| | | public static <T, K, A, D> |
| | | Collector<T, ?, ConcurrentMap<K, D>> groupingByConcurrent(Function<? super T, ? extends K> classifier, |
| | | Collector<? super T, A, D> downstream) { |
| | | return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream); |
| | | } |
| | | |
| | | /** |
| | | * Returns a concurrent {@code Collector} implementing a cascaded "group by" |
| | | * operation on input elements of type {@code T}, grouping elements |
| | | * according to a classification function, and then performing a reduction |
| | | * operation on the values associated with a given key using the specified |
| | | * downstream {@code Collector}. The {@code ConcurrentMap} produced by the |
| | | * Collector is created with the supplied factory function. |
| | | * |
| | | * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and |
| | | * {@link Collector.Characteristics#UNORDERED unordered} Collector. |
| | | * |
| | | * <p>The classification function maps elements to some key type {@code K}. |
| | | * The downstream collector operates on elements of type {@code T} and |
| | | * produces a result of type {@code D}. The resulting collector produces a |
| | | * {@code Map<K, D>}. |
| | | * |
| | | * <p>For example, to compute the set of last names of people in each city, |
| | | * where the city names are sorted: |
| | | * <pre>{@code |
| | | * ConcurrentMap<City, Set<String>> namesByCity |
| | | * = people.stream().collect(groupingBy(Person::getCity, ConcurrentSkipListMap::new, |
| | | * mapping(Person::getLastName, toSet()))); |
| | | * }</pre> |
| | | * |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the type of the keys |
| | | * @param <A> the intermediate accumulation type of the downstream collector |
| | | * @param <D> the result type of the downstream reduction |
| | | * @param <M> the type of the resulting {@code ConcurrentMap} |
| | | * @param classifier a classifier function mapping input elements to keys |
| | | * @param downstream a {@code Collector} implementing the downstream reduction |
| | | * @param mapFactory a function which, when called, produces a new empty |
| | | * {@code ConcurrentMap} of the desired type |
| | | * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation |
| | | * |
| | | * @see #groupingByConcurrent(Function) |
| | | * @see #groupingByConcurrent(Function, Collector) |
| | | * @see #groupingBy(Function, Supplier, Collector) |
| | | */ |
| | | public static <T, K, A, D, M extends ConcurrentMap<K, D>> |
| | | Collector<T, ?, M> groupingByConcurrent(Function<? super T, ? extends K> classifier, |
| | | Supplier<M> mapFactory, |
| | | Collector<? super T, A, D> downstream) { |
| | | Supplier<A> downstreamSupplier = downstream.supplier(); |
| | | BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); |
| | | BinaryOperator<ConcurrentMap<K, A>> merger = CollectorsPlus.<K, A, ConcurrentMap<K, A>>mapMerger(downstream.combiner()); |
| | | @SuppressWarnings("unchecked") |
| | | Supplier<ConcurrentMap<K, A>> mangledFactory = (Supplier<ConcurrentMap<K, A>>) mapFactory; |
| | | BiConsumer<ConcurrentMap<K, A>, T> accumulator; |
| | | if (downstream.characteristics().contains(Collector.Characteristics.CONCURRENT)) { |
| | | accumulator = (m, t) -> { |
| | | K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); |
| | | A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get()); |
| | | downstreamAccumulator.accept(resultContainer, t); |
| | | }; |
| | | } |
| | | else { |
| | | accumulator = (m, t) -> { |
| | | K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key"); |
| | | A resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get()); |
| | | synchronized (resultContainer) { |
| | | downstreamAccumulator.accept(resultContainer, t); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { |
| | | return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_CONCURRENT_ID); |
| | | } |
| | | else { |
| | | @SuppressWarnings("unchecked") |
| | | Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher(); |
| | | Function<ConcurrentMap<K, A>, M> finisher = intermediate -> { |
| | | intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v)); |
| | | @SuppressWarnings("unchecked") |
| | | M castResult = (M) intermediate; |
| | | return castResult; |
| | | }; |
| | | return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_CONCURRENT_NOID); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which partitions the input elements according |
| | | * to a {@code Predicate}, and organizes them into a |
| | | * {@code Map<Boolean, List<T>>}. |
| | | * |
| | | * There are no guarantees on the type, mutability, |
| | | * serializability, or thread-safety of the {@code Map} returned. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param predicate a predicate used for classifying input elements |
| | | * @return a {@code Collector} implementing the partitioning operation |
| | | * |
| | | * @see #partitioningBy(Predicate, Collector) |
| | | */ |
| | | public static <T> |
| | | Collector<T, ?, Map<Boolean, List<T>>> partitioningBy(Predicate<? super T> predicate) { |
| | | return partitioningBy(predicate, toList()); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which partitions the input elements according |
| | | * to a {@code Predicate}, reduces the values in each partition according to |
| | | * another {@code Collector}, and organizes them into a |
| | | * {@code Map<Boolean, D>} whose values are the result of the downstream |
| | | * reduction. |
| | | * |
| | | * <p>There are no guarantees on the type, mutability, |
| | | * serializability, or thread-safety of the {@code Map} returned. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <A> the intermediate accumulation type of the downstream collector |
| | | * @param <D> the result type of the downstream reduction |
| | | * @param predicate a predicate used for classifying input elements |
| | | * @param downstream a {@code Collector} implementing the downstream |
| | | * reduction |
| | | * @return a {@code Collector} implementing the cascaded partitioning |
| | | * operation |
| | | * |
| | | * @see #partitioningBy(Predicate) |
| | | */ |
| | | public static <T, D, A> |
| | | Collector<T, ?, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate, |
| | | Collector<? super T, A, D> downstream) { |
| | | BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator(); |
| | | BiConsumer<Partition<A>, T> accumulator = (result, t) -> |
| | | downstreamAccumulator.accept(predicate.test(t) ? result.forTrue : result.forFalse, t); |
| | | BinaryOperator<A> op = downstream.combiner(); |
| | | BinaryOperator<Partition<A>> merger = (left, right) -> |
| | | new Partition<>(op.apply(left.forTrue, right.forTrue), |
| | | op.apply(left.forFalse, right.forFalse)); |
| | | Supplier<Partition<A>> supplier = () -> |
| | | new Partition<>(downstream.supplier().get(), |
| | | downstream.supplier().get()); |
| | | if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { |
| | | return new CollectorImpl<>(supplier, accumulator, merger, CH_ID); |
| | | } |
| | | else { |
| | | Function<Partition<A>, Map<Boolean, D>> finisher = par -> |
| | | new Partition<>(downstream.finisher().apply(par.forTrue), |
| | | downstream.finisher().apply(par.forFalse)); |
| | | return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that accumulates elements into a |
| | | * {@code Map} whose keys and values are the result of applying the provided |
| | | * mapping functions to the input elements. |
| | | * |
| | | * <p>If the mapped keys contains duplicates (according to |
| | | * {@link Object#equals(Object)}), an {@code IllegalStateException} is |
| | | * thrown when the collection operation is performed. If the mapped keys |
| | | * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)} |
| | | * instead. |
| | | * |
| | | * @apiNote |
| | | * It is common for either the key or the value to be the input elements. |
| | | * In this case, the utility method |
| | | * {@link Function#identity()} may be helpful. |
| | | * For example, the following produces a {@code Map} mapping |
| | | * students to their grade point average: |
| | | * <pre>{@code |
| | | * Map<Student, Double> studentToGPA |
| | | * students.stream().collect(toMap(Functions.identity(), |
| | | * student -> computeGPA(student))); |
| | | * }</pre> |
| | | * And the following produces a {@code Map} mapping a unique identifier to |
| | | * students: |
| | | * <pre>{@code |
| | | * Map<String, Student> studentIdToStudent |
| | | * students.stream().collect(toMap(Student::getId, |
| | | * Functions.identity()); |
| | | * }</pre> |
| | | * |
| | | * @implNote |
| | | * The returned {@code Collector} is not concurrent. For parallel stream |
| | | * pipelines, the {@code combiner} function operates by merging the keys |
| | | * from one map into another, which can be an expensive operation. If it is |
| | | * not required that results are inserted into the {@code Map} in encounter |
| | | * order, using {@link #toConcurrentMap(Function, Function)} |
| | | * may offer better parallel performance. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the output type of the key mapping function |
| | | * @param <U> the output type of the value mapping function |
| | | * @param keyMapper a mapping function to produce keys |
| | | * @param valueMapper a mapping function to produce values |
| | | * @return a {@code Collector} which collects elements into a {@code Map} |
| | | * whose keys and values are the result of applying mapping functions to |
| | | * the input elements |
| | | * |
| | | * @see #toMap(Function, Function, BinaryOperator) |
| | | * @see #toMap(Function, Function, BinaryOperator, Supplier) |
| | | * @see #toConcurrentMap(Function, Function) |
| | | */ |
| | | public static <T, K, U> |
| | | Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper, |
| | | Function<? super T, ? extends U> valueMapper) { |
| | | return toMap(keyMapper, valueMapper, throwingMerger(), HashMap::new); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that accumulates elements into a |
| | | * {@code Map} whose keys and values are the result of applying the provided |
| | | * mapping functions to the input elements. |
| | | * |
| | | * <p>If the mapped |
| | | * keys contains duplicates (according to {@link Object#equals(Object)}), |
| | | * the value mapping function is applied to each equal element, and the |
| | | * results are merged using the provided merging function. |
| | | * |
| | | * @apiNote |
| | | * There are multiple ways to deal with collisions between multiple elements |
| | | * mapping to the same key. The other forms of {@code toMap} simply use |
| | | * a merge function that throws unconditionally, but you can easily write |
| | | * more flexible merge policies. For example, if you have a stream |
| | | * of {@code Person}, and you want to produce a "phone book" mapping name to |
| | | * address, but it is possible that two persons have the same name, you can |
| | | * do as follows to gracefully deals with these collisions, and produce a |
| | | * {@code Map} mapping names to a concatenated list of addresses: |
| | | * <pre>{@code |
| | | * Map<String, String> phoneBook |
| | | * people.stream().collect(toMap(Person::getName, |
| | | * Person::getAddress, |
| | | * (s, a) -> s + ", " + a)); |
| | | * }</pre> |
| | | * |
| | | * @implNote |
| | | * The returned {@code Collector} is not concurrent. For parallel stream |
| | | * pipelines, the {@code combiner} function operates by merging the keys |
| | | * from one map into another, which can be an expensive operation. If it is |
| | | * not required that results are merged into the {@code Map} in encounter |
| | | * order, using {@link #toConcurrentMap(Function, Function, BinaryOperator)} |
| | | * may offer better parallel performance. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the output type of the key mapping function |
| | | * @param <U> the output type of the value mapping function |
| | | * @param keyMapper a mapping function to produce keys |
| | | * @param valueMapper a mapping function to produce values |
| | | * @param mergeFunction a merge function, used to resolve collisions between |
| | | * values associated with the same key, as supplied |
| | | * to {@link Map#merge(Object, Object, BiFunction)} |
| | | * @return a {@code Collector} which collects elements into a {@code Map} |
| | | * whose keys are the result of applying a key mapping function to the input |
| | | * elements, and whose values are the result of applying a value mapping |
| | | * function to all input elements equal to the key and combining them |
| | | * using the merge function |
| | | * |
| | | * @see #toMap(Function, Function) |
| | | * @see #toMap(Function, Function, BinaryOperator, Supplier) |
| | | * @see #toConcurrentMap(Function, Function, BinaryOperator) |
| | | */ |
| | | public static <T, K, U> |
| | | Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper, |
| | | Function<? super T, ? extends U> valueMapper, |
| | | BinaryOperator<U> mergeFunction) { |
| | | return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} that accumulates elements into a |
| | | * {@code Map} whose keys and values are the result of applying the provided |
| | | * mapping functions to the input elements. |
| | | * |
| | | * <p>If the mapped |
| | | * keys contains duplicates (according to {@link Object#equals(Object)}), |
| | | * the value mapping function is applied to each equal element, and the |
| | | * results are merged using the provided merging function. The {@code Map} |
| | | * is created by a provided supplier function. |
| | | * |
| | | * @implNote |
| | | * The returned {@code Collector} is not concurrent. For parallel stream |
| | | * pipelines, the {@code combiner} function operates by merging the keys |
| | | * from one map into another, which can be an expensive operation. If it is |
| | | * not required that results are merged into the {@code Map} in encounter |
| | | * order, using {@link #toConcurrentMap(Function, Function, BinaryOperator, Supplier)} |
| | | * may offer better parallel performance. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the output type of the key mapping function |
| | | * @param <U> the output type of the value mapping function |
| | | * @param <M> the type of the resulting {@code Map} |
| | | * @param keyMapper a mapping function to produce keys |
| | | * @param valueMapper a mapping function to produce values |
| | | * @param mergeFunction a merge function, used to resolve collisions between |
| | | * values associated with the same key, as supplied |
| | | * to {@link Map#merge(Object, Object, BiFunction)} |
| | | * @param mapSupplier a function which returns a new, empty {@code Map} into |
| | | * which the results will be inserted |
| | | * @return a {@code Collector} which collects elements into a {@code Map} |
| | | * whose keys are the result of applying a key mapping function to the input |
| | | * elements, and whose values are the result of applying a value mapping |
| | | * function to all input elements equal to the key and combining them |
| | | * using the merge function |
| | | * |
| | | * @see #toMap(Function, Function) |
| | | * @see #toMap(Function, Function, BinaryOperator) |
| | | * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) |
| | | */ |
| | | public static <T, K, U, M extends Map<K, U>> |
| | | Collector<T, ?, M> toMap(Function<? super T, ? extends K> keyMapper, |
| | | Function<? super T, ? extends U> valueMapper, |
| | | BinaryOperator<U> mergeFunction, |
| | | Supplier<M> mapSupplier) { |
| | | BiConsumer<M, T> accumulator |
| | | = (map, element) -> map.merge(keyMapper.apply(element), |
| | | valueMapper.apply(element), mergeFunction); |
| | | return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a concurrent {@code Collector} that accumulates elements into a |
| | | * {@code ConcurrentMap} whose keys and values are the result of applying |
| | | * the provided mapping functions to the input elements. |
| | | * |
| | | * <p>If the mapped keys contains duplicates (according to |
| | | * {@link Object#equals(Object)}), an {@code IllegalStateException} is |
| | | * thrown when the collection operation is performed. If the mapped keys |
| | | * may have duplicates, use |
| | | * {@link #toConcurrentMap(Function, Function, BinaryOperator)} instead. |
| | | * |
| | | * @apiNote |
| | | * It is common for either the key or the value to be the input elements. |
| | | * In this case, the utility method |
| | | * {@link Function#identity()} may be helpful. |
| | | * For example, the following produces a {@code Map} mapping |
| | | * students to their grade point average: |
| | | * <pre>{@code |
| | | * Map<Student, Double> studentToGPA |
| | | * students.stream().collect(toMap(Functions.identity(), |
| | | * student -> computeGPA(student))); |
| | | * }</pre> |
| | | * And the following produces a {@code Map} mapping a unique identifier to |
| | | * students: |
| | | * <pre>{@code |
| | | * Map<String, Student> studentIdToStudent |
| | | * students.stream().collect(toConcurrentMap(Student::getId, |
| | | * Functions.identity()); |
| | | * }</pre> |
| | | * |
| | | * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and |
| | | * {@link Collector.Characteristics#UNORDERED unordered} Collector. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the output type of the key mapping function |
| | | * @param <U> the output type of the value mapping function |
| | | * @param keyMapper the mapping function to produce keys |
| | | * @param valueMapper the mapping function to produce values |
| | | * @return a concurrent, unordered {@code Collector} which collects elements into a |
| | | * {@code ConcurrentMap} whose keys are the result of applying a key mapping |
| | | * function to the input elements, and whose values are the result of |
| | | * applying a value mapping function to the input elements |
| | | * |
| | | * @see #toMap(Function, Function) |
| | | * @see #toConcurrentMap(Function, Function, BinaryOperator) |
| | | * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) |
| | | */ |
| | | public static <T, K, U> |
| | | Collector<T, ?, ConcurrentMap<K,U>> toConcurrentMap(Function<? super T, ? extends K> keyMapper, |
| | | Function<? super T, ? extends U> valueMapper) { |
| | | return toConcurrentMap(keyMapper, valueMapper, throwingMerger(), ConcurrentHashMap::new); |
| | | } |
| | | |
| | | /** |
| | | * Returns a concurrent {@code Collector} that accumulates elements into a |
| | | * {@code ConcurrentMap} whose keys and values are the result of applying |
| | | * the provided mapping functions to the input elements. |
| | | * |
| | | * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), |
| | | * the value mapping function is applied to each equal element, and the |
| | | * results are merged using the provided merging function. |
| | | * |
| | | * @apiNote |
| | | * There are multiple ways to deal with collisions between multiple elements |
| | | * mapping to the same key. The other forms of {@code toConcurrentMap} simply use |
| | | * a merge function that throws unconditionally, but you can easily write |
| | | * more flexible merge policies. For example, if you have a stream |
| | | * of {@code Person}, and you want to produce a "phone book" mapping name to |
| | | * address, but it is possible that two persons have the same name, you can |
| | | * do as follows to gracefully deals with these collisions, and produce a |
| | | * {@code Map} mapping names to a concatenated list of addresses: |
| | | * <pre>{@code |
| | | * Map<String, String> phoneBook |
| | | * people.stream().collect(toConcurrentMap(Person::getName, |
| | | * Person::getAddress, |
| | | * (s, a) -> s + ", " + a)); |
| | | * }</pre> |
| | | * |
| | | * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and |
| | | * {@link Collector.Characteristics#UNORDERED unordered} Collector. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the output type of the key mapping function |
| | | * @param <U> the output type of the value mapping function |
| | | * @param keyMapper a mapping function to produce keys |
| | | * @param valueMapper a mapping function to produce values |
| | | * @param mergeFunction a merge function, used to resolve collisions between |
| | | * values associated with the same key, as supplied |
| | | * to {@link Map#merge(Object, Object, BiFunction)} |
| | | * @return a concurrent, unordered {@code Collector} which collects elements into a |
| | | * {@code ConcurrentMap} whose keys are the result of applying a key mapping |
| | | * function to the input elements, and whose values are the result of |
| | | * applying a value mapping function to all input elements equal to the key |
| | | * and combining them using the merge function |
| | | * |
| | | * @see #toConcurrentMap(Function, Function) |
| | | * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier) |
| | | * @see #toMap(Function, Function, BinaryOperator) |
| | | */ |
| | | public static <T, K, U> |
| | | Collector<T, ?, ConcurrentMap<K,U>> |
| | | toConcurrentMap(Function<? super T, ? extends K> keyMapper, |
| | | Function<? super T, ? extends U> valueMapper, |
| | | BinaryOperator<U> mergeFunction) { |
| | | return toConcurrentMap(keyMapper, valueMapper, mergeFunction, ConcurrentHashMap::new); |
| | | } |
| | | |
| | | /** |
| | | * Returns a concurrent {@code Collector} that accumulates elements into a |
| | | * {@code ConcurrentMap} whose keys and values are the result of applying |
| | | * the provided mapping functions to the input elements. |
| | | * |
| | | * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), |
| | | * the value mapping function is applied to each equal element, and the |
| | | * results are merged using the provided merging function. The |
| | | * {@code ConcurrentMap} is created by a provided supplier function. |
| | | * |
| | | * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and |
| | | * {@link Collector.Characteristics#UNORDERED unordered} Collector. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param <K> the output type of the key mapping function |
| | | * @param <U> the output type of the value mapping function |
| | | * @param <M> the type of the resulting {@code ConcurrentMap} |
| | | * @param keyMapper a mapping function to produce keys |
| | | * @param valueMapper a mapping function to produce values |
| | | * @param mergeFunction a merge function, used to resolve collisions between |
| | | * values associated with the same key, as supplied |
| | | * to {@link Map#merge(Object, Object, BiFunction)} |
| | | * @param mapSupplier a function which returns a new, empty {@code Map} into |
| | | * which the results will be inserted |
| | | * @return a concurrent, unordered {@code Collector} which collects elements into a |
| | | * {@code ConcurrentMap} whose keys are the result of applying a key mapping |
| | | * function to the input elements, and whose values are the result of |
| | | * applying a value mapping function to all input elements equal to the key |
| | | * and combining them using the merge function |
| | | * |
| | | * @see #toConcurrentMap(Function, Function) |
| | | * @see #toConcurrentMap(Function, Function, BinaryOperator) |
| | | * @see #toMap(Function, Function, BinaryOperator, Supplier) |
| | | */ |
| | | public static <T, K, U, M extends ConcurrentMap<K, U>> |
| | | Collector<T, ?, M> toConcurrentMap(Function<? super T, ? extends K> keyMapper, |
| | | Function<? super T, ? extends U> valueMapper, |
| | | BinaryOperator<U> mergeFunction, |
| | | Supplier<M> mapSupplier) { |
| | | BiConsumer<M, T> accumulator |
| | | = (map, element) -> map.merge(keyMapper.apply(element), |
| | | valueMapper.apply(element), mergeFunction); |
| | | return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_CONCURRENT_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which applies an {@code int}-producing |
| | | * mapping function to each input element, and returns summary statistics |
| | | * for the resulting values. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a mapping function to apply to each element |
| | | * @return a {@code Collector} implementing the summary-statistics reduction |
| | | * |
| | | * @see #summarizingDouble(ToDoubleFunction) |
| | | * @see #summarizingLong(ToLongFunction) |
| | | */ |
| | | public static <T> |
| | | Collector<T, ?, IntSummaryStatistics> summarizingInt(ToIntFunction<? super T> mapper) { |
| | | return new CollectorImpl<T, IntSummaryStatistics, IntSummaryStatistics>( |
| | | IntSummaryStatistics::new, |
| | | (r, t) -> r.accept(mapper.applyAsInt(t)), |
| | | (l, r) -> { l.combine(r); return l; }, CH_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which applies an {@code long}-producing |
| | | * mapping function to each input element, and returns summary statistics |
| | | * for the resulting values. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper the mapping function to apply to each element |
| | | * @return a {@code Collector} implementing the summary-statistics reduction |
| | | * |
| | | * @see #summarizingDouble(ToDoubleFunction) |
| | | * @see #summarizingInt(ToIntFunction) |
| | | */ |
| | | public static <T> |
| | | Collector<T, ?, LongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) { |
| | | return new CollectorImpl<T, LongSummaryStatistics, LongSummaryStatistics>( |
| | | LongSummaryStatistics::new, |
| | | (r, t) -> r.accept(mapper.applyAsLong(t)), |
| | | (l, r) -> { l.combine(r); return l; }, CH_ID); |
| | | } |
| | | |
| | | /** |
| | | * Returns a {@code Collector} which applies an {@code double}-producing |
| | | * mapping function to each input element, and returns summary statistics |
| | | * for the resulting values. |
| | | * |
| | | * @param <T> the type of the input elements |
| | | * @param mapper a mapping function to apply to each element |
| | | * @return a {@code Collector} implementing the summary-statistics reduction |
| | | * |
| | | * @see #summarizingLong(ToLongFunction) |
| | | * @see #summarizingInt(ToIntFunction) |
| | | */ |
| | | public static <T> |
| | | Collector<T, ?, DoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) { |
| | | return new CollectorImpl<T, DoubleSummaryStatistics, DoubleSummaryStatistics>( |
| | | DoubleSummaryStatistics::new, |
| | | (r, t) -> r.accept(mapper.applyAsDouble(t)), |
| | | (l, r) -> { l.combine(r); return l; }, CH_ID); |
| | | } |
| | | |
| | | /** |
| | | * BigDecimal求和 |
| | | * @Author lin.liu |
| | | * @Description BigDecimal求和 |
| | | * @Date 2021/8/26 |
| | | * @Param [mapper] |
| | | * @return java.util.stream.Collector<T,?,java.math.BigDecimal> |
| | | **/ |
| | | public static <T> Collector<T, ?, BigDecimal> summingBigDecimal(ToBigDecimalFunction<? super T> mapper) { |
| | | return new CollectorImpl<>(() -> new BigDecimal[1], (a, t) -> { |
| | | if (a[0] == null) { |
| | | a[0] = BigDecimal.ZERO; |
| | | } |
| | | a[0] = a[0].add(mapper.applyAsBigDecimal(t)); |
| | | }, (a, b) -> { |
| | | a[0] = a[0].add(b[0]); |
| | | return a; |
| | | }, a -> a[0], CH_NOID); |
| | | } |
| | | |
| | | /** |
| | | * Implementation class used by partitioningBy. |
| | | */ |
| | | private static final class Partition<T> |
| | | extends AbstractMap<Boolean, T> |
| | | implements Map<Boolean, T> { |
| | | final T forTrue; |
| | | final T forFalse; |
| | | |
| | | Partition(T forTrue, T forFalse) { |
| | | this.forTrue = forTrue; |
| | | this.forFalse = forFalse; |
| | | } |
| | | |
| | | @Override |
| | | public Set<Entry<Boolean, T>> entrySet() { |
| | | return new AbstractSet<Entry<Boolean, T>>() { |
| | | @Override |
| | | public Iterator<Entry<Boolean, T>> iterator() { |
| | | Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); |
| | | Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); |
| | | return Arrays.asList(falseEntry, trueEntry).iterator(); |
| | | } |
| | | |
| | | @Override |
| | | public int size() { |
| | | return 2; |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.jackson; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; |
| | | import com.fasterxml.jackson.databind.ser.std.NumberSerializer; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | @JacksonStdImpl |
| | | public class BigNumberSerializer extends NumberSerializer { |
| | | /** |
| | | * 根据JS NUmber.MAX SAFE INTEGER与NUmber.MIN SAFE INTEGER 得来 |
| | | */ |
| | | private static final long MAX_SAFE_INTEGER = 9007199254740991L; |
| | | private static final long MIN_SAFE_INTEGER = -9007199254740991L; |
| | | |
| | | /** |
| | | * 提供实例 |
| | | */ |
| | | public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class); |
| | | |
| | | public BigNumberSerializer(Class<? extends Number> rawType) { |
| | | super(rawType); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | |
| | | public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException { |
| | | //超出范围 序列化位字符串 |
| | | if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER){ |
| | | super.serialize(value, gen, provider); |
| | | } else{ |
| | | gen.writeString(value.toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.jackson; |
| | | |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
| | | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; |
| | | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; |
| | | import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.TimeZone; |
| | | |
| | | @Configuration |
| | | public class JacksonConfig { |
| | | /** |
| | | * jackson 配置 |
| | | * @return |
| | | */ |
| | | @Bean |
| | | public Jackson2ObjectMapperBuilderCustomizer customizer() { |
| | | return builder -> { |
| | | //全局配置序列化返回 JSON 处理 |
| | | JavaTimeModule javaTimeModule = new JavaTimeModule(); |
| | | javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE); |
| | | javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE); |
| | | javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE); |
| | | javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH : mm: ss"); |
| | | javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter)); |
| | | javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter)); |
| | | builder.modules(javaTimeModule); |
| | | builder.timeZone(TimeZone.getDefault()); |
| | | System.out.println("初始化 jackson 配置"); |
| | | }; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.jwt; |
| | | |
| | | import com.auth0.jwt.JWT; |
| | | import com.auth0.jwt.JWTCreator; |
| | | import com.auth0.jwt.JWTVerifier; |
| | | import com.auth0.jwt.algorithms.Algorithm; |
| | | import com.auth0.jwt.exceptions.TokenExpiredException; |
| | | import com.auth0.jwt.interfaces.DecodedJWT; |
| | | import com.fengdu.gas.common.config.SysConfig; |
| | | import com.fengdu.gas.common.enums.EResultCode; |
| | | import com.fengdu.gas.common.exceptions.BusinessException; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | public class JWTUtil { |
| | | /** |
| | | * @return token中包含的用户名 |
| | | */ |
| | | public static LoginUserDTO getUser(String token) { |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | throw new BusinessException(EResultCode.UNAUTHORIZED, "尚未登录"); |
| | | } |
| | | JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SysConfig.jwt.getSecret())) |
| | | .build(); |
| | | DecodedJWT jwt = null; |
| | | try { |
| | | |
| | | jwt = verifier.verify(token); |
| | | } catch (TokenExpiredException e) { |
| | | throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); |
| | | } catch (Exception e) { |
| | | throw new BusinessException(EResultCode.UNAUTHORIZED, "token格式不正确." + token); |
| | | } |
| | | if (null == jwt) { |
| | | throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); |
| | | } |
| | | Date expiresAt = jwt.getExpiresAt(); |
| | | |
| | | LocalDateTime dtExpires = LocalDateTimeUtil.getDateTime(expiresAt.getTime()); |
| | | if (dtExpires.isBefore(LocalDateTimeUtil.nowDateTime())) { |
| | | throw new BusinessException(EResultCode.UNAUTHORIZED, "token已过期"); |
| | | } |
| | | LoginUserDTO loginUser = new LoginUserDTO(); |
| | | loginUser.setUserId(jwt.getClaim("userId").asString()); |
| | | loginUser.setUserType(NumericUtil.tryParseInt(jwt.getClaim("userType").asString(), 0)); |
| | | loginUser.setPhone(jwt.getClaim("phone").asString()); |
| | | loginUser.setPhone(jwt.getClaim("phone").asString()); |
| | | loginUser.setNickName(jwt.getClaim("nickName").asString()); |
| | | loginUser.setHeadImg(jwt.getClaim("headImg").asString()); |
| | | loginUser.setListRole(StringUtil.splitLongList(jwt.getClaim("listRole").asString())); |
| | | loginUser.setListRoleName(StringUtil.splitList(jwt.getClaim("listRoleName").asString())); |
| | | |
| | | return loginUser; |
| | | } |
| | | |
| | | /** |
| | | * 生成token,并保存到jwt |
| | | * |
| | | * @param loginUser 登录用户信息 |
| | | * @return 加密的token |
| | | */ |
| | | public static String getToken(LoginUserDTO loginUser) { |
| | | JWTCreator.Builder builder = JWT.create() |
| | | //设置jwt生成时间 |
| | | .withIssuedAt(new Date(LocalDateTimeUtil.nowTimeStamp())) |
| | | //设置token有效期 |
| | | .withExpiresAt(new Date(LocalDateTimeUtil.nowTimeStamp() + SysConfig.jwt.getExpiration() * ConstantFactory.TIME_LEN_1S)); |
| | | builder.withClaim("userId", loginUser.getUserId()); |
| | | builder.withClaim("userType", loginUser.getUserType().toString()); |
| | | builder.withClaim("phone", loginUser.getPhone()); |
| | | builder.withClaim("nickName", loginUser.getNickName()); |
| | | builder.withClaim("headImg", loginUser.getHeadImg()); |
| | | builder.withClaim("listRole", StringUtil.joinLong(loginUser.getListRole())); |
| | | builder.withClaim("listRoleName", StringUtil.join(loginUser.getListRoleName())); |
| | | return builder |
| | | //生成token字符串 |
| | | .sign(Algorithm.HMAC256(SysConfig.jwt.getSecret())) |
| | | ; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.jwt; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class LoginUserDTO { |
| | | /** |
| | | * 身份令牌 |
| | | */ |
| | | private String token; |
| | | /** |
| | | * 用户唯一标识 |
| | | */ |
| | | private String userId; |
| | | /** |
| | | * 用户类型 EUserType |
| | | */ |
| | | private Integer userType; |
| | | /** |
| | | * 用户名称 |
| | | */ |
| | | private String userName; |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String nickName; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String headImg; |
| | | /** |
| | | * 拥有角色列表 |
| | | */ |
| | | private List<Long> listRole; |
| | | /** |
| | | * 拥有角色-名称列表 |
| | | */ |
| | | private List<String> listRoleName; |
| | | |
| | | public String getToken() { |
| | | return token; |
| | | } |
| | | |
| | | public void setToken(String token) { |
| | | this.token = token; |
| | | } |
| | | |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(String userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Integer getUserType() { |
| | | return userType; |
| | | } |
| | | |
| | | public void setUserType(Integer userType) { |
| | | this.userType = userType; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public String getPhone() { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | public String getNickName() { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | public String getHeadImg() { |
| | | return headImg; |
| | | } |
| | | |
| | | public void setHeadImg(String headImg) { |
| | | this.headImg = headImg; |
| | | } |
| | | |
| | | public List<Long> getListRole() { |
| | | return listRole; |
| | | } |
| | | |
| | | public void setListRole(List<Long> listRole) { |
| | | this.listRole = listRole; |
| | | } |
| | | |
| | | public List<String> getListRoleName() { |
| | | return listRoleName; |
| | | } |
| | | |
| | | public void setListRoleName(List<String> listRoleName) { |
| | | this.listRoleName = listRoleName; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.model; |
| | | |
| | | public class ExcelDiscernCell { |
| | | private int cellIndex; |
| | | private String name; |
| | | private String value; |
| | | |
| | | public int getCellIndex() { |
| | | return cellIndex; |
| | | } |
| | | |
| | | public void setCellIndex(int cellIndex) { |
| | | this.cellIndex = cellIndex; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.model; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class ExcelDiscernRow { |
| | | private int rowIndx; |
| | | List<ExcelDiscernCell> listCell; |
| | | |
| | | public int getRowIndx() { |
| | | return rowIndx; |
| | | } |
| | | |
| | | public void setRowIndx(int rowIndx) { |
| | | this.rowIndx = rowIndx; |
| | | } |
| | | |
| | | public List<ExcelDiscernCell> getListCell() { |
| | | return listCell; |
| | | } |
| | | |
| | | public void setListCell(List<ExcelDiscernCell> listCell) { |
| | | this.listCell = listCell; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.model; |
| | | |
| | | /** |
| | | * 文件上传 响应dto |
| | | */ |
| | | public class ResFileUpload { |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | public String fileId; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | public String fileName; |
| | | |
| | | /** |
| | | * 是否上传成功 |
| | | */ |
| | | public Boolean isSuccess; |
| | | |
| | | /** |
| | | * 上传错误消息 |
| | | */ |
| | | public String errorMsg; |
| | | |
| | | /** |
| | | * 保存文件地址(数据库保存) |
| | | */ |
| | | public String newFilePath; |
| | | |
| | | /** |
| | | * 文件下载/预览地址 |
| | | */ |
| | | public String newFullPath; |
| | | |
| | | public String getFileId() { |
| | | return fileId; |
| | | } |
| | | |
| | | public void setFileId(String fileId) { |
| | | this.fileId = fileId; |
| | | } |
| | | |
| | | public String getFileName() { |
| | | return fileName; |
| | | } |
| | | |
| | | public void setFileName(String fileName) { |
| | | this.fileName = fileName; |
| | | } |
| | | |
| | | public Boolean getIsSuccess() { |
| | | return isSuccess; |
| | | } |
| | | |
| | | public void setIsSuccess(Boolean isSuccess) { |
| | | this.isSuccess = isSuccess; |
| | | } |
| | | |
| | | public String getErrorMsg() { |
| | | return errorMsg; |
| | | } |
| | | |
| | | public void setErrorMsg(String errorMsg) { |
| | | this.errorMsg = errorMsg; |
| | | } |
| | | |
| | | public String getNewFilePath() { |
| | | return newFilePath; |
| | | } |
| | | |
| | | public void setNewFilePath(String newFilePath) { |
| | | this.newFilePath = newFilePath; |
| | | } |
| | | |
| | | public String getNewFullPath() { |
| | | return newFullPath; |
| | | } |
| | | |
| | | public void setNewFullPath(String newFullPath) { |
| | | this.newFullPath = newFullPath; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ResFileUpload{" + |
| | | "fileId='" + fileId + '\'' + |
| | | ", fileName='" + fileName + '\'' + |
| | | ", isSuccess=" + isSuccess + |
| | | ", errorMsg='" + errorMsg + '\'' + |
| | | ", newFilePath='" + newFilePath + '\'' + |
| | | ", newFullPath='" + newFullPath + '\'' + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.model; |
| | | |
| | | /** |
| | | * 2个泛型参数返回结果 |
| | | * @param <T1> 参数1的类型 |
| | | * @param <T2> 参数2的类型 |
| | | */ |
| | | public class Tuple<T1, T2> { |
| | | private T1 item1; |
| | | private T2 item2; |
| | | |
| | | public Tuple() { |
| | | } |
| | | |
| | | public Tuple(T1 item1, T2 item2) { |
| | | this.item1 = item1; |
| | | this.item2 = item2; |
| | | } |
| | | |
| | | public T1 getItem1() { |
| | | return this.item1; |
| | | } |
| | | |
| | | public void setItem1(T1 item1) { |
| | | this.item1 = item1; |
| | | } |
| | | |
| | | public T2 getItem2() { |
| | | return this.item2; |
| | | } |
| | | |
| | | public void setItem2(T2 item2) { |
| | | this.item2 = item2; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.security; |
| | | |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.nio.charset.Charset; |
| | | import java.util.Base64; |
| | | |
| | | /** |
| | | * Base64工具类 |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | */ |
| | | public final class Base64Util { |
| | | private Base64Util() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | private static final String DEFAULT = "utf-8"; |
| | | |
| | | /** |
| | | * base64解码(utf-8编码) |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String encode(String str) { |
| | | return encode(str, DEFAULT); |
| | | } |
| | | /** |
| | | * base64解码 |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @param encoding 编码格式[默认utf-8] |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String encode(String str, String encoding) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return ""; |
| | | } |
| | | if(StringUtil.isNullOrEmpty(encoding)) { |
| | | encoding = DEFAULT; |
| | | } |
| | | byte[] bytes = str.getBytes(Charset.forName(encoding)); |
| | | return Base64.getEncoder().encodeToString(bytes); |
| | | } |
| | | /** |
| | | * base64解码(utf-8编码) |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String decode(String str) { |
| | | return decode(str, DEFAULT); |
| | | } |
| | | /** |
| | | * base64解码 |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @param encoding 编码格式[默认utf-8] |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String decode(String str, String encoding) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return ""; |
| | | } |
| | | if(StringUtil.isNullOrEmpty(encoding)) { |
| | | encoding = DEFAULT; |
| | | } |
| | | byte[] bytes = Base64.getDecoder().decode(str); |
| | | return new String(bytes, Charset.forName(encoding)); |
| | | } |
| | | |
| | | /** |
| | | * 二进制流转成base64字符串 |
| | | * @param buffer 二进制数组 |
| | | * @return 编码后的base64字符串 |
| | | */ |
| | | public static String encodeStream(final byte[] buffer) { |
| | | return Base64.getEncoder().encodeToString(buffer); |
| | | } |
| | | |
| | | /** |
| | | * 二进制流转成base64流 |
| | | * @param buffer 二进制数组 |
| | | * @return 编码后的base64流 |
| | | */ |
| | | public static byte[] encodeToStream(final byte[] buffer) { |
| | | return Base64.getEncoder().encode(buffer); |
| | | } |
| | | |
| | | /** |
| | | * base64字符串转成二进制流 |
| | | * @param str 密文字符串 |
| | | * @return 解码后的文件流 |
| | | */ |
| | | public static byte[] decodeToStream(String str) { |
| | | try { |
| | | return Base64.getDecoder().decode(str); |
| | | } catch (Exception e) { |
| | | return new byte[0]; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * base64字符串转成二进制流 |
| | | * @param buffer 密文流 |
| | | * @return 解码后的文件流 |
| | | */ |
| | | public static byte[] decodeToStream(final byte[] buffer) { |
| | | try { |
| | | return Base64.getDecoder().decode(buffer); |
| | | } catch (Exception e) { |
| | | return new byte[0]; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.security; |
| | | |
| | | import com.fengdu.gas.common.enums.ELogger; |
| | | import com.fengdu.gas.common.util.LoggerUtil; |
| | | import org.slf4j.Logger; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.KeyGenerator; |
| | | import javax.crypto.SecretKey; |
| | | import javax.crypto.SecretKeyFactory; |
| | | import javax.crypto.spec.DESedeKeySpec; |
| | | import javax.crypto.spec.IvParameterSpec; |
| | | import java.nio.charset.Charset; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.Key; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.SecureRandom; |
| | | import java.security.spec.InvalidKeySpecException; |
| | | import java.util.UUID; |
| | | |
| | | |
| | | public final class Des3Util { |
| | | private Des3Util() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); |
| | | |
| | | private static final String TITLE = "Des3加密工具"; |
| | | |
| | | //默认加密偏移量 |
| | | private static byte[] DEFAULT_IV = { 0x23, (byte)0xf2, (byte)0xa3, (byte)0xc6, 0x3e, 0x2b, (byte)0xe7, 0x28 }; |
| | | //加密算法 |
| | | private static final String ALGORITHM = "DESede"; |
| | | // 加解密统一使用的编码方式 |
| | | private static final String DEFAULT_ENCODING = "utf-8"; |
| | | //密钥 |
| | | public static final String DEFAULT_KEY = "com.ctrip.tour.cq.soa.v1"; |
| | | |
| | | /** |
| | | * 生成加密偏移量 |
| | | * @param iv 偏移量 |
| | | */ |
| | | private static IvParameterSpec IvGenerator(byte[] iv) throws Exception { |
| | | IvParameterSpec result = new IvParameterSpec(iv); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 随机生成一个key |
| | | */ |
| | | public static String genKey() throws NoSuchAlgorithmException { |
| | | byte[] keyBytes = UUID.randomUUID().toString().getBytes(); |
| | | KeyGenerator generator = KeyGenerator.getInstance(ALGORITHM); |
| | | generator.init(new SecureRandom( keyBytes ) ); |
| | | SecretKey key = generator.generateKey(); |
| | | return Base64Util.encodeStream(key.getEncoded()); |
| | | } |
| | | /** |
| | | * 根据明文字符串生成key(key长度必须 大于等于 24) |
| | | */ |
| | | public static Key genKey(String key) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException { |
| | | DESedeKeySpec spec = new DESedeKeySpec(key.getBytes()); |
| | | SecretKeyFactory keyfactory = SecretKeyFactory.getInstance(ALGORITHM); |
| | | return keyfactory.generateSecret(spec); |
| | | } |
| | | |
| | | /** |
| | | * 加密以byte[]明文输入,byte[]密文输出 |
| | | * @param buffer 待加密的字节码 |
| | | * @param key 密钥(key长度必须 大于等于 24) |
| | | * @return 加密后的字节码 |
| | | */ |
| | | private static byte[] encrypt(byte[] buffer, String key) { |
| | | byte[] result = null; |
| | | try { |
| | | Cipher cipher = Cipher.getInstance(ALGORITHM +"/CBC/PKCS5Padding"); |
| | | IvParameterSpec IVSpec = IvGenerator(DEFAULT_IV); |
| | | cipher.init(Cipher.ENCRYPT_MODE, genKey(key), IVSpec); |
| | | byte[] temp = cipher.doFinal(buffer); |
| | | result = Base64Util.encodeToStream(temp); |
| | | } catch (Exception e) { |
| | | sysLogger.error("Des3Util.encrypt", e); |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * 解密以byte[]密文输入,以byte[]明文输出 |
| | | * @param buffer 待解密的字节码 |
| | | * @param key 密钥(key长度必须是8的倍数) |
| | | * @return 解密后的字节码 |
| | | */ |
| | | private static byte[] decrypt(byte[] buffer, String key) { |
| | | byte[] result = null; |
| | | try { |
| | | IvParameterSpec IVSpec = IvGenerator(DEFAULT_IV); |
| | | Cipher cipher = Cipher.getInstance(ALGORITHM +"/CBC/PKCS5Padding"); |
| | | cipher.init(Cipher.DECRYPT_MODE, genKey(key), IVSpec); |
| | | byte[] temp = Base64Util.decodeToStream(buffer); |
| | | result = cipher.doFinal(temp); |
| | | } catch (Exception e) { |
| | | sysLogger.error("Des3Util.decrypt", e); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 加密String 明文输入密文输出 |
| | | * @param str 待加密的明文 |
| | | * @param key 密钥(key长度必须 大于等于 24) |
| | | * @return 加密后的字符串 |
| | | */ |
| | | public static String encrypt(String str, String key) throws Exception { |
| | | byte[] buffer = str.getBytes(Charset.forName(DEFAULT_ENCODING)); |
| | | byte[] result = encrypt(buffer, key); |
| | | return new String(result); |
| | | } |
| | | /** |
| | | * 解密String 以密文输入明文输出 |
| | | * @param str 需要解密的字符串 |
| | | * @param key 密钥(key长度必须 大于等于 24) |
| | | * @return 解密后的字符串 |
| | | */ |
| | | public static String decrypt(String str, String key) { |
| | | byte[] buffer = str.getBytes(Charset.forName(DEFAULT_ENCODING)); |
| | | byte[] result = decrypt(buffer, key); |
| | | return new String(result).trim(); |
| | | } |
| | | |
| | | /** |
| | | * 加密String 明文输入密文输出 |
| | | * @param str 待加密的明文 |
| | | * @return 加密后的字符串 |
| | | */ |
| | | public static String encrypt(String str) throws Exception { |
| | | return encrypt(str, DEFAULT_KEY); |
| | | } |
| | | /** |
| | | * 解密String 以密文输入明文输出 |
| | | * @param str 需要解密的字符串 |
| | | * @return 解密后的字符串 |
| | | */ |
| | | public static String decrypt(String str) { |
| | | return decrypt(str, DEFAULT_KEY); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.security; |
| | | |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | public class MD5Util { |
| | | private MD5Util() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 生成32位md5码 |
| | | * @param content 待加密明文字符串 |
| | | * @return 加密串 |
| | | */ |
| | | public static String encrypt(String content) { |
| | | //region 加盐方式 |
| | | try { |
| | | // 得到一个信息摘要器 |
| | | MessageDigest digest = MessageDigest.getInstance("md5"); |
| | | byte[] result = digest.digest(content.getBytes()); |
| | | StringBuilder sb = new StringBuilder(); |
| | | // 把每一个byte 做一个与运算 0xff; |
| | | for (byte b : result) { |
| | | // 与运算 |
| | | int number = b & 0xff;// 加盐 |
| | | String str = Integer.toHexString(number); |
| | | if (str.length() == 1) { |
| | | sb.append("0"); |
| | | } |
| | | sb.append(str); |
| | | } |
| | | // 标准的md5加密后的结果 |
| | | return sb.toString(); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | return ""; |
| | | } |
| | | //endregion |
| | | |
| | | //region 普通方式 |
| | | |
| | | /*char hexDigits[] = { |
| | | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' |
| | | }; |
| | | try { |
| | | byte[] btInput = content.getBytes(); |
| | | // 获得MD5摘要算法的 MessageDigest 对象 |
| | | MessageDigest mdInst = MessageDigest.getInstance("MD5"); |
| | | // 使用指定的字节更新摘要 |
| | | mdInst.update(btInput); |
| | | // 获得密文 |
| | | byte[] md = mdInst.digest(); |
| | | // 把密文转换成十六进制的字符串形式 |
| | | int j = md.length; |
| | | char str[] = new char[j * 2]; |
| | | int k = 0; |
| | | for (int i = 0; i < j; i++) { |
| | | byte byte0 = md[i]; |
| | | str[k++] = hexDigits[byte0 >>> 4 & 0xf]; |
| | | str[k++] = hexDigits[byte0 & 0xf]; |
| | | } |
| | | return new String(str); |
| | | } catch (Exception e) { |
| | | return ""; |
| | | }*/ |
| | | |
| | | //endregion |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.JsonSerializer; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fengdu.gas.common.util.CalendarUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Calendar; |
| | | |
| | | /** |
| | | * 自定义json序列化 Calendar 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQCalendarSerializer extends JsonSerializer<Calendar> { |
| | | @Override |
| | | public void serialize(Calendar value, JsonGenerator g, SerializerProvider provider) throws IOException { |
| | | if(null==value) { |
| | | return; |
| | | } |
| | | g.writeString(CalendarUtil.toDateTimeStr(value)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.JsonSerializer; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 自定义json序列化 Date 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQDateSerializer extends JsonSerializer<Date> { |
| | | @Override |
| | | public void serialize(Date value, JsonGenerator g, SerializerProvider provider) throws IOException { |
| | | if(null==value) { |
| | | return; |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat(ConstantFactory.STR_DATE); |
| | | g.writeString(sdf.format(value)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.JsonSerializer; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * 自定义json序列化 LocalDate 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQLocalDateSerializer extends JsonSerializer<LocalDate> { |
| | | public void serialize(LocalDate value, JsonGenerator g, SerializerProvider provider) throws IOException { |
| | | g.writeString(LocalDateTimeUtil.toFormatString(value)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.JsonSerializer; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * 自定义json序列化 LocalDateTime 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQLocalDateTimeSerializer extends JsonSerializer<LocalDateTime> { |
| | | @Override |
| | | public void serialize(LocalDateTime value, JsonGenerator g, SerializerProvider provider) throws IOException { |
| | | g.writeString(LocalDateTimeUtil.toFormatFullString(value)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.JsonSerializer; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * 自定义json序列化 Timestamp 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQTimestampSerializer extends JsonSerializer<Timestamp> { |
| | | @Override |
| | | public void serialize(Timestamp value, JsonGenerator g, SerializerProvider provider) throws IOException { |
| | | if(null==value) { |
| | | return; |
| | | } |
| | | g.writeString(LocalDateTimeUtil.toFormatFullString(value)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer.deserializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonParser; |
| | | import com.fasterxml.jackson.databind.DeserializationContext; |
| | | import com.fasterxml.jackson.databind.JsonDeserializer; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.util.CalendarUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Calendar; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * 自定义json反序列化 Calendar 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQCalendarDeSerializer extends JsonDeserializer<Calendar> { |
| | | @Override |
| | | public Calendar deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
| | | String value = p.getText(); |
| | | |
| | | if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { |
| | | return CalendarUtil.fromDateStr(value); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { |
| | | return CalendarUtil.fromDateTimeStr(value); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { |
| | | return CalendarUtil.fromDateTimeMSStr(value); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_JAVA)) { |
| | | Pattern pattern = Pattern.compile(ConstantFactory.REGEX_DATETIME_JAVA); |
| | | Matcher matcher = pattern.matcher(value); |
| | | if(matcher.find()) { |
| | | String timestamp = matcher.group("timestamp"); |
| | | return CalendarUtil.fromMillis(NumericUtil.tryParseLong(timestamp)); |
| | | } |
| | | } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { |
| | | return CalendarUtil.fromMillis(NumericUtil.tryParseLong(value)); |
| | | } |
| | | throw new IOException("can't be deserialize as type “Calendar”, " + value); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer.deserializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonParser; |
| | | import com.fasterxml.jackson.databind.DeserializationContext; |
| | | import com.fasterxml.jackson.databind.JsonDeserializer; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 自定义json反序列化 Date 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQDateDeSerializer extends JsonDeserializer<Date> { |
| | | @Override |
| | | public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
| | | String value = p.getText(); |
| | | if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { |
| | | LocalDateTime date = LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE); |
| | | Instant instant = date.toInstant(ZoneOffset.UTC); |
| | | return Date.from(instant); |
| | | } else { |
| | | throw new IOException("can't be deserialize as type “Date”, " + value); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer.deserializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonParser; |
| | | import com.fasterxml.jackson.databind.DeserializationContext; |
| | | import com.fasterxml.jackson.databind.JsonDeserializer; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * 自定义json反序列化 LocalDate 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQLocalDateDeSerializer extends JsonDeserializer<LocalDate> { |
| | | @Override |
| | | public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
| | | String value = p.getText(); |
| | | if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { |
| | | return LocalDateTimeUtil.getDate(value); |
| | | } else { |
| | | throw new IOException("can't be deserialize as type “LocalDate”, " + value); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer.deserializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonParser; |
| | | import com.fasterxml.jackson.databind.DeserializationContext; |
| | | import com.fasterxml.jackson.databind.JsonDeserializer; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * 自定义json反序列化 LocalDateTime 属性 |
| | | * @author linliu |
| | | * @date 2020-05-12 |
| | | */ |
| | | public class CQLocalDateTimeDeSerializer extends JsonDeserializer<LocalDateTime> { |
| | | @Override |
| | | public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
| | | String value = p.getText(); |
| | | if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { |
| | | return LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { |
| | | return LocalDateTimeUtil.getDateTime(value); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { |
| | | return LocalDateTimeUtil.getDateTime(value, ConstantFactory.STR_DATE_FULLMS); |
| | | } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { |
| | | return LocalDateTimeUtil.getDateTime(NumericUtil.tryParseLong(value)); |
| | | } else { |
| | | throw new IOException("can't be deserialize as type “LocalDateTime”, " + value); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.serializer.deserializer; |
| | | |
| | | import com.fasterxml.jackson.core.JsonParser; |
| | | import com.fasterxml.jackson.databind.DeserializationContext; |
| | | import com.fasterxml.jackson.databind.JsonDeserializer; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * 自定义json反序列化 LocalDateTime 属性 |
| | | * @author linliu |
| | | * @date 2020-07-03 |
| | | */ |
| | | public class CQTimestampDeSerializer extends JsonDeserializer<Timestamp> { |
| | | @Override |
| | | public Timestamp deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
| | | String value = p.getText(); |
| | | if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATE)) { |
| | | return LocalDateTimeUtil.getTimeStamp(value, ConstantFactory.STR_DATE); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME)) { |
| | | return LocalDateTimeUtil.getTimeStamp(value); |
| | | } else if(StringUtil.isMatch(value, ConstantFactory.REGEX_DATETIME_FULL)) { |
| | | return LocalDateTimeUtil.getTimeStamp(value, ConstantFactory.STR_DATE_FULLMS); |
| | | } else if(StringUtil.isMatch(value, "^[0-9]{13}$")) { |
| | | return LocalDateTimeUtil.getTimeStamp(NumericUtil.tryParseLong(value)); |
| | | } else { |
| | | throw new IOException("can't be deserialize as type “Timestamp”, " + value); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 日期处理类 |
| | | * @author xiangyuanzhang |
| | | * @date 2018-12-25 |
| | | */ |
| | | public final class CalendarUtil { |
| | | static final Long ONE_DAYMS = 86400000L; |
| | | private static final int ONE_SECONDS = 1000; |
| | | |
| | | private CalendarUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时区时间 |
| | | * @param origin |
| | | */ |
| | | public static Calendar toLocal(Calendar origin) { |
| | | if(origin == null) { |
| | | return null; |
| | | } else if(origin.getTimeZone().equals(TimeZone.getDefault())) { |
| | | return origin; |
| | | } else { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(origin.getTimeInMillis()); |
| | | return calendar; |
| | | } |
| | | } |
| | | |
| | | public static int daysBetween(Calendar timeStart, Calendar timeEnd) { |
| | | long time1 = timeStart.getTimeInMillis(); |
| | | long time2 = timeEnd.getTimeInMillis(); |
| | | long betweenDays = (time2 - time1) / ONE_DAYMS; |
| | | return Integer.parseInt(String.valueOf(betweenDays)); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间 |
| | | */ |
| | | public static Calendar getNow() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | return calendar; |
| | | } |
| | | |
| | | public static Calendar getNow(int days) { |
| | | Calendar calendar = getNow(); |
| | | calendar.add(Calendar.DAY_OF_MONTH, days); |
| | | return calendar; |
| | | } |
| | | |
| | | public static Calendar fromCalendarInDate(Calendar time) { |
| | | Calendar calendar = null; |
| | | if(time != null) { |
| | | try { |
| | | String ex = toDateStr(time); |
| | | calendar = fromDateStr(ex); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | |
| | | return calendar; |
| | | } |
| | | |
| | | public static Calendar fromMillisInDate(Long ms) { |
| | | Calendar calendar = fromMillis(ms); |
| | | return CalendarUtil.fromCalendarInDate(calendar); |
| | | } |
| | | |
| | | public static Calendar fromMillis(Long ms) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(ms); |
| | | return calendar; |
| | | } |
| | | |
| | | public static Calendar fromTimestamp(Timestamp ts) { |
| | | Calendar calendar = null; |
| | | if(ts != null) { |
| | | calendar = Calendar.getInstance(); |
| | | long time = ts.getTime(); |
| | | calendar.setTimeInMillis(time); |
| | | } |
| | | return calendar; |
| | | } |
| | | |
| | | /** |
| | | * 通过yyyy-MM-dd获取日期 |
| | | * @param dateStr 日期字符串 |
| | | */ |
| | | public static Calendar fromDateStr(String dateStr) { |
| | | return CalendarUtil.fromStr(dateStr, ConstantFactory.STR_DATE); |
| | | } |
| | | |
| | | /** |
| | | * 通过yyyy-MM-dd HH:mm:ss.SSS获取日期 |
| | | * @param dateTimeMSStr 带毫秒的时间字符串 |
| | | */ |
| | | public static Calendar fromDateTimeMSStr(String dateTimeMSStr) { |
| | | Calendar calendar = null; |
| | | if(StringUtil.isNotNullOrEmpty(dateTimeMSStr) && !"null".equals(dateTimeMSStr)) { |
| | | calendar = CalendarUtil.fromStr(dateTimeMSStr, ConstantFactory.STR_DATE_FULLMS); |
| | | } |
| | | return calendar; |
| | | } |
| | | |
| | | /** |
| | | * 通过yyyy-MM-dd HH:mm:ss获取日期 |
| | | * @param dateTimeStr 时间字符串 |
| | | */ |
| | | public static Calendar fromDateTimeStr(String dateTimeStr) { |
| | | return CalendarUtil.fromStr(dateTimeStr, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | |
| | | /** |
| | | * 通过指定时间格式,获取Calendar对象 |
| | | * @param dateStr 时间字符串 |
| | | * @param format 时间格式 |
| | | */ |
| | | public static Calendar fromStr(String dateStr, String format) { |
| | | Calendar calendar; |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | Date date = sdf.parse(dateStr); |
| | | calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | return calendar; |
| | | } catch (ParseException var5) { |
| | | //TODO log |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public static String toNowDateStr() { |
| | | return CalendarUtil.toDateStr(getNow()); |
| | | } |
| | | |
| | | public static String toNowDateTimeStr() { |
| | | return CalendarUtil.toDateTimeStr(getNow()); |
| | | } |
| | | |
| | | public static String toNowDateTimeMSStr() { |
| | | return CalendarUtil.toDateTimeMSStr(getNow()); |
| | | } |
| | | |
| | | public static String toDateStr(Calendar calendar) { |
| | | return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE); |
| | | } |
| | | |
| | | public static String toDateTimeStr(Calendar calendar) { |
| | | return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | |
| | | public static String toDateTimeMSStr(Calendar calendar) { |
| | | return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULLMS); |
| | | } |
| | | |
| | | public static String toDateTimeStr(Calendar calendar, String format) { |
| | | if(null == calendar) { |
| | | calendar = CalendarUtil.fromDateTimeStr(ConstantFactory.STR_DATE_DEFAULT); |
| | | } |
| | | SimpleDateFormat formatter = new SimpleDateFormat(format); |
| | | return formatter.format(calendar.getTime()); |
| | | } |
| | | |
| | | public static String toStringByTimestamp(Timestamp ts) { |
| | | Calendar calendar = CalendarUtil.fromTimestamp(ts); |
| | | return CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE_FULLMS); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间戳 |
| | | * @return 当前时间戳 |
| | | */ |
| | | public static Timestamp getNowTimestamp() { |
| | | return new Timestamp(CalendarUtil.nowTimestamp()); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间戳 |
| | | */ |
| | | public static Long nowTimestamp() { |
| | | return Instant.now().toEpochMilli(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间戳 |
| | | */ |
| | | public static String nowTimestampStr() { |
| | | return Long.toString(CalendarUtil.nowTimestamp()); |
| | | } |
| | | |
| | | public static Calendar get1970() { |
| | | Calendar result; |
| | | try { |
| | | result = fromStr("1970-01-01 08:00:01", ConstantFactory.STR_DATE_FULL); |
| | | } catch (Exception e) { |
| | | result = null; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static Integer getAge(Calendar birthDay) { |
| | | if(birthDay==null) { |
| | | return 0; |
| | | } |
| | | Calendar now = getNow(); |
| | | |
| | | int nowYear = now.get(Calendar.YEAR); |
| | | int nowMonth = now.get(Calendar.MONTH); |
| | | int nowDay = now.get(Calendar.DAY_OF_MONTH); |
| | | |
| | | int birthDayYear= birthDay.get(Calendar.YEAR); |
| | | int birthDayMonth = birthDay.get(Calendar.MONTH); |
| | | int birthDayDay = birthDay.get(Calendar.DAY_OF_MONTH); |
| | | |
| | | int age = nowYear - birthDayYear; |
| | | if(nowMonth < birthDayMonth) { |
| | | age--; |
| | | } else if(nowMonth == birthDayMonth && nowDay < birthDayDay) { |
| | | age--; |
| | | } else { |
| | | age = 0; |
| | | } |
| | | return age; |
| | | } |
| | | |
| | | public static Integer getAge(String birthDay) { |
| | | Calendar cBirthDay = CalendarUtil.fromStr(birthDay, ConstantFactory.STR_DATE); |
| | | return getAge(cBirthDay); |
| | | } |
| | | |
| | | /** |
| | | * 方法为获取时间段内的所有日期 |
| | | * @param dateFrom 时间起 |
| | | * @param dateEnd 时间至 |
| | | * @return List<Long> 返回该时间段内的所有日期的时间戳队列。 |
| | | * @throws ParseException |
| | | */ |
| | | public static List<String> getDates(String dateFrom, String dateEnd) throws ParseException { |
| | | return CalendarUtil.getDates(dateFrom, dateEnd, "-1"); |
| | | } |
| | | |
| | | /** |
| | | * 方法为指定时间段内获取指定周几的所有日期 |
| | | * @param dateFrom 时间起 |
| | | * @param dateEnd 时间至 |
| | | * @param weekDays 需要在时间段中指定查询的周数,建议使用“,”隔开(不隔开也没问题),需要获取时间段内所有日期时参数为"-1"。星期日=0,星期一=1,星期二=2,星期三=3,星期四=4,星期五=5,星期六=6。 |
| | | * @return List<Long> 返回符合条件日期的时间戳队列。 |
| | | * @throws ParseException |
| | | */ |
| | | public static List<String> getDates(String dateFrom, String dateEnd, String weekDays) throws ParseException { |
| | | boolean isAll = weekDays.contains("-1"); |
| | | long time; |
| | | List<String> dateList = new ArrayList<>(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ConstantFactory.STR_DATE); |
| | | dateFrom = simpleDateFormat.format(simpleDateFormat.parse(dateFrom).getTime() - ONE_DAYMS); |
| | | while (true) { |
| | | time = simpleDateFormat.parse(dateFrom).getTime(); |
| | | time = time + ONE_DAYMS; |
| | | Date date = new Date(time); |
| | | dateFrom = simpleDateFormat.format(date); |
| | | if (dateFrom.compareTo(dateEnd) <= 0) { |
| | | if (isAll) { |
| | | dateList.add(dateFrom); |
| | | } else { |
| | | Integer weekDay = dayForWeek(date); |
| | | if (weekDays.contains(weekDay.toString())) { |
| | | dateList.add(dateFrom); |
| | | } |
| | | } |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | return dateList; |
| | | } |
| | | |
| | | private static Integer dayForWeek(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | return calendar.get(Calendar.DAY_OF_WEEK) - 1; |
| | | } |
| | | |
| | | public static Timestamp get1970Timestamp() { |
| | | Timestamp result; |
| | | try { |
| | | Calendar date = get1970(); |
| | | if(null!=date) { |
| | | result = new Timestamp(date.getTimeInMillis()); |
| | | } else { |
| | | result = null; |
| | | } |
| | | } catch (Exception e) { |
| | | result = null; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 从指定格式时间字符串,获取时间戳 |
| | | */ |
| | | public static Timestamp getTimestamp(String dateStr, String format) { |
| | | Long timspamp = Long.parseLong("1000"); |
| | | Calendar date = CalendarUtil.fromStr(dateStr, format); |
| | | if(null!=date) { |
| | | timspamp = date.getTimeInMillis(); |
| | | } |
| | | return new Timestamp(timspamp); |
| | | } |
| | | |
| | | /** |
| | | * 获取今日 00:00:00 |
| | | */ |
| | | public static Calendar getToday() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | String today = CalendarUtil.toDateTimeStr(calendar, ConstantFactory.STR_DATE); |
| | | return CalendarUtil.fromStr(today, ConstantFactory.STR_DATE); |
| | | } |
| | | |
| | | /** |
| | | * 获取本月第一天零时 xxxx-xx-01 00:00:00 |
| | | */ |
| | | public static Calendar getCurrentMonthFirstDay() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | String toMonth = CalendarUtil.toDateTimeStr(calendar, "yyyy-MM")+"-01"; |
| | | return CalendarUtil.fromStr(toMonth, ConstantFactory.STR_DATE); |
| | | } |
| | | |
| | | /** |
| | | * 从指定Calendar获取时间戳 |
| | | */ |
| | | public static Timestamp getTimestamp(Calendar date) { |
| | | Long timspamp = Long.parseLong("1000"); |
| | | if(null!=date) { |
| | | timspamp = date.getTimeInMillis(); |
| | | } |
| | | return new Timestamp(timspamp); |
| | | } |
| | | |
| | | public static boolean isValid(Calendar calendar) { |
| | | if(null==calendar|| calendar.compareTo(CalendarUtil.get1970())<0) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | public static boolean isValid(Timestamp timestamp) { |
| | | if(null==timestamp || timestamp.compareTo(CalendarUtil.get1970Timestamp())<0) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | public static boolean isValid(String dateStr, String format) { |
| | | Calendar calendar = CalendarUtil.fromStr(dateStr, format); |
| | | if(null==calendar || calendar.compareTo(CalendarUtil.get1970())<0) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public static Integer getTimestampSeconds(Calendar time) { |
| | | long mils = time.getTimeInMillis(); |
| | | String timestamp = String.valueOf(mils / ONE_SECONDS); |
| | | return Integer.valueOf(timestamp); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import org.springframework.cglib.beans.BeanCopier; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | public final class CopierUtil { |
| | | private CopierUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 单个对象属性拷贝 |
| | | * @param source 源对象 |
| | | * @param clazz 目标对象Class |
| | | * @param <T> 目标对象类型 |
| | | * @param <M> 源对象类型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <T, M> T mapTo(M source, Class<T> clazz) { |
| | | if (Objects.isNull(source) || Objects.isNull(clazz)) |
| | | throw new IllegalArgumentException(); |
| | | return mapTo(source, clazz, null); |
| | | } |
| | | |
| | | /** |
| | | * 列表对象拷贝 |
| | | * @param sources 源列表 |
| | | * @param clazz 源列表对象Class |
| | | * @param <T> 目标列表对象类型 |
| | | * @param <M> 源列表对象类型 |
| | | * @return 目标列表 |
| | | */ |
| | | public static <T, M> List<T> mapTo(List<M> sources, Class<T> clazz) { |
| | | if (Objects.isNull(sources) || Objects.isNull(clazz) || sources.isEmpty()) |
| | | throw new IllegalArgumentException(); |
| | | BeanCopier copier = BeanCopier.create(sources.get(0).getClass(), clazz, false); |
| | | return Optional.of(sources) |
| | | .orElse(new ArrayList<>()) |
| | | .stream().map(m -> mapTo(m, clazz, copier)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 单个对象属性拷贝 |
| | | * @param source 源对象 |
| | | * @param clazz 目标对象Class |
| | | * @param copier copier |
| | | * @param <T> 目标对象类型 |
| | | * @param <M> 源对象类型 |
| | | * @return 目标对象 |
| | | */ |
| | | private static <T, M> T mapTo(M source, Class<T> clazz, BeanCopier copier) { |
| | | if (null == copier){ |
| | | copier = BeanCopier.create(source.getClass(), clazz, false); |
| | | } |
| | | T t = null; |
| | | try { |
| | | t = clazz.newInstance(); |
| | | copier.copy(source, t, null); |
| | | } catch (InstantiationException | IllegalAccessException e) { |
| | | // TODO log |
| | | } |
| | | return t; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | public class EncryptionUtil { |
| | | public static String encryptString(String input) { |
| | | try { |
| | | // 将传入的字符串转换为字节数组 |
| | | byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8); |
| | | |
| | | // 使用SHA-256进行加密 |
| | | MessageDigest digest = MessageDigest.getInstance("SHA-256"); |
| | | byte[] hashBytes = digest.digest(inputBytes); |
| | | |
| | | // 转换为十六进制字符串 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (byte b : hashBytes) { |
| | | sb.append(String.format("%02x", b)); |
| | | } |
| | | String hashedString = sb.toString(); |
| | | |
| | | // 按照指定规则截取和重新组合字符串 |
| | | StringBuilder result = new StringBuilder(); |
| | | for (int i = 0; i < 4; i++) { |
| | | String subString = hashedString.substring(i * 16, (i + 1) * 16); |
| | | for (int j = 0; j < 4; j++) { |
| | | result.append(subString.charAt(j * 4 + j)); |
| | | } |
| | | } |
| | | return result.toString(); |
| | | |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // String input = "#beiaisi#_000001"; // 传入的字符串 |
| | | // |
| | | // // 调用加密方法 |
| | | // String encryptedString = encryptString(input); |
| | | // System.out.println(encryptedString); |
| | | // } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.PrintStream; |
| | | |
| | | /** |
| | | * 异常工具类 |
| | | * @author linliu |
| | | * @date 2018-12-28 |
| | | */ |
| | | public final class ExceptionUtil { |
| | | private ExceptionUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | public static String getMsg(Throwable e) { |
| | | ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| | | PrintStream pout = new PrintStream(out); |
| | | e.printStackTrace(pout); |
| | | String ret = new String(out.toByteArray()); |
| | | pout.close(); |
| | | return ret; |
| | | } |
| | | |
| | | public static String getDetails(Throwable ex) { |
| | | return getMessage(ex, true); |
| | | } |
| | | |
| | | |
| | | private static String getMessage(Throwable ex, boolean includeDetail) { |
| | | if (ex != null) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | Throwable current = ex; |
| | | |
| | | do { |
| | | builder.append(ex.getClass().getName()); |
| | | if (!StringUtil.isNullOrEmpty(current.getMessage())) { |
| | | builder.append(String.format(" : %s%n", current.getMessage())); |
| | | } |
| | | |
| | | if (includeDetail) { |
| | | builder.append(getStackTraceInfo(current)); |
| | | } |
| | | |
| | | current = current.getCause(); |
| | | } while(current != null); |
| | | |
| | | return builder.toString(); |
| | | } else { |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | private static String getStackTraceInfo(Throwable ex) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | if (ex != null) { |
| | | StackTraceElement[] trace = ex.getStackTrace(); |
| | | StackTraceElement[] var6 = trace; |
| | | int var5 = trace.length; |
| | | |
| | | for(int var4 = 0; var4 < var5; ++var4) { |
| | | StackTraceElement s = var6[var4]; |
| | | sb.append(String.format("\tat %s%n", s)); |
| | | } |
| | | } |
| | | |
| | | return sb.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.io.*; |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * 文件工具类 |
| | | * @author linliu |
| | | * @date 2019-03-20 |
| | | */ |
| | | public final class FileUtil { |
| | | private FileUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | static final String TITLE = "FileUtil"; |
| | | static final Integer EXCEL_SHEET_MAXROW = 65536; |
| | | static final String STR_FAILD = "generate excel is faild!"; |
| | | static final String STR_UPLOADEXCEL = "list to excel and upload file service"; |
| | | static final String STR_DEFAULT_SHEETNAME = "Sheet1"; |
| | | |
| | | /** |
| | | * 根据文件contentType生成一个文件名 |
| | | * @param fileContentType contentType |
| | | */ |
| | | public static String getNewFileNameByType(String fileContentType) { |
| | | String timeStamp = Long.toString(System.currentTimeMillis()); |
| | | return timeStamp + FileUtil.getFileExtByType(fileContentType); |
| | | } |
| | | |
| | | /** |
| | | * 根据文件contentType生成一个文件名 |
| | | * @param fileContentType contentType |
| | | */ |
| | | public static String getFileExtByType(String fileContentType) { |
| | | String result = checkImage(fileContentType); |
| | | if (StringUtil.isNotNullOrEmpty(result)) { |
| | | return result; |
| | | } |
| | | |
| | | result = checkRar(fileContentType); |
| | | if (StringUtil.isNotNullOrEmpty(result)) { |
| | | return result; |
| | | } |
| | | |
| | | result = checkMedia(fileContentType); |
| | | if (StringUtil.isNotNullOrEmpty(result)) { |
| | | return result; |
| | | } |
| | | |
| | | result = checkXml(fileContentType); |
| | | if (StringUtil.isNotNullOrEmpty(result)) { |
| | | return result; |
| | | } |
| | | |
| | | result = checkOffice(fileContentType); |
| | | if (StringUtil.isNotNullOrEmpty(result)) { |
| | | return result; |
| | | } |
| | | return ".txt"; |
| | | } |
| | | |
| | | /** |
| | | * 验证文件contentType是否是图片 |
| | | * @param fileContentType contentType |
| | | */ |
| | | private static String checkImage(String fileContentType) { |
| | | String result; |
| | | switch (fileContentType) { |
| | | case "image/jpeg": |
| | | case "application/x-jpg": |
| | | result = ".jpg"; |
| | | break; |
| | | case "image/gif": |
| | | result = ".gif"; |
| | | break; |
| | | case "image/png": |
| | | result = ".png"; |
| | | break; |
| | | case "image/bmp": |
| | | result = ".bmp"; |
| | | break; |
| | | default: |
| | | result = ""; |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 验证文件contentType是否是压缩包 |
| | | * @param fileContentType contentType |
| | | */ |
| | | private static String checkRar(String fileContentType) { |
| | | String result; |
| | | switch (fileContentType) { |
| | | case "application/zip": |
| | | result = ".zip"; |
| | | break; |
| | | case "application/x-rar": |
| | | result = ".rar"; |
| | | break; |
| | | case "application/x-7z-compressed": |
| | | result = ".7z"; |
| | | break; |
| | | case "application/x-gzip": |
| | | result = ".gz"; |
| | | break; |
| | | default: |
| | | result = ""; |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 验证文件contentType是否是媒体文件 |
| | | * @param fileContentType contentType |
| | | */ |
| | | private static String checkMedia(String fileContentType) { |
| | | String result; |
| | | switch (fileContentType) { |
| | | case "video/mpeg": |
| | | result = ".mp2"; |
| | | break; |
| | | case "video/mp4": |
| | | result = ".mp4"; |
| | | break; |
| | | case "video/3gpp": |
| | | result = ".3gp"; |
| | | break; |
| | | case "video/x-flv": |
| | | result = ".flv"; |
| | | break; |
| | | |
| | | case "audio/mpeg": |
| | | result = ".mp3"; |
| | | break; |
| | | case "audio/x-flac": |
| | | result = ".flac"; |
| | | break; |
| | | default: |
| | | result = ""; |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 验证文件contentType是否是xml |
| | | * @param fileContentType contentType |
| | | */ |
| | | private static String checkXml(String fileContentType) { |
| | | String result; |
| | | switch (fileContentType) { |
| | | case "application/xml": |
| | | case "text/html": |
| | | result = ".xml"; |
| | | break; |
| | | default: |
| | | result = ""; |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 验证文件contentType是否是office |
| | | * @param fileContentType contentType |
| | | */ |
| | | private static String checkOffice(String fileContentType) { |
| | | String result; |
| | | switch (fileContentType) { |
| | | case "application/vnd.ms-excel": |
| | | result = ".xls"; |
| | | break; |
| | | case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": |
| | | result = ".xlsx"; |
| | | break; |
| | | case "application/msword": |
| | | result = ".doc"; |
| | | break; |
| | | case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": |
| | | result = ".docx"; |
| | | break; |
| | | case "application/vnd.ms-powerpoint": |
| | | result = ".ppt"; |
| | | break; |
| | | case "application/vnd.openxmlformats-officedocument.presentationml.presentation": |
| | | result = ".pptx"; |
| | | break; |
| | | default: |
| | | result = ""; |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件名识别文件 mediaType |
| | | * @author linliu |
| | | * @date 2019-06-26 |
| | | * @param fileName 文件名 |
| | | */ |
| | | public static String getMediaTypeByFileName(String fileName) { |
| | | if (StringUtil.isNullOrEmpty(fileName)) { |
| | | return ""; |
| | | } |
| | | String[] arrayPath = StringUtil.split(fileName, "/"); |
| | | String realFileName = arrayPath[arrayPath.length - 1]; |
| | | String[] array = StringUtil.split(realFileName, "\\."); |
| | | String fileSuffix = "." + array[array.length - 1]; |
| | | return getOfficeMediaTypeByFileName(fileSuffix); |
| | | } |
| | | |
| | | /** |
| | | * 根据文件拓展名识别 office文件 |
| | | * @param fileSuffix 拓展名 |
| | | */ |
| | | private static String getOfficeMediaTypeByFileName(String fileSuffix) { |
| | | String result; |
| | | switch (fileSuffix) { |
| | | case ".xls": |
| | | result = "application/vnd.ms-excel"; |
| | | break; |
| | | case ".xlsx": |
| | | result = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; |
| | | break; |
| | | case ".doc": |
| | | result = "application/msword"; |
| | | break; |
| | | case ".docx": |
| | | result = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; |
| | | break; |
| | | case ".ppt": |
| | | result = "application/vnd.ms-powerpoint"; |
| | | break; |
| | | case ".pptx": |
| | | result = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; |
| | | break; |
| | | default: |
| | | result = getImageMediaTypeByFileName(fileSuffix); |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件拓展名识别 图片文件 |
| | | * @param fileSuffix 拓展名 |
| | | */ |
| | | private static String getImageMediaTypeByFileName(String fileSuffix) { |
| | | String result; |
| | | switch (fileSuffix) { |
| | | case ".jpeg": |
| | | result = "image/jpeg"; |
| | | break; |
| | | case ".jpg": |
| | | result = "application/x-jpg"; |
| | | break; |
| | | case ".gif": |
| | | result = "image/gif"; |
| | | break; |
| | | case ".png": |
| | | result = "image/png"; |
| | | break; |
| | | case ".bmp": |
| | | result = "image/bmp"; |
| | | break; |
| | | default: |
| | | result = getRarMediaTypeByFileName(fileSuffix); |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件拓展名识别 压缩文件 |
| | | * @param fileSuffix 拓展名 |
| | | */ |
| | | private static String getRarMediaTypeByFileName(String fileSuffix) { |
| | | String result; |
| | | switch (fileSuffix) { |
| | | case ".zip": |
| | | result = "application/zip"; |
| | | break; |
| | | case ".rar": |
| | | result = "application/x-rar"; |
| | | break; |
| | | case ".7z": |
| | | result = "application/x-7z-compressed"; |
| | | break; |
| | | case ".gz": |
| | | result = "application/x-gzip"; |
| | | break; |
| | | default: |
| | | result = getOtherMediaTypeByFileName(fileSuffix); |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件拓展名识别 其他文件 |
| | | * @param fileSuffix 拓展名 |
| | | */ |
| | | private static String getOtherMediaTypeByFileName(String fileSuffix) { |
| | | String result; |
| | | switch (fileSuffix) { |
| | | case ".pdf": |
| | | result = "application/pdf"; |
| | | break; |
| | | case ".txt": |
| | | result = "text/plain"; |
| | | break; |
| | | default: |
| | | result = ""; |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 读取本地文件内容 |
| | | * @param filePath 文件路径 |
| | | */ |
| | | public static String readFileContent(String filePath) { |
| | | return readFileContent(filePath, null); |
| | | } |
| | | |
| | | /** |
| | | * 读取本地文件内容 |
| | | * @param filePath 文件路径 |
| | | * @param charset 编码格式 |
| | | */ |
| | | public static String readFileContent(String filePath, Charset charset) { |
| | | if(null==charset) { |
| | | charset = Charset.forName("utf-8"); |
| | | } |
| | | File file = new File(filePath.replaceAll("\\\\", "/")); |
| | | StringBuilder localStrBulider = new StringBuilder(); |
| | | if(file.isFile() && file.exists()) { |
| | | String lineStr; |
| | | try (InputStreamReader inputStreamReader=new InputStreamReader(new FileInputStream(file), charset)){ |
| | | BufferedReader bufferReader = new BufferedReader(inputStreamReader); |
| | | while((lineStr = bufferReader.readLine()) != null) { |
| | | localStrBulider.append(lineStr); |
| | | } |
| | | bufferReader.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } else { |
| | | //TODO log |
| | | return null; |
| | | } |
| | | return localStrBulider.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 读取本地文件内容 |
| | | * @param filePath 文件路径 |
| | | */ |
| | | public static byte[] readFile(String filePath) throws IOException { |
| | | File f = new File(filePath); |
| | | if (!f.exists()) { |
| | | throw new FileNotFoundException(filePath); |
| | | } |
| | | |
| | | ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length()); |
| | | BufferedInputStream in = null; |
| | | try { |
| | | in = new BufferedInputStream(new FileInputStream(f)); |
| | | int bufSize = 1024; |
| | | byte[] buffer = new byte[bufSize]; |
| | | int len; |
| | | while (-1 != (len = in.read(buffer, 0, bufSize))) { |
| | | bos.write(buffer, 0, len); |
| | | } |
| | | return bos.toByteArray(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw e; |
| | | } finally { |
| | | try { |
| | | in.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | bos.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除文件 |
| | | * @param path |
| | | */ |
| | | public static void deleteFile(String path){ |
| | | File file=new File(path); |
| | | if(file.exists()){ |
| | | file.delete(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取流内容 |
| | | * @param inputStream 流 |
| | | */ |
| | | public static String readFileContent(InputStream inputStream) { |
| | | return FileUtil.readFileContent(inputStream, null); |
| | | } |
| | | |
| | | /** |
| | | * 读取流内容 |
| | | * @param inputStream 流 |
| | | * @param charset 编码格式 |
| | | */ |
| | | public static String readFileContent(InputStream inputStream, Charset charset) { |
| | | if(null==charset) { |
| | | charset = StandardCharsets.UTF_8; |
| | | } |
| | | StringBuilder localStrBulider = new StringBuilder(); |
| | | try (InputStreamReader inputStreamReader=new InputStreamReader(inputStream, charset)){ |
| | | BufferedReader bufferReader = new BufferedReader(inputStreamReader); |
| | | String lineStr; |
| | | while((lineStr = bufferReader.readLine()) != null) { |
| | | localStrBulider.append(lineStr); |
| | | } |
| | | bufferReader.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | return localStrBulider.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import com.fengdu.gas.common.enums.EHttpContentType; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.HttpHost; |
| | | import org.apache.http.HttpStatus; |
| | | import org.apache.http.StatusLine; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.entity.ByteArrayEntity; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.entity.mime.MultipartEntityBuilder; |
| | | import org.apache.http.entity.mime.content.ByteArrayBody; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.util.EntityUtils; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Http请求工具类 |
| | | * @author xiangyuanzhang |
| | | * @date 2018-12-25 |
| | | */ |
| | | public final class HttpUtil { |
| | | //region 常量 |
| | | |
| | | static final String STR_LOGTITLE = "SendHttpRequest"; |
| | | static final String STR_UTF8 = "utf-8"; |
| | | |
| | | private static final int CONNECTTIMEOUT=20000; |
| | | |
| | | //endregion |
| | | |
| | | private HttpUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | static Boolean isLogRequestContent(EHttpContentType contentType) { |
| | | Boolean isLog; |
| | | switch (contentType) { |
| | | case JSON: |
| | | case XML: |
| | | case FORM: |
| | | isLog = Boolean.TRUE; |
| | | break; |
| | | default: |
| | | isLog = Boolean.FALSE; |
| | | break; |
| | | } |
| | | return isLog; |
| | | } |
| | | |
| | | /** |
| | | * 获取HttpPost对象 |
| | | * @param url 请求url |
| | | * @param contentType 请求类型(EHttpContentType),默认application/x-www-Form-urlencoded |
| | | * @param headers 自定义请求头 |
| | | * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) |
| | | * @return |
| | | */ |
| | | private static HttpPost getHttpPost(String url, String contentType, Map<String, String> headers, String proxy) { |
| | | if(StringUtil.isNullOrEmpty(contentType)) { |
| | | contentType = EHttpContentType.FORM.getDesc(); |
| | | } |
| | | |
| | | HttpHost httpProxy = null; |
| | | if(StringUtil.isNotNullOrEmpty(proxy)) { |
| | | proxy = proxy.replace("https://", "").replace("http://", ""); |
| | | String[] arrProxy = StringUtil.split(proxy, ":"); |
| | | httpProxy = new HttpHost(arrProxy[0], Integer.valueOf(arrProxy[1])); |
| | | } |
| | | |
| | | //创建httpPost |
| | | HttpPost httpPost = new HttpPost(url); |
| | | if(!EHttpContentType.FORMDATA.getDesc().equals(contentType)) { |
| | | httpPost.setHeader("Content-Type", contentType); |
| | | } |
| | | |
| | | RequestConfig config = RequestConfig.custom() |
| | | //连接超时 |
| | | .setConnectionRequestTimeout(Integer.parseInt("60000"))//60 * 1000 |
| | | //请求超时 |
| | | .setConnectTimeout(Integer.parseInt("300000"))//5 * 60 * 1000 |
| | | //读取超时 |
| | | .setSocketTimeout(Integer.parseInt("10000"))//10 * 1000 |
| | | .setProxy(httpProxy) |
| | | .build(); |
| | | |
| | | httpPost.setConfig(config); |
| | | if(headers!=null && !headers.isEmpty()) { |
| | | for (Map.Entry<String, String> item : headers.entrySet()) { |
| | | httpPost.setHeader(item.getKey(), item.getValue()); |
| | | } |
| | | } |
| | | |
| | | return httpPost; |
| | | } |
| | | |
| | | /** |
| | | * 发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param contentType 请求类型 |
| | | * @param headers 自定义header |
| | | * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) |
| | | */ |
| | | public static String doPost(String url, HttpEntity postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { |
| | | String responseContent; |
| | | |
| | | CloseableHttpClient httpclient = HttpClients.custom() |
| | | .build(); |
| | | HttpPost httpPost = HttpUtil.getHttpPost(url, contentType.getDesc(), headers, proxy); |
| | | httpPost.setEntity(postData); |
| | | CloseableHttpResponse response = null; |
| | | |
| | | Map<String, String> logTags = new HashMap<>(); |
| | | logTags.put("url", url.toLowerCase()); |
| | | StringBuilder sbLog = new StringBuilder(HttpUtil.createLog(url, httpPost, contentType, postData)); |
| | | |
| | | try { |
| | | response = httpclient.execute(httpPost); |
| | | sbLog.append(String.format("ResponseTime:%s%n", CalendarUtil.toNowDateTimeMSStr())); |
| | | |
| | | StatusLine status = response.getStatusLine(); |
| | | int state = status.getStatusCode(); |
| | | if (state == HttpStatus.SC_OK) { |
| | | HttpEntity responseEntity = response.getEntity(); |
| | | responseContent = EntityUtils.toString(responseEntity); |
| | | |
| | | sbLog.append(String.format("ResponseData:%s%n", responseContent)); |
| | | sbLog.append(String.format("ResponseDataReadedTime:%s%n", CalendarUtil.toNowDateTimeMSStr())); |
| | | } |
| | | else{ |
| | | throw new RuntimeException(url+", the response “HttpStatus” of remote is :"+ state); |
| | | } |
| | | } |
| | | catch (Exception e) { |
| | | sbLog.append(String.format("the time at exception happend:%s%n", LocalDateTimeUtil.nowTimeStampStr())); |
| | | //TODO log |
| | | throw e; |
| | | } |
| | | finally { |
| | | if (response != null) { |
| | | try { |
| | | response.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | try { |
| | | httpclient.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | //TODO log |
| | | return responseContent; |
| | | } |
| | | |
| | | static String createLog(String url, HttpPost httpPost, EHttpContentType contentType, HttpEntity postData) { |
| | | StringBuilder sbLog = new StringBuilder(); |
| | | |
| | | sbLog.append(String.format("url:%s%n", url)); |
| | | sbLog.append(String.format("Request time:%s%n", CalendarUtil.toNowDateTimeMSStr())); |
| | | sbLog.append(String.format("Request method:%s%n", httpPost.getMethod())); |
| | | sbLog.append(String.format("ContentType:%s%n", httpPost.getEntity().getContentType())); |
| | | HttpHost hProxy = httpPost.getConfig().getProxy(); |
| | | if(hProxy!=null && StringUtil.isNotNullOrEmpty(hProxy.getHostName())) { |
| | | sbLog.append(String.format("used http proxy:%s://%s:%s%n", hProxy.getSchemeName(), hProxy.getHostName(), hProxy.getPort())); |
| | | } |
| | | if(null!= httpPost.getAllHeaders() && httpPost.getAllHeaders().length>0) { |
| | | sbLog.append(String.format("headers:%s%n", SerializeUtil.toJson(httpPost.getAllHeaders()))); |
| | | } |
| | | |
| | | if(isLogRequestContent(contentType)) { |
| | | try { |
| | | sbLog.append(String.format("Request body:%s%n", EntityUtils.toString(postData, STR_UTF8))); |
| | | } catch (Exception e) { |
| | | // |
| | | } |
| | | } else { |
| | | BigDecimal sizeKB = new BigDecimal(postData.getContentLength()).divide(new BigDecimal("1024")); |
| | | sbLog.append(String.format("Request body:%s kb.%n", sizeKB.setScale(Integer.parseInt("2"), BigDecimal.ROUND_HALF_UP))); |
| | | } |
| | | sbLog.append(String.format("Request data readed time:%s%n", CalendarUtil.toNowDateTimeMSStr())); |
| | | |
| | | return sbLog.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param contentType 请求类型 |
| | | */ |
| | | public static String doPost(String url, byte[] postData, EHttpContentType contentType) throws IOException { |
| | | return HttpUtil.doPost(url, postData, contentType, null, null); |
| | | } |
| | | |
| | | /** |
| | | * 发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param contentType 请求类型 |
| | | * @param headers 自定义header |
| | | * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) |
| | | */ |
| | | public static String doPost(String url, byte[] postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { |
| | | HttpEntity entity = new ByteArrayEntity(postData, ContentType.create(contentType.getDesc())); |
| | | return HttpUtil.doPost(url, entity, contentType, headers, proxy); |
| | | } |
| | | |
| | | /** |
| | | * 发起文件上传请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param fileName 文件名 |
| | | * @param fileContentType 文件类型 |
| | | */ |
| | | public static String postFile(String url, byte[] postData, String fileName, String fileContentType) throws IOException { |
| | | return HttpUtil.postFile(url, postData, fileName, fileContentType, null, null); |
| | | } |
| | | /** |
| | | * 发起文件上传请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param fileName 文件名 |
| | | * @param fileContentType 文件类型 |
| | | * @param headers 自定义header |
| | | * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) |
| | | */ |
| | | public static String postFile(String url, byte[] postData, String fileName, String fileContentType, Map<String, String> headers, String proxy) throws IOException { |
| | | MultipartEntityBuilder entity = MultipartEntityBuilder.create(); |
| | | entity.addPart("file", new ByteArrayBody(postData, ContentType.create(fileContentType), fileName)); |
| | | return HttpUtil.doPost(url, entity.build(), EHttpContentType.FORMDATA, headers, proxy); |
| | | } |
| | | |
| | | /** |
| | | * 发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param contentType 请求类型 |
| | | */ |
| | | public static String doPost(String url, String postData, EHttpContentType contentType, Map<String, String> headers) throws IOException { |
| | | HttpEntity entity = new StringEntity(postData, STR_UTF8); |
| | | return HttpUtil.doPost(url, entity, contentType, headers, null); |
| | | } |
| | | |
| | | /** |
| | | * 发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param contentType 请求类型 |
| | | * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) |
| | | */ |
| | | public static String doPost(String url, String postData, EHttpContentType contentType, Map<String, String> headers, String proxy) throws IOException { |
| | | HttpEntity entity = new StringEntity(postData, STR_UTF8); |
| | | return HttpUtil.doPost(url, entity, contentType, headers, proxy); |
| | | } |
| | | |
| | | /** |
| | | * 发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param contentType 请求类型 |
| | | */ |
| | | public static String doPost(String url, String postData, EHttpContentType contentType) throws IOException { |
| | | return HttpUtil.doPost(url, postData, contentType, null); |
| | | } |
| | | |
| | | /** |
| | | * 以“application/json”方式发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param headers 自定义header |
| | | */ |
| | | public static String postJson(String url, Object postData, Map<String, String> headers) throws IOException { |
| | | String json = SerializeUtil.toJson(postData); |
| | | HttpEntity entity = new StringEntity(json, STR_UTF8); |
| | | return HttpUtil.doPost(url, entity, EHttpContentType.JSON, headers, null); |
| | | } |
| | | |
| | | /** |
| | | * 以“application/json”方式发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param type 反序列化类型 |
| | | * @param headers 自定义header |
| | | * @param <T> 反序列化对象泛型 |
| | | */ |
| | | public static <T> T postJson(String url, Object postData, Class<T> type, Map<String, String> headers) throws IOException { |
| | | return HttpUtil.postJson(url, postData, type, headers, null); |
| | | } |
| | | |
| | | /** |
| | | * 以“application/json”方式发起post请求 |
| | | * @param url 请求url |
| | | * @param postData 数据包 |
| | | * @param type 反序列化类型 |
| | | * @param headers 自定义header |
| | | * @param proxy http代理(例: http://ntproxy.qa.nt.ctripcorp.com:8080) |
| | | * @param <T> 反序列化对象泛型 |
| | | */ |
| | | public static <T> T postJson(String url, Object postData, Class<T> type, Map<String, String> headers, String proxy) throws IOException { |
| | | String json = SerializeUtil.toJson(postData); |
| | | HttpEntity entity = new StringEntity(json, STR_UTF8); |
| | | String response = doPost(url, entity, EHttpContentType.JSON, headers, proxy); |
| | | |
| | | T result; |
| | | try { |
| | | result = SerializeUtil.toObject(response, type); |
| | | } catch (Exception e) { |
| | | result = null; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 从url获取响应流 |
| | | * @param url 请求url |
| | | */ |
| | | public static byte[] getStreamByUrl(String url) { |
| | | CloseableHttpClient httpclient = HttpClients.custom().setConnectionManagerShared(true).build(); |
| | | HttpGet httpGet = new HttpGet(url); |
| | | RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(CONNECTTIMEOUT).setConnectTimeout(CONNECTTIMEOUT).build();//设置请求和传输超时时间 |
| | | httpGet.setConfig(requestConfig); |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | response = httpclient.execute(httpGet); |
| | | int statuscode = response.getStatusLine().getStatusCode(); |
| | | if (statuscode == HttpStatus.SC_OK) { |
| | | HttpEntity entity = response.getEntity(); |
| | | InputStream isStream = entity.getContent(); |
| | | return HttpUtil.getBytesFromInputStream(isStream); |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | } finally { |
| | | if (response != null) { |
| | | //TODO log |
| | | } |
| | | |
| | | try { |
| | | httpclient.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | return new byte[0]; |
| | | } |
| | | |
| | | /** |
| | | * 从输入流返回字节数组 |
| | | * @param input 输入流 |
| | | */ |
| | | public static byte[] getBytesFromInputStream(InputStream input) { |
| | | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| | | try { |
| | | byte[] buffer = new byte[1024]; |
| | | int n = 0; |
| | | while (-1 != (n = input.read(buffer))) { |
| | | output.write(buffer, 0, n); |
| | | } |
| | | return output.toByteArray(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | return new byte[0]; |
| | | } finally { |
| | | try { |
| | | output.close(); |
| | | input.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发起get请求,读取返回流为字符串 |
| | | * @param url 请求url |
| | | * @param charset 读取返回流的字符集 |
| | | */ |
| | | public static String doGet(String url, String charset) throws UnsupportedEncodingException { |
| | | byte[] result = HttpUtil.getStreamByUrl(url); |
| | | try { |
| | | return new String(result, charset); |
| | | } catch (UnsupportedEncodingException e) { |
| | | try { |
| | | return new String(result, STR_UTF8); |
| | | } catch (Exception ex) { |
| | | throw e; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发起get请求,以“utf-8”字符集,读取返回流为字符串 |
| | | * @param url 请求url |
| | | */ |
| | | public static String doGet(String url) { |
| | | try { |
| | | return HttpUtil.doGet(url, STR_UTF8); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 从url获取响应流 |
| | | * @param url 请求url |
| | | * @param headers 自定义header |
| | | * @param proxy 代理地址([http:// | https://]www.baidu.com:8080) |
| | | */ |
| | | public static byte[] getStream(String url, Map<String, String> headers, String proxy) { |
| | | String action = "getStreamByUrl"; |
| | | Map<String, String> logTags = new HashMap<>(); |
| | | logTags.put("action", action); |
| | | logTags.put("url", url); |
| | | |
| | | HttpHost httpProxy = null; |
| | | if(StringUtil.isNotNullOrEmpty(proxy)) { |
| | | proxy = proxy.replace("https://", "").replace("http://", ""); |
| | | String[] arrProxy = StringUtil.split(proxy, ":"); |
| | | httpProxy = new HttpHost(arrProxy[0], Integer.parseInt(arrProxy[1])); |
| | | } |
| | | |
| | | CloseableHttpClient httpclient = HttpClients.custom() |
| | | .setConnectionManagerShared(true) |
| | | .build(); |
| | | HttpGet httpGet = new HttpGet(url); |
| | | if(null!=headers) { |
| | | for (Map.Entry<String, String> entry : headers.entrySet()) { |
| | | httpGet.setHeader(entry.getKey(), entry.getValue()); |
| | | } |
| | | } |
| | | //设置请求和传输超时时间 |
| | | RequestConfig requestConfig = RequestConfig.custom() |
| | | .setSocketTimeout(CONNECTTIMEOUT) |
| | | .setConnectTimeout(CONNECTTIMEOUT) |
| | | .setProxy(httpProxy) |
| | | .build(); |
| | | httpGet.setConfig(requestConfig); |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | response = httpclient.execute(httpGet); |
| | | int statusCode = response.getStatusLine().getStatusCode(); |
| | | if (statusCode == HttpStatus.SC_OK) { |
| | | HttpEntity entity = response.getEntity(); |
| | | InputStream isStream = entity.getContent(); |
| | | return HttpUtil.getBytesFromInputStream(isStream); |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | } finally { |
| | | if (response != null) { |
| | | try { |
| | | response.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | try { |
| | | httpclient.close(); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | } |
| | | } |
| | | return new byte[0]; |
| | | } |
| | | |
| | | public static byte[] getStream(String url, Map<String, String> headers) { |
| | | return HttpUtil.getStream(url, headers, null); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | |
| | | public class IPUtils { |
| | | private static Logger logger = LoggerFactory.getLogger(IPUtils.class); |
| | | private static final String IP_UTILS_FLAG = ","; |
| | | private static final String UNKNOWN = "unknown"; |
| | | private static final String LOCALHOST_IP = "0:0:0:0:0:0:0:1"; |
| | | private static final String LOCALHOST_IP1 = "127.0.0.1"; |
| | | |
| | | /** |
| | | * 获取IP地址 |
| | | * <p> |
| | | * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址 |
| | | * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址 |
| | | */ |
| | | public static String getIpAddress(HttpServletRequest request) { |
| | | String ip = null; |
| | | try { |
| | | //以下两个获取在k8s中,将真实的客户端IP,放到了x-Original-Forwarded-For。而将WAF的回源地址放到了 x-Forwarded-For了。 |
| | | ip = request.getHeader("X-Original-Forwarded-For"); |
| | | if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("X-Forwarded-For"); |
| | | } |
| | | //获取nginx等代理的ip |
| | | if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("x-forwarded-for"); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("Proxy-Client-IP"); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(ip) || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("WL-Proxy-Client-IP"); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_CLIENT_IP"); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); |
| | | } |
| | | //兼容k8s集群获取ip |
| | | if (StringUtil.isNullOrEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) { |
| | | ip = request.getRemoteAddr(); |
| | | if (LOCALHOST_IP1.equalsIgnoreCase(ip) || LOCALHOST_IP.equalsIgnoreCase(ip)) { |
| | | //根据网卡取本机配置的IP |
| | | InetAddress iNet = null; |
| | | try { |
| | | iNet = InetAddress.getLocalHost(); |
| | | } catch (UnknownHostException e) { |
| | | logger.error("getClientIp error: {}", e); |
| | | } |
| | | ip = iNet.getHostAddress(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("IPUtils ERROR ", e); |
| | | } |
| | | //使用代理,则获取第一个IP地址 |
| | | if (!StringUtil.isNullOrEmpty(ip) && ip.indexOf(IP_UTILS_FLAG) > 0) { |
| | | ip = ip.substring(0, ip.indexOf(IP_UTILS_FLAG)); |
| | | } |
| | | |
| | | return ip; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.function.Consumer; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * List工具类 |
| | | * @author linliu |
| | | * @date 2018-12-28 |
| | | */ |
| | | public final class ListUtil { |
| | | private ListUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * array转list |
| | | * @param array 数组 |
| | | * @param <T> 实体类型 |
| | | */ |
| | | public static <T> List<T> toList(T... array) { |
| | | if(array==null || array.length==0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return Arrays.stream(array).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * Long类型 list转array |
| | | * @param list 集合 |
| | | */ |
| | | public static Long[] toLongArray(List<Long> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new Long[0]; |
| | | } |
| | | Long[] array = new Long[list.size()]; |
| | | return list.toArray(array); |
| | | } |
| | | /** |
| | | * Integer类型 list转array |
| | | * @param list 集合 |
| | | */ |
| | | public static Integer[] toIntArray(List<Integer> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new Integer[0]; |
| | | } |
| | | Integer[] array = new Integer[list.size()]; |
| | | return list.toArray(array); |
| | | } |
| | | /** |
| | | * BigDecimal类型 list转array |
| | | * @param list 集合 |
| | | */ |
| | | public static BigDecimal[] toDecimalArray(List<BigDecimal> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new BigDecimal[0]; |
| | | } |
| | | BigDecimal[] array = new BigDecimal[list.size()]; |
| | | return list.toArray(array); |
| | | } |
| | | /** |
| | | * Double类型 list转array |
| | | * @param list 集合 |
| | | */ |
| | | public static Double[] toDoubleArray(List<Double> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new Double[0]; |
| | | } |
| | | Double[] array = new Double[list.size()]; |
| | | return list.toArray(array); |
| | | } |
| | | /** |
| | | * String类型 list转array |
| | | * @param list 集合 |
| | | */ |
| | | public static String[] toArray(List<String> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new String[0]; |
| | | } |
| | | String[] array = new String[list.size()]; |
| | | return list.toArray(array); |
| | | } |
| | | |
| | | /** |
| | | * 判断集合【为】null或empty |
| | | * @param list 集合 |
| | | * @param <T> 集合实体类型 |
| | | */ |
| | | public static <T> boolean isNullOrEmpty(Collection<T> list){ |
| | | return list==null || list.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * 判断集合【不为】null或empty |
| | | * @param list 集合 |
| | | * @param <T> 集合实体类型 |
| | | */ |
| | | public static <T> boolean isNotNullOrEmpty(Collection<T> list){ |
| | | return !ListUtil.isNullOrEmpty(list); |
| | | } |
| | | |
| | | /** |
| | | * String类型集合转Integer类型集合 |
| | | * @param list 集合 |
| | | */ |
| | | public static List<Integer> toIntList(List<String> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return list.stream().map(Integer::parseInt).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * String类型集合转Long类型集合 |
| | | * @param list 集合 |
| | | */ |
| | | public static List<Long> toLongList(List<String> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return list.stream().map(Long::parseLong).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * Integer类型集合转String类型集合 |
| | | * @param list 集合 |
| | | */ |
| | | public static List<String> toStringList(List<Integer> list) { |
| | | if(ListUtil.isNullOrEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return list.stream().map(String::valueOf).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * BigDecimal类型集合求和 |
| | | * @param list 集合 |
| | | */ |
| | | public static BigDecimal sum(Collection<BigDecimal> list) { |
| | | BigDecimal result = BigDecimal.ZERO; |
| | | if(ListUtil.isNotNullOrEmpty(list)) { |
| | | result = list.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 判断集合非空后,执行委托 |
| | | * @param list 集合 |
| | | * @param predicate 循环集合的委托代码 |
| | | * @param <T> 集合实体类型 |
| | | * @param <R> 函数(集合委托)返回值,委托里最后一句写死“return null;” |
| | | */ |
| | | public static <T, R> void notNullForeach(Collection<T> list, Function<T, R> predicate) { |
| | | if(ListUtil.isNotNullOrEmpty(list)) { |
| | | for (T item : list) { |
| | | predicate.apply(item); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 集合去重 |
| | | * @param list 集合 |
| | | * @param <T> 集合实体类型 |
| | | */ |
| | | public static <T> void repeat(Collection<T> list) { |
| | | HashSet<T> hash = new HashSet<T>(list); |
| | | list.clear(); |
| | | list.addAll(hash); |
| | | } |
| | | |
| | | /** |
| | | * 判断集合是否存在重复元素 |
| | | * @param list 集合 |
| | | * @param <T> 集合实体类型 |
| | | */ |
| | | public static <T> Boolean hasRepeat(Collection<T> list) { |
| | | int oldSize = list.size(); |
| | | repeat(list); |
| | | return list.size()!=oldSize; |
| | | } |
| | | |
| | | /** |
| | | * 集合非空,则执行委托 |
| | | * @param list 集合 |
| | | * @param predicate 循环集合的委托代码 |
| | | * @param <T> 集合实体类型 |
| | | */ |
| | | public static <T> void notNullForeach(Collection<T> list, Consumer<T> predicate) { |
| | | if(ListUtil.isNotNullOrEmpty(list)) { |
| | | for (T item : list) { |
| | | predicate.accept(item); |
| | | } |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.fengdu.gas.common.exceptions.BusinessException; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * jdk8时间日期处理 工具类 |
| | | */ |
| | | public final class LocalDateTimeUtil { |
| | | private LocalDateTimeUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 默认时间格式化对象 |
| | | */ |
| | | private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern(ConstantFactory.STR_DATE_FULL); |
| | | /** |
| | | * 默认时间格式化对象 |
| | | */ |
| | | private static final DateTimeFormatter DEFAULT_FORMATTER_DATE = DateTimeFormatter.ofPattern(ConstantFactory.STR_DATE); |
| | | /** |
| | | * 默认时间(1970-01-01 00:00:00) |
| | | */ |
| | | public static final LocalDateTime DEFAULT_DATETIME = LocalDateTime.parse(ConstantFactory.STR_DATE_DEFAULT, DEFAULT_FORMATTER); |
| | | /** |
| | | * 默认时间(1970-01-01) |
| | | */ |
| | | public static final LocalDate DEFAULT_DATE = LocalDate.parse(ConstantFactory.STR_DATE_DEFAULT_DATE, DEFAULT_FORMATTER_DATE); |
| | | |
| | | //************************************** 【LocalDateTime】 ************************************** |
| | | /** |
| | | * 获取当前LocalDateTime |
| | | */ |
| | | public static LocalDateTime nowDateTime() { |
| | | return LocalDateTime.now(); |
| | | } |
| | | /** |
| | | * 获取当前时间字符串(yyyy-MM-dd HH:mm:ss) |
| | | */ |
| | | public static String nowDateTimeStr() { |
| | | return LocalDateTimeUtil.toFormatString(LocalDateTime.now()); |
| | | } |
| | | /** |
| | | * 获取当前时间字符串(yyyy-MM-dd HH:mm:ss.SSS) |
| | | */ |
| | | public static String nowDateTimeFullStr() { |
| | | return LocalDateTimeUtil.toFormatFullString(LocalDateTime.now()); |
| | | } |
| | | /** |
| | | * 通过时间戳构建LocalDateTime |
| | | * @param timestamp 时间戳 |
| | | */ |
| | | public static LocalDateTime getDateTime(Long timestamp) { |
| | | if(NumericUtil.tryParseLong(timestamp).compareTo(0L)<1) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); |
| | | } |
| | | /** |
| | | * 通过时间戳构建LocalDateTime |
| | | * @param timestamp 时间戳 |
| | | */ |
| | | public static LocalDateTime getDateTime(Timestamp timestamp) { |
| | | if(null==timestamp) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return LocalDateTimeUtil.getDateTime(timestamp.getTime()); |
| | | } |
| | | /** |
| | | * 通过时间字符串和指定时间格式(例:yyyy-MM-dd HH:mm:ss), 构建LocalDateTime |
| | | * @param dateTime 时间字符串 |
| | | * @param format 指定时间格式(例:yyyy-MM-dd HH:mm:ss) |
| | | */ |
| | | public static LocalDateTime getDateTime(String dateTime, String format) { |
| | | if(StringUtil.isNullOrEmpty(dateTime)) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | if(StringUtil.isNullOrEmpty(format)) { |
| | | format = ConstantFactory.STR_DATE_FULL; |
| | | } |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); |
| | | if(ConstantFactory.STR_DATE.equals(format)) { |
| | | LocalDate localDate = getDate(dateTime); |
| | | return localDate.atStartOfDay(); |
| | | } |
| | | return LocalDateTime.parse(dateTime, dateTimeFormatter); |
| | | } |
| | | /** |
| | | * 通过时间字符串和固定时间格式(yyyy-MM-dd HH:mm:ss), 构建LocalDateTime |
| | | * @param dateTime 时间字符串 |
| | | */ |
| | | public static LocalDateTime getDateTime(String dateTime) { |
| | | return LocalDateTimeUtil.getDateTime(dateTime, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | /** |
| | | * 将LocalDateTime格式化成时间字符串 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param format 指定时间格式(例:yyyy-MM-dd HH:mm:ss) |
| | | */ |
| | | public static String toFormatString(LocalDateTime dateTime, String format) { |
| | | if(null==dateTime) { |
| | | return ConstantFactory.STR_DATE_DEFAULT; |
| | | } |
| | | if(StringUtil.isNullOrEmpty(format)) { |
| | | format = ConstantFactory.STR_DATE_FULL; |
| | | } |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); |
| | | return dateTimeFormatter.format(dateTime); |
| | | } |
| | | /** |
| | | * 将LocalDateTime按“yyyy-MM-dd HH:mm:ss.SSS”格式化成时间字符串 |
| | | * @param dateTime LocalDateTime对象 |
| | | */ |
| | | public static String toFormatFullString(LocalDateTime dateTime) { |
| | | if(null==dateTime) { |
| | | return ConstantFactory.STR_DATE_DEFAULT_FULL; |
| | | } |
| | | return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE_FULLMS); |
| | | } |
| | | /** |
| | | * 将LocalDateTime按“yyyy-MM-dd HH:mm:ss”格式化成时间字符串 |
| | | * @param dateTime LocalDateTime对象 |
| | | */ |
| | | public static String toFormatString(LocalDateTime dateTime) { |
| | | if(null==dateTime) { |
| | | return ConstantFactory.STR_DATE_DEFAULT; |
| | | } |
| | | return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | /** |
| | | * 将LocalDateTime按“yyyy-MM-dd”格式化成时间字符串 |
| | | * @param dateTime LocalDateTime对象 |
| | | */ |
| | | public static String toDateString(LocalDateTime dateTime) { |
| | | if(null==dateTime) { |
| | | return ConstantFactory.STR_DATE_DEFAULT_DATE; |
| | | } |
| | | return LocalDateTimeUtil.toFormatString(dateTime, ConstantFactory.STR_DATE); |
| | | } |
| | | /** |
| | | * 将dateTime格式化成时间字符串 |
| | | * @param date LocalDate对象 |
| | | * @param format 指定时间格式(例:yyyy-MM-dd) |
| | | */ |
| | | public static String toFormatString(LocalDate date, String format) { |
| | | if(null==date) { |
| | | return ConstantFactory.STR_DATE_DEFAULT_DATE; |
| | | } |
| | | if(StringUtil.isNullOrEmpty(format)) { |
| | | format = ConstantFactory.STR_DATE; |
| | | } |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); |
| | | return dateTimeFormatter.format(date); |
| | | } |
| | | /** |
| | | * 将LocalDate按“yyyy-MM-dd”格式化成时间字符串 |
| | | * @param date LocalDate对象 |
| | | */ |
| | | public static String toFormatString(LocalDate date) { |
| | | return LocalDateTimeUtil.toFormatString(date, ConstantFactory.STR_DATE); |
| | | } |
| | | /** |
| | | * LocalDateTime偏移指定月数 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param addMonth 偏移月数(可以为负数) |
| | | */ |
| | | public static LocalDateTime dateTimeAddMonth(LocalDateTime dateTime, Long addMonth) { |
| | | if(null==dateTime) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return dateTime.plusMonths(addMonth); |
| | | } |
| | | /** |
| | | * LocalDateTime偏移指定天数 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param addDay 偏移天数(可以为负数) |
| | | */ |
| | | public static LocalDateTime dateTimeAddDay(LocalDateTime dateTime, Long addDay) { |
| | | if(null==dateTime) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return dateTime.plusDays(addDay); |
| | | } |
| | | /** |
| | | * LocalDateTime偏移指定小时数 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param addHour 偏移小时数(可以为负数) |
| | | */ |
| | | public static LocalDateTime dateTimeAddHour(LocalDateTime dateTime, Long addHour) { |
| | | if(null==dateTime) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return dateTime.plusHours(addHour); |
| | | } |
| | | /** |
| | | * LocalDateTime偏移指定分钟数 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param addMin 偏移分钟数(可以为负数) |
| | | */ |
| | | public static LocalDateTime dateTimeAddMin(LocalDateTime dateTime, Long addMin) { |
| | | if(null==dateTime) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return dateTime.plusMinutes(addMin); |
| | | } |
| | | /** |
| | | * 获取两个日期相差的天数 |
| | | * |
| | | * @param dateString1 开始日期的字符串 |
| | | * @param dateString2 结束日期的字符串 |
| | | * @return 相差天数,如果解析失败则返回-1 |
| | | **/ |
| | | public static long subDaysByDate2(String dateString1 , String dateString2 ) { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDate date1 = LocalDate.parse(dateString1, formatter); |
| | | LocalDate date2 = LocalDate.parse(dateString2, formatter); |
| | | long daysBetween = java.time.Duration.between(date1.atStartOfDay(), date2.atStartOfDay()).toDays(); |
| | | return daysBetween; |
| | | } |
| | | /** |
| | | * LocalDateTime偏移指定秒数 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param addSec 偏移秒数(可以为负数) |
| | | */ |
| | | public static LocalDateTime dateTimeAddSec(LocalDateTime dateTime, Long addSec) { |
| | | if(null==dateTime) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return dateTime.plusSeconds(addSec); |
| | | } |
| | | /** |
| | | * LocalDateTime指定时间部分,偏移指定值 |
| | | * @param dateTime LocalDateTime对象 |
| | | * @param addPart 偏移时间部分 |
| | | * @param value 偏移值 |
| | | */ |
| | | public static LocalDateTime dateTimeAdd(LocalDateTime dateTime, ChronoUnit addPart, Long value) { |
| | | if(null==dateTime) { |
| | | return LocalDateTimeUtil.DEFAULT_DATETIME; |
| | | } |
| | | return dateTime.plus(value, addPart); |
| | | } |
| | | /** |
| | | * 获取当前月份第一天LocalDateTime“00:00:00” |
| | | */ |
| | | public static LocalDateTime monthFirstDateTime() { |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | return LocalDateTime.of(now.getYear(), now.getMonthValue(), 1, 0, 0); |
| | | } |
| | | /** |
| | | * 获取年月字符串第一天“00:00:00”时间戳 |
| | | */ |
| | | public static Long getYearMonthFirstTime(String yearMonth){ |
| | | //String month = "2023-05"; |
| | | LocalDateTime time = DateTime.of(yearMonth, "yyyy-MM").toTimestamp().toLocalDateTime(); |
| | | LocalDateTime first = time.with(TemporalAdjusters.firstDayOfMonth()).withHour(0) |
| | | .withMinute(0).withSecond(0); |
| | | return getTimeStamp(first).getTime(); |
| | | } |
| | | /** |
| | | * 获取年月字符串最后一天“00:00:00”时间戳 |
| | | */ |
| | | public static Long getYearMonthLatestTime(String yearMonth){ |
| | | //String month = "2023-05"; |
| | | LocalDateTime time = DateTime.of(yearMonth, "yyyy-MM").toTimestamp().toLocalDateTime(); |
| | | LocalDateTime end = time.with(TemporalAdjusters.lastDayOfMonth()).withHour(23) |
| | | .withMinute(59).withSecond(59); |
| | | return getTimeStamp(end).getTime(); |
| | | } |
| | | /** |
| | | * 获取当前月份最后一天LocalDateTime“23:59:59” |
| | | */ |
| | | public static LocalDateTime monthLatestDateTime() { |
| | | //当前月第一天“00:00:00” |
| | | LocalDateTime monthFirst = monthFirstDateTime(); |
| | | //下个月第一天“00:00:00” |
| | | LocalDateTime nextMonthFirst = dateTimeAddMonth(monthFirst, 1L); |
| | | //当前月最后一天“23:59:59” |
| | | return LocalDateTimeUtil.dateTimeAddSec(nextMonthFirst, -1L); |
| | | } |
| | | /** |
| | | * 获取今天LocalDateTime“00:00:00” |
| | | */ |
| | | public static LocalDateTime todayFirst() { |
| | | LocalDateTime now = LocalDateTimeUtil.nowDateTime(); |
| | | return LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), 0, 0); |
| | | } |
| | | /** |
| | | * 获取今天LocalDateTime“23:59:59” |
| | | */ |
| | | public static LocalDateTime todayLatest() { |
| | | //今天“00:00:00” |
| | | LocalDateTime now = LocalDateTimeUtil.nowDateTime(); |
| | | //明天“00:00:00” |
| | | LocalDateTime nextDayFirst = LocalDateTimeUtil.dateTimeAddDay(now, 1L); |
| | | //今天“23:59:59” |
| | | return LocalDateTimeUtil.dateTimeAddSec(nextDayFirst, -1L); |
| | | } |
| | | //************************************** 【LocalDateTime】 ************************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //************************************** 【LocalDate】 ************************************** |
| | | /** |
| | | * 获取当前LocalDate |
| | | */ |
| | | public static LocalDate nowDate() { |
| | | return LocalDate.now(); |
| | | } |
| | | /** |
| | | * 获取当前日期字符串(yyyy-MM-dd) |
| | | */ |
| | | public static String todayStr() { |
| | | return LocalDateTimeUtil.toFormatString(LocalDateTime.now(), ConstantFactory.STR_DATE); |
| | | } |
| | | /** |
| | | * 根据日期字符串获取LocalDate(必须是yyyy-MM-dd格式) |
| | | * @param date 日期字符串 |
| | | */ |
| | | public static LocalDate getDate(String date) { |
| | | if(StringUtil.isNullOrEmpty(date)) { |
| | | return LocalDateTimeUtil.DEFAULT_DATE; |
| | | } |
| | | return LocalDate.parse(date); |
| | | } |
| | | /** |
| | | * 获取LocalDate |
| | | * @param year 年份 |
| | | * @param month 月份 |
| | | * @param day 天 |
| | | */ |
| | | public static LocalDate getDate(Integer year, Integer month, Integer day) { |
| | | return LocalDate.of(year, month, day); |
| | | } |
| | | /** |
| | | * LocalDate偏移指定天数 |
| | | * @param date LocalDate对象 |
| | | * @param addDay 偏移天数(可以为负数) |
| | | */ |
| | | public static LocalDate dateAddDay(LocalDate date, Long addDay) { |
| | | if(null==date) { |
| | | return LocalDateTimeUtil.DEFAULT_DATE; |
| | | } |
| | | return date.plusDays(addDay); |
| | | } |
| | | /** |
| | | * LocalDate偏移指定月数 |
| | | * @param date LocalDate对象 |
| | | * @param addMonth 偏移月数(可以为负数) |
| | | */ |
| | | public static LocalDate dateAddMonth(LocalDate date, Long addMonth) { |
| | | if(null==date) { |
| | | return LocalDateTimeUtil.DEFAULT_DATE; |
| | | } |
| | | return date.plusMonths(addMonth); |
| | | } |
| | | /** |
| | | * 获取当前月份第一天LocalDate |
| | | */ |
| | | public static LocalDate monthFirstDate() { |
| | | LocalDate toDay = nowDate(); |
| | | return LocalDate.of(toDay.getYear(), toDay.getMonthValue(), 1); |
| | | } |
| | | /** |
| | | * 获取当前月份最后一天LocalDate |
| | | */ |
| | | public static LocalDate monthLatestDate() { |
| | | //当前月第一天 |
| | | LocalDate monthFirst = monthFirstDate(); |
| | | //下个月第一天 |
| | | LocalDate nextMonthDay = dateAddMonth(monthFirst, 1L); |
| | | return LocalDateTimeUtil.dateAddDay(nextMonthDay, -1L); |
| | | } |
| | | //************************************** 【LocalDate】 ************************************** |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //************************************** 【时间戳处理】 ************************************** |
| | | /** |
| | | * 获取当前时间戳 |
| | | */ |
| | | public static Long nowTimeStamp() { |
| | | return Instant.now().toEpochMilli(); |
| | | } |
| | | /** |
| | | * 获取当前时间戳(字符串) |
| | | */ |
| | | public static String nowTimeStampStr() { |
| | | return String.valueOf(nowTimeStamp()); |
| | | } |
| | | /** |
| | | * 通过LocalDateTime对象获取时间戳 |
| | | * @param dateTime LocalDateTime对象 |
| | | */ |
| | | public static Timestamp getTimeStamp(LocalDateTime dateTime) { |
| | | if(null==dateTime) { |
| | | return Timestamp.valueOf(LocalDateTimeUtil.DEFAULT_DATETIME); |
| | | } |
| | | return Timestamp.valueOf(dateTime); |
| | | } |
| | | /** |
| | | * 通过时间字符串按指定格式获取时间戳 |
| | | * @param dateTime 时间字符串 |
| | | * @param format 时间格式 |
| | | */ |
| | | public static Timestamp getTimeStamp(String dateTime, String format) { |
| | | LocalDateTime localDateTime = LocalDateTimeUtil.getDateTime(dateTime, format); |
| | | return Timestamp.valueOf(localDateTime); |
| | | } |
| | | /** |
| | | * 通过时间字符串按“yyyy-MM-dd HH:mm:ss”格式获取时间戳 |
| | | * @param dateTime 时间字符串 |
| | | */ |
| | | public static Timestamp getTimeStamp(String dateTime) { |
| | | return LocalDateTimeUtil.getTimeStamp(dateTime, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过Unix时间戳获取Timestamp |
| | | * @param timeStamp Unix时间戳 |
| | | */ |
| | | public static Timestamp getTimeStamp(Long timeStamp) { |
| | | return new Timestamp(timeStamp); |
| | | } |
| | | /** |
| | | * 通过时间戳,按指定格式,转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | * @param format 时间格式 |
| | | */ |
| | | public static String toFormatString(Long timeStamp, String format) { |
| | | LocalDateTime dateTime = LocalDateTimeUtil.getDateTime(timeStamp); |
| | | return LocalDateTimeUtil.toFormatString(dateTime, format); |
| | | } |
| | | /** |
| | | * 通过时间戳,按“yyyy-MM-dd HH:mm:ss”转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | */ |
| | | public static String toFormatString(Long timeStamp) { |
| | | return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | /** |
| | | * 通过时间戳,按“yyyy-MM-dd”转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | */ |
| | | public static String toDateString(Long timeStamp) { |
| | | return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE); |
| | | } |
| | | /** |
| | | * 通过时间戳,按“yyyy-MM-dd HH:mm:ss.SSS”转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | */ |
| | | public static String toFormatFullString(Long timeStamp) { |
| | | return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULLMS); |
| | | } |
| | | /** |
| | | * 通过时间戳,按指定格式,转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | * @param format 时间格式 |
| | | */ |
| | | public static String toFormatString(Timestamp timeStamp, String format) { |
| | | LocalDateTime dateTime = LocalDateTimeUtil.getDateTime(timeStamp); |
| | | return LocalDateTimeUtil.toFormatString(dateTime, format); |
| | | } |
| | | /** |
| | | * 通过时间戳,按“yyyy-MM-dd HH:mm:ss”转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | */ |
| | | public static String toFormatString(Timestamp timeStamp) { |
| | | return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULL); |
| | | } |
| | | /** |
| | | * 通过时间戳,按“yyyy-MM-dd”转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | */ |
| | | public static String toDateString(Timestamp timeStamp) { |
| | | return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE); |
| | | } |
| | | /** |
| | | * 通过时间戳,按“yyyy-MM-dd HH:mm:ss.SSS”转成时间字符串 |
| | | * @param timeStamp 时间戳值 |
| | | */ |
| | | public static String toFormatFullString(Timestamp timeStamp) { |
| | | return LocalDateTimeUtil.toFormatString(timeStamp, ConstantFactory.STR_DATE_FULLMS); |
| | | } |
| | | //************************************** 【时间戳处理】 ************************************** |
| | | |
| | | |
| | | public static String convertToDateFormat(String inputString) { |
| | | try { |
| | | // 将输入字符串解析为日期对象 |
| | | SimpleDateFormat inputFormat = new SimpleDateFormat("yyMMddHHmmss"); |
| | | Date date = inputFormat.parse(inputString); |
| | | |
| | | // 将日期对象格式化为目标日期字符串 |
| | | SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | return outputFormat.format(date); |
| | | } catch (Exception e) { |
| | | return "Invalid Date"; |
| | | } |
| | | } |
| | | |
| | | public static String nowTimeBCD(String timeFormat) { |
| | | return LocalDateTimeUtil.time2BCD(LocalDateTimeUtil.nowDateTime(), timeFormat); |
| | | } |
| | | public static String nowTimeBCD() { |
| | | return LocalDateTimeUtil.time2BCD(LocalDateTimeUtil.nowDateTime()); |
| | | } |
| | | |
| | | public static String time2BCD(LocalDateTime nowDateTime) { |
| | | String timeStr = LocalDateTimeUtil.toFormatString(nowDateTime, ConstantFactory.STR_DATE_FULL); |
| | | return LocalDateTimeUtil.number2BCD(timeStr); |
| | | } |
| | | |
| | | public static String time2BCD(LocalDateTime nowDateTime, String timeFormat) { |
| | | String timeStr = LocalDateTimeUtil.toFormatString(nowDateTime, timeFormat); |
| | | return LocalDateTimeUtil.number2BCD(timeStr); |
| | | } |
| | | |
| | | public static String number2BCD(String numberStr) { |
| | | // 因为可能修改字符串的内容,所以构造StringBuffer |
| | | StringBuffer sb = new StringBuffer(numberStr); |
| | | // 一个字节包含两个4位的BCD码,byte数组中要包含偶数个BCD码 |
| | | // 一个十进制字符对应4位BCD码,所以如果十进制字符串的长度是奇数,要在前面补一个0使长度成为偶数 |
| | | if ((sb.length() % 2) != 0) { |
| | | sb.insert(0, '0'); |
| | | } |
| | | |
| | | // 两个十进制数字转换为BCD码后占用一个字节,所以存放BCD码的字节数等于十进制字符串长度的一半 |
| | | byte[] bcd = new byte[sb.length() / 2]; |
| | | for (int i = 0; i < sb.length();) { |
| | | if (!Character.isDigit(sb.charAt(i)) || !Character.isDigit(sb.charAt(i + 1))) { |
| | | throw new BusinessException("传入的十进制字符串包含非数字字符!"); |
| | | } |
| | | // 每个字节的构成:用两位十进制数字运算的和填充,高位十进制数字左移4位+低位十进制数字 |
| | | bcd[i/2] = (byte)((Character.digit(sb.charAt(i), 10) << 4) + Character.digit(sb.charAt(i + 1), 10)); |
| | | // 字符串的每两个字符取出来一起处理,所以此处i的自增长要加2,而不是加1 |
| | | i += 2; |
| | | } |
| | | StringBuffer sbResult = new StringBuffer(); |
| | | for (int i = 0; i < bcd.length; i++) { |
| | | sbResult.append(Integer.toBinaryString(bcd[i])); |
| | | } |
| | | return sbResult.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import com.fengdu.gas.common.enums.ELogger; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | public class LoggerUtil { |
| | | public static <T> Logger get(Class<T> clazz) { |
| | | return LoggerFactory.getLogger(clazz); |
| | | } |
| | | |
| | | public static Logger get(ELogger logger) { |
| | | return LoggerFactory.getLogger(logger.getLogFileName()); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.mail.*; |
| | | import javax.mail.internet.InternetAddress; |
| | | import javax.mail.internet.MimeMessage; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * 发邮件工具类 |
| | | */ |
| | | @Component |
| | | public final class MailUtils { |
| | | @Value("${spring:mail:username}") |
| | | private String USER; // 发件人邮箱地址 |
| | | @Value("${spring:mail:password}") |
| | | private String PASSWORD; // 如果是qq邮箱可以使户端授权码 |
| | | |
| | | /** |
| | | * 发送邮件 |
| | | * @param to 收件人邮箱 |
| | | * @param text 邮件正文 |
| | | * @param title 标题 |
| | | * mail: |
| | | * password: ennnntqxzijsdjdh |
| | | * username: 2413500195@qq.com |
| | | * host: smtp.qq.com |
| | | * default-encoding: UTF-8 |
| | | */ |
| | | public boolean sendMail(String to, String text, String title){ |
| | | try { |
| | | final Properties props = new Properties(); |
| | | props.put("mail.smtp.auth", "true"); |
| | | props.put("mail.smtp.host", "smtp.qq.com"); |
| | | |
| | | // 发件人的账号 |
| | | props.put("spring:mail:username", USER); |
| | | //发件人的密码 |
| | | props.put("spring:mail:password", PASSWORD); |
| | | |
| | | // 构建授权信息,用于进行SMTP进行身份验证 |
| | | Authenticator authenticator = new Authenticator() { |
| | | @Override |
| | | protected PasswordAuthentication getPasswordAuthentication() { |
| | | // 用户名、密码 |
| | | String userName = props.getProperty("spring:mail:username"); |
| | | String password = props.getProperty("spring:mail:password"); |
| | | return new PasswordAuthentication(userName, password); |
| | | } |
| | | }; |
| | | // 使用环境属性和授权信息,创建邮件会话 |
| | | Session mailSession = Session.getInstance(props, authenticator); |
| | | // 创建邮件消息 |
| | | MimeMessage message = new MimeMessage(mailSession); |
| | | // 设置发件人 |
| | | String username = props.getProperty("spring:mail:username"); |
| | | InternetAddress form = new InternetAddress(username); |
| | | message.setFrom(form); |
| | | |
| | | // 设置收件人 |
| | | InternetAddress toAddress = new InternetAddress(to); |
| | | message.setRecipient(Message.RecipientType.TO, toAddress); |
| | | |
| | | // 设置邮件标题 |
| | | message.setSubject(title); |
| | | |
| | | // 设置邮件的内容体 |
| | | message.setContent(text, "text/html;charset=UTF-8"); |
| | | // 发送邮件 |
| | | Transport.send(message); |
| | | return true; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 金钱计算工具类 |
| | | */ |
| | | |
| | | public class MoneyUtil { |
| | | /** |
| | | * 加法 |
| | | * @param v1 |
| | | * @param v2 |
| | | * @return |
| | | */ |
| | | public static BigDecimal add(BigDecimal v1,BigDecimal v2){ |
| | | if(v1 == null || "".equals(v1)){ |
| | | v1 = new BigDecimal(0); |
| | | }else if(v2 == null || "".equals(v2)){ |
| | | v2 = new BigDecimal(0); |
| | | } |
| | | return v1.add(v2).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 减法 |
| | | * @param v1 |
| | | * @param v2 |
| | | * @return |
| | | */ |
| | | public static BigDecimal subtract(BigDecimal v1,BigDecimal v2){ |
| | | if(v1 == null || "".equals(v1)){ |
| | | v1 = new BigDecimal(0); |
| | | }else if(v2 == null || "".equals(v2)){ |
| | | v2 = new BigDecimal(0); |
| | | } |
| | | return v1.subtract(v2).setScale(2, BigDecimal.ROUND_DOWN); |
| | | } |
| | | |
| | | /** |
| | | * 除法 |
| | | * @param v1 |
| | | * @param v2 |
| | | * @return |
| | | */ |
| | | public static BigDecimal divide(BigDecimal v1,BigDecimal v2){ |
| | | if(v1 == null || "".equals(v1)){ |
| | | v1 = new BigDecimal(0); |
| | | }else if(v2 == null || "".equals(v2)){ |
| | | v2 = new BigDecimal(0); |
| | | } |
| | | // 暂时不算负数的情况 |
| | | int i = v2.compareTo(new BigDecimal(0)); |
| | | if(i == 0){ |
| | | return new BigDecimal(0); |
| | | } |
| | | return v1.divide(v2,2, BigDecimal.ROUND_DOWN); |
| | | } |
| | | |
| | | /** |
| | | * 乘法 |
| | | * @param v1 |
| | | * @param v2 |
| | | * @return |
| | | */ |
| | | |
| | | public static BigDecimal multiply(BigDecimal v1,BigDecimal v2){ |
| | | if(v1 == null || "".equals(v1)){ |
| | | v1 = new BigDecimal(0); |
| | | }else if(v2 == null || "".equals(v2)){ |
| | | v2 = new BigDecimal(0); |
| | | } |
| | | return v1.multiply(v2).setScale(2, BigDecimal.ROUND_DOWN); |
| | | } |
| | | |
| | | // 小于 |
| | | public static boolean lt(BigDecimal v1,BigDecimal v2) { |
| | | return v1.compareTo(v2) == -1; |
| | | } |
| | | |
| | | // 等于 |
| | | public static boolean eq(BigDecimal v1,BigDecimal v2) { |
| | | return v1.compareTo(v2) == 0; |
| | | } |
| | | |
| | | // 大于 |
| | | public static boolean gt(BigDecimal v1,BigDecimal v2) { |
| | | return v1.compareTo(v2) == 1; |
| | | } |
| | | |
| | | // 大于等于 |
| | | public static boolean ge(BigDecimal v1,BigDecimal v2) { |
| | | return v1.compareTo(v2) > -1; |
| | | } |
| | | |
| | | // 小于等于 |
| | | public static boolean le(BigDecimal v1,BigDecimal v2) { |
| | | return v1.compareTo(v2) < 1; |
| | | } |
| | | |
| | | /** |
| | | * 换算积分 |
| | | * @param money |
| | | * @return |
| | | */ |
| | | public static Integer integral(BigDecimal money){ |
| | | Integer integer=money.intValue()/10; |
| | | return integer; |
| | | } |
| | | |
| | | // public static void main(String [] args){ |
| | | // //加法 |
| | | // BigDecimal jia=add(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); |
| | | // System.out.println("加法:"+jia); |
| | | // //减法 |
| | | // BigDecimal jian=subtract(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); |
| | | // System.out.println("减法:"+jian); |
| | | // //乘法 |
| | | // BigDecimal chen=multiply(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); |
| | | // System.out.println("乘法:"+chen); |
| | | // //除法 |
| | | // BigDecimal chu=divide(BigDecimal.valueOf(5.66),BigDecimal.valueOf(3.347)); |
| | | // System.out.println("积分:"+integral(BigDecimal.valueOf(101.88))); |
| | | // } |
| | | |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | |
| | | /** |
| | | * 数值处理类 |
| | | * @author linliu |
| | | * @date 2018-12-28 |
| | | */ |
| | | public final class NumericUtil { |
| | | private NumericUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 验证数值为空 |
| | | * @param num 传入数值 |
| | | */ |
| | | public static Boolean isNullOrEmpty(Number num) { |
| | | return num==null || num.doubleValue()==0; |
| | | } |
| | | |
| | | /** |
| | | * 验证数值非空 |
| | | * @param num 传入数值 |
| | | */ |
| | | public static Boolean isNotNullOrEmpty(Number num) { |
| | | return !NumericUtil.isNullOrEmpty(num); |
| | | } |
| | | |
| | | /** |
| | | * 判断传入值,是否在传入数组中 |
| | | * @param num 比较值 |
| | | * @param array 范围数组 |
| | | */ |
| | | public static Boolean includeIn(Number num, Number... array) { |
| | | return ListUtil.toList(array).contains(num); |
| | | } |
| | | |
| | | /** |
| | | * 字符串枚举值转成枚举对象 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param enumType 枚举类型 |
| | | * @param value 枚举值 |
| | | * @param <T> 枚举类型 |
| | | * @return 枚举对象 |
| | | */ |
| | | public static <T extends Enum<T>> T parseEnum(Class<T> enumType, Integer value) { |
| | | if(null == value) { |
| | | return null; |
| | | } |
| | | |
| | | T result = null; |
| | | try { |
| | | T[] values = enumType.getEnumConstants(); |
| | | Method getValue = enumType.getMethod("getValue"); |
| | | |
| | | for (T e : values) { |
| | | if(getValue.invoke(e).equals(value)) { |
| | | result = e; |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 判断枚举是否申明了传入枚举值 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param enumType 枚举类型 |
| | | * @param value 枚举值 |
| | | * @param <T> 枚举类型 |
| | | * @return 是否包含 |
| | | */ |
| | | public static <T extends Enum<T>> boolean isEnum(Class<T> enumType, Integer value) { |
| | | return (null != NumericUtil.parseEnum(enumType, value)); |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 Integer |
| | | * @param value 传入值 |
| | | */ |
| | | public static Integer tryParseInt(Object value) { |
| | | return NumericUtil.tryParseInt(value, Integer.MIN_VALUE); |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 Long |
| | | * @param value 传入值 |
| | | */ |
| | | public static Long tryParseLong(Object value) { |
| | | return NumericUtil.tryParseLong(value, Long.MIN_VALUE); |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 Double |
| | | * @param value 传入值 |
| | | */ |
| | | public static Double tryParseDouble(Object value) { |
| | | return NumericUtil.tryParseDouble(value, Double.valueOf(String.valueOf(Long.MIN_VALUE))); |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 BigDecimal |
| | | * @param value 传入值 |
| | | */ |
| | | public static BigDecimal tryParseBigDecimal(Object value) { |
| | | return NumericUtil.tryParseBigDecimal(value, new BigDecimal(String.valueOf(Long.MIN_VALUE))); |
| | | } |
| | | |
| | | /** |
| | | * 输出数值补“0”,不输出小数部分(如果传入数值位数不足传入最小位数,则在数值前补“0”,否则直接输出数值的字符串) |
| | | * @param value 传入数值 |
| | | * @param minLength 最小位数 |
| | | */ |
| | | public static String toDString(Number value, Integer minLength) { |
| | | String result = toNumberString(value, 0); |
| | | StringBuilder sb = new StringBuilder(); |
| | | while (result.length()+sb.length() < minLength) { |
| | | sb.append("0"); |
| | | } |
| | | sb.append(result); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 判断传入数值大小是否在“min”和“max”之间(不包含包含端值,即包含最大最小值) |
| | | * @param num 比较的数值 |
| | | * @param min 最小值 |
| | | * @param max 最大值 |
| | | */ |
| | | public static Boolean isInRange(Number num, Number min, Number max) { |
| | | BigDecimal dnum = tryParseBigDecimal(num); |
| | | BigDecimal dmin = tryParseBigDecimal(min); |
| | | BigDecimal dmax = tryParseBigDecimal(max); |
| | | return dnum.compareTo(dmin)>0 && dnum.compareTo(dmax)<0; |
| | | } |
| | | |
| | | /** |
| | | * 判断传入数值大小是否在“min”和“max”之间(包含端值,即包含最大最小值) |
| | | * @param num 比较的数值 |
| | | * @param min 最小值 |
| | | * @param max 最大值 |
| | | */ |
| | | public static Boolean isInRangeInclude(Number num, Number min, Number max) { |
| | | BigDecimal dnum = tryParseBigDecimal(num); |
| | | BigDecimal dmin = tryParseBigDecimal(min); |
| | | BigDecimal dmax = tryParseBigDecimal(max); |
| | | return dnum.compareTo(dmin)>-1 && dnum.compareTo(dmax)<1; |
| | | } |
| | | |
| | | /** |
| | | * 格式化输出小数(最多“length”位小数,如果小数部分某位后面全是0,则不展示) |
| | | * @param num 数字 |
| | | * @param length 最多展示的小数位数 |
| | | */ |
| | | public static String toNumberString(Number num, Integer length) { |
| | | length = tryParseInt(length); |
| | | StringBuilder sbFormat = new StringBuilder("#0"); |
| | | if(length.compareTo(0) > 0) { |
| | | sbFormat.append("."); |
| | | for(int i=0; i<length; i++) { |
| | | sbFormat.append("#"); |
| | | } |
| | | } |
| | | DecimalFormat df = new DecimalFormat(sbFormat.toString()); |
| | | return df.format(num); |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 Integer |
| | | * @param value 传入值 |
| | | * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 |
| | | */ |
| | | public static Integer tryParseInt(Object value, Integer defaultValue) { |
| | | if(null==value) { |
| | | return defaultValue; |
| | | } |
| | | try { |
| | | return Integer.parseInt(String.valueOf(value)); |
| | | } catch (Exception e) { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 Long |
| | | * @param value 传入值 |
| | | * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 |
| | | */ |
| | | public static Long tryParseLong(Object value, Long defaultValue) { |
| | | if(null==value) { |
| | | return defaultValue; |
| | | } |
| | | try { |
| | | return Long.parseLong(String.valueOf(value)); |
| | | } catch (Exception e) { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 Double |
| | | * @param value 传入值 |
| | | * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 |
| | | */ |
| | | public static Double tryParseDouble(Object value, Double defaultValue) { |
| | | if(null==value) { |
| | | return defaultValue; |
| | | } |
| | | try { |
| | | return Double.parseDouble(String.valueOf(value)); |
| | | } catch (Exception e) { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 尝试转换为 BigDecimal |
| | | * @param value 传入值 |
| | | * @param defaultValue 传入值为空,或者转换失败时,返回的默认值 |
| | | */ |
| | | public static BigDecimal tryParseBigDecimal(Object value, BigDecimal defaultValue) { |
| | | if(null==value) { |
| | | return defaultValue; |
| | | } |
| | | try { |
| | | return new BigDecimal(String.valueOf(value)); |
| | | } catch (Exception e) { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | public class OrderUtil { |
| | | |
| | | public static String getOrderNo(String prefix) { |
| | | SnowFlake idWorker = new SnowFlake(7, 7); |
| | | long id = idWorker.nextId(); |
| | | String rechargeOrder = prefix + id; |
| | | return rechargeOrder; |
| | | } |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import com.fengdu.gas.common.model.Tuple; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | public class ParameterUtil { |
| | | public static String named(String name) { |
| | | return "参数“" + name + "”"; |
| | | } |
| | | |
| | | public static String sqlASC(String name) { |
| | | return name + ConstantFactory.SQL_ASC; |
| | | } |
| | | |
| | | public static String sqlDESC(String name) { |
| | | return name + ConstantFactory.SQL_DESC; |
| | | } |
| | | |
| | | public static String sqlLikeValue(String value) { |
| | | return "%" + value + "%"; |
| | | } |
| | | |
| | | public static String dealNull(String parameter) { |
| | | if(StringUtil.isNullOrEmpty(parameter)) { |
| | | return ""; |
| | | } |
| | | return parameter.trim().replaceAll("\\t", "").replaceAll("\\r", "").replaceAll("\\n", ""); |
| | | } |
| | | |
| | | public static String dealNullStr(Object parameter, String defaultValue) { |
| | | if(Objects.isNull(parameter) || StringUtil.isNullOrEmpty(parameter.toString())) { |
| | | return defaultValue; |
| | | } |
| | | return parameter.toString(); |
| | | } |
| | | |
| | | public static String dealNullStr(Object parameter) { |
| | | return ParameterUtil.dealNullStr(parameter, ""); |
| | | } |
| | | |
| | | public static <T> List<T> dealNull(List<T> list) { |
| | | if(null == list) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public static String dealNotStr(String parameter) { |
| | | if(null == parameter) { |
| | | return parameter; |
| | | } |
| | | return parameter.trim().replaceAll("\\t", "").replaceAll("\\r", "").replaceAll("\\n", ""); |
| | | } |
| | | |
| | | public static Tuple<String, String> getTimeRange(String timeRange) { |
| | | if (StringUtil.isNullOrEmpty(timeRange)) { |
| | | return new Tuple<>("", ""); |
| | | } |
| | | String[] list = StringUtil.split(timeRange, ConstantFactory.STR_TIME_RANGE); |
| | | if (list.length != 2) { |
| | | return new Tuple<>("", ""); |
| | | } |
| | | return new Tuple<>(list[0], list[1]); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import net.sourceforge.pinyin4j.PinyinHelper; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; |
| | | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; |
| | | |
| | | public final class PinYinUtil { |
| | | private PinYinUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 获取中文全拼 |
| | | * |
| | | * @param name 需要转换的中文 |
| | | * @return 全拼结果 |
| | | **/ |
| | | public static String getFullPinyin(String name) { |
| | | // 创建格式化对象 |
| | | HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); |
| | | //设置大小写格式 |
| | | outputFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); |
| | | //设置声调格式 |
| | | outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
| | | // 放置输入结果 |
| | | StringBuilder result = new StringBuilder(); |
| | | // 字符数组 |
| | | char[] charArray = name.toCharArray(); |
| | | // 遍历字符 |
| | | for (char c : charArray) { |
| | | // 中文会被变成全拼,非中文会被直接拼接在结果字符串中 |
| | | if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) { |
| | | String[] pinyinArray = new String[0]; |
| | | try { |
| | | pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, outputFormat); |
| | | } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { |
| | | badHanyuPinyinOutputFormatCombination.printStackTrace(); |
| | | } |
| | | if (pinyinArray != null) { |
| | | result.append(pinyinArray[0]); |
| | | } |
| | | } else { |
| | | result.append(c); |
| | | } |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 获取中文首字母 |
| | | * |
| | | * @param name 需要转换的中文 |
| | | * @return 首字母结果 |
| | | **/ |
| | | public static String getPinyinInitial(String name) { |
| | | // 创建格式化对象 |
| | | HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); |
| | | //设置大小写格式 |
| | | outputFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE); |
| | | //设置声调格式 |
| | | outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
| | | // 放置输入结果 |
| | | StringBuilder result = new StringBuilder(); |
| | | // 字符数组 |
| | | char[] charArray = name.toCharArray(); |
| | | // 遍历字符 |
| | | for (char c : charArray) { |
| | | // 中文会被变成拼音首字母,非中文会被直接拼接在结果字符串中 |
| | | if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) { |
| | | String[] pinyinArray = new String[0]; |
| | | try { |
| | | pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, outputFormat); |
| | | } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { |
| | | badHanyuPinyinOutputFormatCombination.printStackTrace(); |
| | | } |
| | | if (pinyinArray != null) { |
| | | result.append(pinyinArray[0].charAt(0)); |
| | | } |
| | | } else { |
| | | result.append(c); |
| | | } |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * 随机验证码 工具类 |
| | | */ |
| | | public final class RandVerifyCode { |
| | | public static final Integer USE_ZERO = 1; |
| | | public static final Integer USE_O = 2; |
| | | public static final Integer USE_ONE = 1; |
| | | public static final Integer USE_I = 2; |
| | | |
| | | static char[] arrayCharCode = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; |
| | | static char[] arrayComplexCode = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; |
| | | |
| | | private RandVerifyCode() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 生成随机数字 |
| | | * @param length 生成长度 |
| | | */ |
| | | public static String numberCode(int length) { |
| | | try { |
| | | Thread.sleep(Long.valueOf("1")); |
| | | } catch (Exception e) { |
| | | e.getStackTrace(); |
| | | } |
| | | Random random = new Random(CalendarUtil.nowTimestamp()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < length; i++) { |
| | | try { |
| | | Thread.sleep(Long.valueOf("1")); |
| | | } catch (Exception e) {} |
| | | sb.append(random.nextInt(Integer.valueOf("10"))); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 生成随机字母与数字 |
| | | * @param length 生成长度 |
| | | */ |
| | | public static String complexCode(int length) { |
| | | return complexCode(length, 2, 2); |
| | | } |
| | | |
| | | /** |
| | | * 生成随机字母与数字 |
| | | * @param length 生成长度 |
| | | * @param zeroOrO 为避免视觉歧义,数字零“0”和字母欧“O”如何取舍。取数字零=1,取字母欧=2 |
| | | * @param oneOrI 为避免视觉歧义,数字一“1”和字母艾“I”如何取舍。取数字一=1,取字母艾=2 |
| | | */ |
| | | public static String complexCode(int length, Integer zeroOrO, Integer oneOrI) { |
| | | int n = arrayComplexCode.length; |
| | | try { |
| | | Thread.sleep(Long.valueOf("1")); |
| | | } catch (Exception e) { |
| | | e.getStackTrace(); |
| | | } |
| | | Random random = new Random(CalendarUtil.nowTimestamp()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < length; i++) { |
| | | int rnd = random.nextInt(n); |
| | | char code = arrayComplexCode[rnd]; |
| | | if('O'==code && USE_ZERO.equals(zeroOrO)) { |
| | | code = '0'; |
| | | } else if('0'==code && USE_O.equals(zeroOrO)) { |
| | | code = 'O'; |
| | | } |
| | | |
| | | if('I'==code && USE_ONE.equals(oneOrI)) { |
| | | code = '1'; |
| | | } else if('1'==code && USE_I.equals(oneOrI)) { |
| | | code = 'I'; |
| | | } |
| | | sb.append(code); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 生成随机纯字母随机数 |
| | | * @param length 生成长度 |
| | | */ |
| | | public static String charCode(int length) { |
| | | int n = arrayCharCode.length; |
| | | try { |
| | | Thread.sleep(Long.valueOf("1")); |
| | | } catch (Exception e) { |
| | | e.getStackTrace(); |
| | | } |
| | | Random random = new Random(CalendarUtil.nowTimestamp()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < length; i++) { |
| | | int rnd = random.nextInt(n); |
| | | sb.append(arrayCharCode[rnd]); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import org.bouncycastle.crypto.CipherParameters; |
| | | import org.bouncycastle.crypto.params.ECPrivateKeyParameters; |
| | | import org.bouncycastle.crypto.params.ECPublicKeyParameters; |
| | | import org.bouncycastle.crypto.params.ParametersWithRandom; |
| | | import org.bouncycastle.crypto.signers.SM2Signer; |
| | | import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; |
| | | import org.bouncycastle.jce.provider.BouncyCastleProvider; |
| | | import org.springframework.util.Base64Utils; |
| | | |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.*; |
| | | import java.security.spec.*; |
| | | |
| | | public class SM2Util { |
| | | /** |
| | | * 要生成的EC域参数的标准名称 |
| | | */ |
| | | private static final String STANDARD_NAME = "sm2p256v1"; |
| | | /** |
| | | * 算法 |
| | | */ |
| | | private static final String ALGORITHM = "EC"; |
| | | /** |
| | | * 字符编码 |
| | | */ |
| | | private static final Charset CHARSET = StandardCharsets.UTF_8; |
| | | |
| | | /** |
| | | * 生成密钥对 |
| | | * |
| | | * @return 密钥对 |
| | | */ |
| | | private static KeyPair generateSm2KeyPair() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { |
| | | //使用标准名称创建EC参数生成的参数规范 |
| | | final ECGenParameterSpec sm2Spec = new ECGenParameterSpec(STANDARD_NAME); |
| | | |
| | | // 获取一个椭圆曲线类型的密钥对生成器 |
| | | final KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGORITHM, new BouncyCastleProvider()); |
| | | |
| | | kpg.initialize(sm2Spec, new SecureRandom()); |
| | | // 通过密钥生成器生成密钥对 |
| | | return kpg.generateKeyPair(); |
| | | } |
| | | |
| | | /** |
| | | * 生成密钥对 |
| | | * |
| | | * @return 密钥对 |
| | | */ |
| | | public static String[] genKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException { |
| | | KeyPair keyPair = generateSm2KeyPair(); |
| | | PrivateKey privateKey = keyPair.getPrivate(); |
| | | PublicKey publicKey = keyPair.getPublic(); |
| | | return new String[]{ |
| | | Base64Utils.encodeToString(privateKey.getEncoded()), |
| | | Base64Utils.encodeToString(publicKey.getEncoded()) |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * 私钥转换为 {@link ECPrivateKeyParameters} |
| | | * |
| | | * @param key 私钥 |
| | | * @return 私钥{@link ECPrivateKeyParameters} |
| | | */ |
| | | private static ECPrivateKeyParameters privateKeyToParams(byte[] key) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException { |
| | | KeySpec keySpec = new PKCS8EncodedKeySpec(key); |
| | | PrivateKey privateKey = getKeyFactory().generatePrivate(keySpec); |
| | | ; |
| | | return (ECPrivateKeyParameters) ECUtil.generatePrivateKeyParameter(privateKey); |
| | | } |
| | | |
| | | /** |
| | | * 公钥转换为 {@link ECPublicKeyParameters} |
| | | * |
| | | * @param key 公钥 |
| | | * @return 公钥{@link ECPublicKeyParameters} |
| | | */ |
| | | private static ECPublicKeyParameters publicKeyToParams(byte[] key) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException { |
| | | KeySpec keySpec = new X509EncodedKeySpec(key); |
| | | PublicKey publicKey = getKeyFactory().generatePublic(keySpec); |
| | | return (ECPublicKeyParameters) ECUtil.generatePublicKeyParameter(publicKey); |
| | | } |
| | | |
| | | /** |
| | | * 获取{@link KeyFactory} |
| | | * |
| | | * @return {@link KeyFactory} |
| | | */ |
| | | private static KeyFactory getKeyFactory() throws NoSuchAlgorithmException { |
| | | final Provider provider = new BouncyCastleProvider(); |
| | | return KeyFactory.getInstance(ALGORITHM, provider); |
| | | } |
| | | |
| | | /** |
| | | * 签名 |
| | | * |
| | | * @param content 原始串 |
| | | * @param priKey 私钥 |
| | | * @return 签名 |
| | | */ |
| | | public static String sign(String content, String priKey) throws Exception { |
| | | byte[] data = content.getBytes(CHARSET); |
| | | byte[] privateKey = Base64Utils.decode(priKey.getBytes(CHARSET)); |
| | | |
| | | SM2Signer signer = new SM2Signer(); |
| | | CipherParameters param = new ParametersWithRandom(privateKeyToParams(privateKey)); |
| | | signer.init(true, param); |
| | | signer.update(data, 0, data.length); |
| | | |
| | | byte[] buffer = signer.generateSignature(); |
| | | |
| | | return Base64Utils.encodeToString(buffer); |
| | | } |
| | | |
| | | /** |
| | | * 用公钥检验数字签名的合法性 |
| | | * |
| | | * @param content 原始串 |
| | | * @param sign 待验证签名 |
| | | * @param publicKey 私钥 |
| | | * @return 是否验证通过 |
| | | */ |
| | | public static boolean verify(String content, String sign, String publicKey) throws Exception { |
| | | byte[] data = content.getBytes(CHARSET); |
| | | byte[] signBuffer = Base64Utils.decodeFromString(sign); |
| | | byte[] keyBuffer = Base64Utils.decodeFromString(publicKey); |
| | | |
| | | SM2Signer signer = new SM2Signer(); |
| | | CipherParameters param = publicKeyToParams(keyBuffer); |
| | | signer.init(false, param); |
| | | signer.update(data, 0, data.length); |
| | | return signer.verifySignature(signBuffer); |
| | | } |
| | | |
| | | |
| | | |
| | | // public static void main(String[] args) { |
| | | // Security.addProvider(new BouncyCastleProvider()); |
| | | // |
| | | // try { |
| | | // // 生成密钥对 |
| | | // String[] keyPair = SM2Util.genKeyPair(); |
| | | // String privateKey = keyPair[0]; |
| | | // String publicKey = keyPair[1]; |
| | | // |
| | | // // 对消息进行签名 |
| | | // String message = "你好,世界!"; |
| | | // String signature = SM2Util.sign(message, privateKey); |
| | | // System.out.println("生成的签名: " + signature); |
| | | // |
| | | // // 验证签名 |
| | | // boolean isValid = SM2Util.verify(message, signature, publicKey); |
| | | // System.out.println("签名验证结果: " + isValid); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | |
| | | import org.springframework.util.Base64Utils; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.spec.IvParameterSpec; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Random; |
| | | |
| | | public class SM4Util { |
| | | /** |
| | | * 算法名字 |
| | | */ |
| | | private static final String NAME = "SM4"; |
| | | /** |
| | | * 加密模式以及短快填充方式 |
| | | */ |
| | | private static final String ALGORITHM = "SM4/CBC/PKCS5Padding"; |
| | | /** |
| | | * 加密使用的初始向量 |
| | | */ |
| | | private static final String IV = "0000000000000000"; |
| | | /** |
| | | * 密钥长度(128-32位16进制;256-64位16进制) |
| | | */ |
| | | private static final int KEY_SIZE = 16; |
| | | |
| | | private static final String ALL_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| | | |
| | | public static String generateKey() { |
| | | Random random = new Random(); |
| | | StringBuffer sb = new StringBuffer(); |
| | | for (int i = 0; i < KEY_SIZE; i++) { |
| | | int number = random.nextInt(ALL_STR.length()); |
| | | sb.append(ALL_STR.charAt(number)); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 使用指定的加密算法和密钥对给定的字节数组进行加密 |
| | | * |
| | | * @param content 待加密的原始字符串 |
| | | * @param key 密钥(注意必须是128bits,即16个字节) |
| | | * @return 加密后的字符串 |
| | | * @throws Exception 如果加密时发生错误,则抛出异常 |
| | | */ |
| | | public static String encode(String content, String key) throws Exception { |
| | | try { |
| | | byte[] inputByte = content.getBytes(StandardCharsets.UTF_8); |
| | | byte[] keyBuffer = key.getBytes(StandardCharsets.UTF_8); |
| | | |
| | | // 获取加密实例 |
| | | Cipher c = Cipher.getInstance(ALGORITHM); |
| | | // 根据密钥的字节数组创建 SecretKeySpec |
| | | SecretKeySpec secretKeySpec = new SecretKeySpec(keyBuffer, NAME); |
| | | // 创建 IvParameterSpec 对象,使用默认向量和字符集 |
| | | IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes(StandardCharsets.UTF_8)); |
| | | // 初始化加密实例 |
| | | c.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec); |
| | | // 返回加密后的字节数组 |
| | | byte[] buffer = c.doFinal(inputByte); |
| | | return Base64Utils.encodeToString(buffer); |
| | | } catch (Exception e) { |
| | | throw new Exception("加密失败: " + e, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 解密 |
| | | * |
| | | * @param content 待解密字符串 |
| | | * @param key 密钥(注意必须是128bits,即16个字节) |
| | | * @return 解密后的原始字符串 |
| | | * @throws Exception 如果解密时发生错误,则抛出异常 |
| | | */ |
| | | public static String decode(String content, String key) throws Exception { |
| | | try { |
| | | byte[] inputBytes = Base64Utils.decode(content.getBytes(StandardCharsets.UTF_8)); |
| | | byte[] keyBuffer = key.getBytes(StandardCharsets.UTF_8); |
| | | Cipher cipher = Cipher.getInstance(ALGORITHM); |
| | | SecretKeySpec secretKeySpec = new SecretKeySpec(keyBuffer, NAME); |
| | | IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes(StandardCharsets.UTF_8)); |
| | | cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); |
| | | byte[] buffer = cipher.doFinal(inputBytes); |
| | | return new String(buffer, StandardCharsets.UTF_8); |
| | | } catch (Exception e) { |
| | | throw new Exception("解密失败: " + e, e); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.*; |
| | | import com.fasterxml.jackson.databind.module.SimpleModule; |
| | | import com.fasterxml.jackson.dataformat.xml.PackageVersion; |
| | | import com.fasterxml.jackson.dataformat.xml.XmlMapper; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonArray; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.JsonParser; |
| | | import com.fengdu.gas.common.serializer.*; |
| | | import com.fengdu.gas.common.serializer.deserializer.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * json/XML处理类 |
| | | * @author linliu |
| | | * @date 2018-12-28 |
| | | */ |
| | | public final class SerializeUtil { |
| | | private SerializeUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | //region 字符串常量 |
| | | private static final String TITLE = "SerializeUtil"; |
| | | //endregion |
| | | |
| | | private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); |
| | | private static final XmlMapper XML_MAPPER = new XmlMapper(); |
| | | |
| | | static { |
| | | //忽略字段大小写 |
| | | XML_MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); |
| | | //忽略字段数量不一致 |
| | | XML_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| | | |
| | | //默认json序列化设置 |
| | | SerializeUtil.initSerializationConfigure(JSON_MAPPER); |
| | | } |
| | | /** |
| | | * 默认json序列化设置 |
| | | * @param JSON_MAPPER mapper实例 |
| | | */ |
| | | private static void initSerializationConfigure(ObjectMapper JSON_MAPPER) { |
| | | //忽略字段大小写 |
| | | JSON_MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); |
| | | |
| | | //此配置反序列化的时候如果多了属性, 不抛出异常。不设置这个json字符串只能少属性,不能多属性,否者会抛异常 |
| | | JSON_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| | | |
| | | //如果是空对象的时候,不抛异常 |
| | | JSON_MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); |
| | | |
| | | //******************************* 处理日期类型序列化和反序列化 ******************************* |
| | | |
| | | //取消时间的转化格式,默认是时间戳,可以取消,同时需要设置要表现的时间格式 |
| | | JSON_MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); |
| | | |
| | | SimpleModule serializerModule = new SimpleModule("CQDateTimeSerializer", PackageVersion.VERSION); |
| | | |
| | | serializerModule.addSerializer(Date.class, new CQDateSerializer()); |
| | | serializerModule.addDeserializer(Date.class, new CQDateDeSerializer()); |
| | | |
| | | serializerModule.addSerializer(Calendar.class, new CQCalendarSerializer()); |
| | | serializerModule.addDeserializer(Calendar.class, new CQCalendarDeSerializer()); |
| | | |
| | | serializerModule.addSerializer(LocalDate.class, new CQLocalDateSerializer()); |
| | | serializerModule.addDeserializer(LocalDate.class, new CQLocalDateDeSerializer()); |
| | | |
| | | serializerModule.addSerializer(LocalDateTime.class, new CQLocalDateTimeSerializer()); |
| | | serializerModule.addDeserializer(LocalDateTime.class, new CQLocalDateTimeDeSerializer()); |
| | | |
| | | serializerModule.addSerializer(Timestamp.class, new CQTimestampSerializer()); |
| | | serializerModule.addDeserializer(Timestamp.class, new CQTimestampDeSerializer()); |
| | | |
| | | JSON_MAPPER.registerModule(serializerModule); |
| | | //******************************* 处理日期类型序列化和反序列化 ******************************* |
| | | |
| | | /* |
| | | |
| | | //序列化的时候序列对象的所有属性 |
| | | JSON_MAPPER.setSerializationInclusion(JsonInclude.Include.ALWAYS); |
| | | |
| | | */ |
| | | } |
| | | |
| | | /** |
| | | * json字符串转 T 类型实体 |
| | | * @param json json字符串 |
| | | * @param clazz 实体类型 |
| | | * @param <T> 实体类型 |
| | | */ |
| | | public static <T> T toObject(String json, Class<T> clazz) { |
| | | if(StringUtil.isNullOrEmpty(json)){ |
| | | return null; |
| | | } |
| | | try { |
| | | if(Objects.equals(clazz, JsonObject.class)) { |
| | | JsonParser jsonParser = new JsonParser(); |
| | | return (T)jsonParser.parse(json).getAsJsonObject(); |
| | | } |
| | | return JSON_MAPPER.readValue(json, clazz); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * json字符串转 List→T 类型集合 |
| | | * @param json json字符串 |
| | | * @param clazz 实体类型 |
| | | * @param <T> 实体类型 |
| | | */ |
| | | public static <T> List<T> toListObject(String json, Class<T> clazz){ |
| | | if(StringUtil.isNullOrEmpty(json)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | try{ |
| | | //这种返回的是List<LinkedMap> |
| | | //return JSON_MAPPER.readValue(json, new TypeReference<List<T>>() {}); |
| | | return SerializeUtil.toObject(json, List.class, clazz); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * json字符串转 T 类型实体 |
| | | * @param json json字符串 |
| | | * @param genericClass 实体类型 |
| | | * @param clazz 实体类型 |
| | | * @param <T> 实体类型 |
| | | */ |
| | | public static <T> T toObject(String json, Class<?> genericClass, Class<?> clazz) { |
| | | if(StringUtil.isNullOrEmpty(json)){ |
| | | return null; |
| | | } |
| | | try { |
| | | JavaType type = JSON_MAPPER.getTypeFactory().constructParametricType(genericClass, clazz); |
| | | return JSON_MAPPER.readValue(json, type); |
| | | } catch (IOException e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static String toJson(Object obj) { |
| | | if(obj==null){ |
| | | return null; |
| | | } |
| | | try { |
| | | if(obj instanceof JsonObject || obj instanceof JsonArray) { |
| | | return obj.toString(); |
| | | } else { |
| | | return JSON_MAPPER.writeValueAsString(obj); |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | public static String toJsonWithoutNull(Object obj) { |
| | | if(obj==null){ |
| | | return null; |
| | | } |
| | | try { |
| | | if (obj instanceof JsonObject || obj instanceof JsonArray) { |
| | | return obj.toString(); |
| | | } else { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | //默认json序列化设置 |
| | | SerializeUtil.initSerializationConfigure(mapper); |
| | | mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); |
| | | return mapper.writeValueAsString(obj); |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static String toCSharpJson(Object obj) { |
| | | if(obj==null){ |
| | | return null; |
| | | } |
| | | try { |
| | | if (obj instanceof JsonObject || obj instanceof JsonArray) { |
| | | return obj.toString(); |
| | | } else { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | //默认json序列化设置 |
| | | SerializeUtil.initSerializationConfigure(mapper); |
| | | // deprecated mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); |
| | | mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); |
| | | return mapper.writeValueAsString(obj); |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static String toJson(Object obj, String dateFormat) { |
| | | if(obj==null){ |
| | | return null; |
| | | } |
| | | try { |
| | | if (obj instanceof JsonObject || obj instanceof JsonArray) { |
| | | return obj.toString(); |
| | | } else { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | //默认json序列化设置 |
| | | SerializeUtil.initSerializationConfigure(mapper); |
| | | mapper.setDateFormat(new SimpleDateFormat(dateFormat)); |
| | | return mapper.writeValueAsString(obj); |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static <T> T fromXml(String xml, Class<T> clazz) { |
| | | if(StringUtil.isNullOrEmpty(xml)){ |
| | | return null; |
| | | } |
| | | try { |
| | | return XML_MAPPER.readValue(xml, clazz); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static <T> T fromXml(String xml, Class<?> genericClass, Class<?> clazz) { |
| | | if(StringUtil.isNullOrEmpty(xml)){ |
| | | return null; |
| | | } |
| | | try { |
| | | JavaType type = XML_MAPPER.getTypeFactory().constructParametricType(genericClass, clazz); |
| | | return XML_MAPPER.readValue(xml, type); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static String toXml(Object obj) { |
| | | if(obj == null){ |
| | | return ""; |
| | | } |
| | | try{ |
| | | return XML_MAPPER.writeValueAsString(obj); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static JsonObject toJSONObject(Object obj) { |
| | | if(null==obj) { |
| | | return null; |
| | | } |
| | | try { |
| | | String json = new Gson().toJson(obj); |
| | | return new JsonParser().parse(json).getAsJsonObject(); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | |
| | | /** |
| | | * |
| | | * |
| | | * 生成唯一id |
| | | * |
| | | * |
| | | * Twitter_Snowflake<br> |
| | | * SnowFlake的结构如下(每部分用-分开):<br> |
| | | * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br> |
| | | * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br> |
| | | * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截) |
| | | * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br> |
| | | * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br> |
| | | * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br> |
| | | * 加起来刚好64位,为一个Long型。<br> |
| | | * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。 |
| | | * |
| | | * @author Lucifer |
| | | */ |
| | | public class SnowFlake { |
| | | |
| | | // ==============================Fields=========================================== |
| | | /** |
| | | * 开始时间截 (2018-07-03) |
| | | */ |
| | | |
| | | private final long twepoch = 1530607760000L; |
| | | |
| | | /** |
| | | * 机器id所占的位数 |
| | | */ |
| | | private final long workerIdBits = 5L; |
| | | |
| | | /** |
| | | * 数据标识id所占的位数 |
| | | */ |
| | | private final long datacenterIdBits = 5L; |
| | | |
| | | /** |
| | | * 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) |
| | | */ |
| | | private final long maxWorkerId = -1L ^ (-1L << workerIdBits); |
| | | |
| | | /** |
| | | * 支持的最大数据标识id,结果是31 |
| | | */ |
| | | private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); |
| | | |
| | | /** |
| | | * 序列在id中占的位数 |
| | | */ |
| | | private final long sequenceBits = 12L; |
| | | |
| | | /** |
| | | * 机器ID向左移12位 |
| | | */ |
| | | private final long workerIdShift = sequenceBits; |
| | | |
| | | /** |
| | | * 数据标识id向左移17位(12+5) |
| | | */ |
| | | private final long datacenterIdShift = sequenceBits + workerIdBits; |
| | | |
| | | /** |
| | | * 时间截向左移22位(5+5+12) |
| | | */ |
| | | private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; |
| | | |
| | | /** |
| | | * 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) |
| | | */ |
| | | private final long sequenceMask = -1L ^ (-1L << sequenceBits); |
| | | |
| | | /** |
| | | * 工作机器ID(0~31) |
| | | */ |
| | | private long workerId; |
| | | |
| | | /** |
| | | * 数据中心ID(0~31) |
| | | */ |
| | | private long datacenterId; |
| | | |
| | | /** |
| | | * 毫秒内序列(0~4095) |
| | | */ |
| | | private long sequence = 0L; |
| | | |
| | | /** |
| | | * 上次生成ID的时间截 |
| | | */ |
| | | private long lastTimestamp = -1L; |
| | | |
| | | //==============================Constructors===================================== |
| | | |
| | | /** |
| | | * 构造函数 |
| | | * |
| | | * @param workerId 工作ID (0~31) |
| | | * @param datacenterId 数据中心ID (0~31) |
| | | */ |
| | | public SnowFlake(long workerId, long datacenterId) { |
| | | if (workerId > maxWorkerId || workerId < 0) { |
| | | throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); |
| | | } |
| | | if (datacenterId > maxDatacenterId || datacenterId < 0) { |
| | | throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); |
| | | } |
| | | this.workerId = workerId; |
| | | this.datacenterId = datacenterId; |
| | | } |
| | | |
| | | // ==============================Methods========================================== |
| | | |
| | | /** |
| | | * 获得下一个ID (该方法是线程安全的) |
| | | * |
| | | * @return SnowflakeId |
| | | */ |
| | | public synchronized long nextId() { |
| | | long timestamp = timeGen(); |
| | | |
| | | //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 |
| | | if (timestamp < lastTimestamp) { |
| | | throw new RuntimeException( |
| | | String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); |
| | | } |
| | | |
| | | //如果是同一时间生成的,则进行毫秒内序列 |
| | | if (lastTimestamp == timestamp) { |
| | | sequence = (sequence + 1) & sequenceMask; |
| | | //毫秒内序列溢出 |
| | | if (sequence == 0) { |
| | | //阻塞到下一个毫秒,获得新的时间戳 |
| | | timestamp = tilNextMillis(lastTimestamp); |
| | | } |
| | | } |
| | | //时间戳改变,毫秒内序列重置 |
| | | else { |
| | | sequence = 0L; |
| | | } |
| | | |
| | | //上次生成ID的时间截 |
| | | lastTimestamp = timestamp; |
| | | |
| | | //移位并通过或运算拼到一起组成64位的ID |
| | | return (((timestamp - twepoch) << timestampLeftShift) |
| | | | (datacenterId << datacenterIdShift) |
| | | | (workerId << workerIdShift) |
| | | | sequence); |
| | | } |
| | | |
| | | /** |
| | | * 阻塞到下一个毫秒,直到获得新的时间戳 |
| | | * |
| | | * @param lastTimestamp 上次生成ID的时间截 |
| | | * @return 当前时间戳 |
| | | */ |
| | | protected long tilNextMillis(long lastTimestamp) { |
| | | long timestamp = timeGen(); |
| | | while (timestamp <= lastTimestamp) { |
| | | timestamp = timeGen(); |
| | | } |
| | | return timestamp; |
| | | } |
| | | |
| | | /** |
| | | * 返回以毫秒为单位的当前时间 |
| | | * |
| | | * @return 当前时间(毫秒) |
| | | */ |
| | | protected long timeGen() { |
| | | return System.currentTimeMillis(); |
| | | } |
| | | |
| | | //==============================Test============================================= |
| | | |
| | | /** |
| | | * 测试 |
| | | */ |
| | | |
| | | // public static void main(String[] args) { |
| | | // long startTime = System.currentTimeMillis(); |
| | | // SnowFlake idWorker = new SnowFlake(30, 30); |
| | | // Set set = new HashSet(); |
| | | // for (int i = 0; i < 10; i++) { |
| | | // long id = idWorker.nextId(); |
| | | // set.add(id); |
| | | // System.out.println("id----"+i+":"+id); |
| | | // } |
| | | // long endTime = System.currentTimeMillis(); |
| | | // System.out.println("set.size():" + set.size()); |
| | | // System.out.println("endTime-startTime:" + (endTime - startTime)); |
| | | // } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | public class SnowFlakeUtil { |
| | | |
| | | /** |
| | | * 起始的时间戳(2020-05-27 00:00:00) |
| | | */ |
| | | private final static long START_STAMP = 1590508800000L; |
| | | |
| | | /** |
| | | * 每一部分占用的位数 |
| | | */ |
| | | //序列号占用的位数 |
| | | private final static long SEQUENCE_BIT = 12; |
| | | //机器标识占用的位数 |
| | | private final static long MACHINE_BIT = 5; |
| | | //数据中心占用的位数 |
| | | private final static long DATA_CENTER_BIT = 5; |
| | | |
| | | /** |
| | | * 每一部分的最大值 |
| | | */ |
| | | private final static long MAX_DATA_CENTER_NUM = -1L ^ (-1L << DATA_CENTER_BIT); |
| | | private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT); |
| | | private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT); |
| | | |
| | | /** |
| | | * 每一部分向左的位移 |
| | | */ |
| | | private final static long MACHINE_LEFT = SEQUENCE_BIT; |
| | | private final static long DATA_CENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT; |
| | | private final static long TIMESTAMP_LEFT = DATA_CENTER_LEFT + DATA_CENTER_BIT; |
| | | |
| | | /** |
| | | * 单例模式 |
| | | */ |
| | | private static SnowFlakeUtil snowFlake; |
| | | |
| | | static { |
| | | snowFlake = new SnowFlakeUtil(1L, 2L); |
| | | } |
| | | |
| | | public static long getId() { |
| | | return snowFlake.nextId(); |
| | | } |
| | | |
| | | public static long getId(long machineId) { |
| | | return SnowFlakeUtil.getId(1L, machineId); |
| | | } |
| | | |
| | | public static long getId(long dataCenterId, long machineId) { |
| | | return new SnowFlakeUtil(dataCenterId, machineId).nextId(); |
| | | } |
| | | |
| | | //数据中心 |
| | | private long dataCenterId; |
| | | //机器标识 |
| | | private long machineId; |
| | | //序列号 |
| | | private long sequence = 0L; |
| | | //上一次时间戳 |
| | | private long lastStamp = -1L; |
| | | |
| | | private SnowFlakeUtil(long dataCenterId, long machineId) { |
| | | if (dataCenterId > MAX_DATA_CENTER_NUM || dataCenterId < 0) { |
| | | throw new IllegalArgumentException("dataCenterId can't be greater than MAX_DATA_CENTER_NUM or less than 0"); |
| | | } |
| | | if (machineId > MAX_MACHINE_NUM || machineId < 0) { |
| | | throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0"); |
| | | } |
| | | this.dataCenterId = dataCenterId; |
| | | this.machineId = machineId; |
| | | } |
| | | |
| | | /** |
| | | * 产生下一个ID |
| | | */ |
| | | public synchronized long nextId() { |
| | | long currStamp = getNewStamp(); |
| | | if (currStamp < lastStamp) { |
| | | throw new RuntimeException("Clock moved backwards. Refusing to generate id"); |
| | | } |
| | | |
| | | if (currStamp == lastStamp) { |
| | | //相同毫秒内,序列号自增 |
| | | sequence = (sequence + 1) & MAX_SEQUENCE; |
| | | //同一毫秒的序列数已经达到最大 |
| | | if (sequence == 0L) { |
| | | currStamp = getNextMill(); |
| | | } |
| | | } else { |
| | | //不同毫秒内,序列号置为0 |
| | | sequence = 0L; |
| | | } |
| | | |
| | | lastStamp = currStamp; |
| | | |
| | | return (currStamp - START_STAMP) << TIMESTAMP_LEFT //时间戳部分 |
| | | | dataCenterId << DATA_CENTER_LEFT //数据中心部分 |
| | | | machineId << MACHINE_LEFT //机器标识部分 |
| | | | sequence; //序列号部分 |
| | | } |
| | | |
| | | private long getNextMill() { |
| | | long mill = getNewStamp(); |
| | | while (mill <= lastStamp) { |
| | | mill = getNewStamp(); |
| | | } |
| | | return mill; |
| | | } |
| | | |
| | | private long getNewStamp() { |
| | | return LocalDateTimeUtil.nowTimeStamp(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * Spring工具类 |
| | | * Created by macro on 2020/3/3. |
| | | */ |
| | | @Component |
| | | public class SpringUtil implements ApplicationContextAware { |
| | | |
| | | private static ApplicationContext applicationContext; |
| | | |
| | | // 获取applicationContext |
| | | public static ApplicationContext getApplicationContext() { |
| | | return applicationContext; |
| | | } |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| | | if (SpringUtil.applicationContext == null) { |
| | | SpringUtil.applicationContext = applicationContext; |
| | | } |
| | | } |
| | | |
| | | // 通过name获取Bean |
| | | public static Object getBean(String name) { |
| | | return getApplicationContext().getBean(name); |
| | | } |
| | | |
| | | // 通过class获取Bean |
| | | public static <T> T getBean(Class<T> clazz) { |
| | | return getApplicationContext().getBean(clazz); |
| | | } |
| | | |
| | | // 通过name,以及Clazz返回指定的Bean |
| | | public static <T> T getBean(String name, Class<T> clazz) { |
| | | return getApplicationContext().getBean(name, clazz); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import com.fengdu.gas.common.security.MD5Util; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import org.apache.commons.lang3.EnumUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.Charset; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 字符串处理类 |
| | | * @author linliu |
| | | * @date 2018-12-28 |
| | | */ |
| | | public final class StringUtil { |
| | | //region 常量 |
| | | private static final String REGX_MOBILEPHONE = "^((\\+86)|(\\(\\+86\\))-)?[0-9]{11}$"; |
| | | |
| | | private static final String REGX_TELEPHONE = "^((\\+86)|(\\(\\+86\\))-)?(((0[1,2]{1}\\d{1})?-?\\d{8})|((0[3-9]{1}\\d{2})?-?\\d{7,8}))$"; |
| | | |
| | | private static final String REGX_IDCARD = "^([0-9]{17}[0-9X]{1})|([0-9]{15})$"; |
| | | |
| | | private static final String REGX_WEBURL = "^(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\\.))+(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(/[a-zA-Z0-9\\&%_\\./-~-]*)?$"; |
| | | |
| | | private static final String REGX_EMAIL = "^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; |
| | | |
| | | private static final String REGX_MONEY = "^\\d{1,12}(?:\\.\\d{1,4})?$"; |
| | | |
| | | private static final String DEFAULT = "utf-8"; |
| | | //endregion |
| | | |
| | | private StringUtil() { |
| | | throw new IllegalStateException("Utility class"); |
| | | } |
| | | |
| | | /** |
| | | * 从当前对象移除头尾指定字符 |
| | | * @author xiangyuanzhang |
| | | * @date 2018-12-25 |
| | | * @param source 原始字符串 |
| | | * @param trimChar 移除字符串 |
| | | */ |
| | | public String trim(String source, String trimChar) { |
| | | if(source==null){ |
| | | return ""; |
| | | } |
| | | source = source.trim(); |
| | | if(source.isEmpty()){ |
| | | return ""; |
| | | } |
| | | String beginChar = source.substring(0, 1); |
| | | if (beginChar.equalsIgnoreCase(trimChar)) { |
| | | source = source.substring(1, source.length()); |
| | | } |
| | | String endChar = source.substring(source.length() - 1, source.length()); |
| | | if (endChar.equalsIgnoreCase(trimChar)) { |
| | | source = source.substring(0, source.length() - 1); |
| | | } |
| | | return source; |
| | | } |
| | | |
| | | /** |
| | | * 从当前对象移除头部指定字符 |
| | | * @author xiangyuanzhang |
| | | * @date 2018-12-25 |
| | | * @param source 原始字符串 |
| | | * @param trimChar 移除字符串 |
| | | */ |
| | | public String trimStart(String source, String trimChar) { |
| | | if(source==null){ |
| | | return ""; |
| | | } |
| | | source = source.trim(); |
| | | if(source.isEmpty()){ |
| | | return ""; |
| | | } |
| | | String beginChar = source.substring(0, 1); |
| | | if (beginChar.equalsIgnoreCase(trimChar)) { |
| | | source = source.substring(1, source.length()); |
| | | } |
| | | return source; |
| | | } |
| | | |
| | | /** |
| | | * 从当前对象移除尾部指定字符 |
| | | * @author xiangyuanzhang |
| | | * @date 2018-12-25 |
| | | * @param source 原始字符串 |
| | | * @param trimChar 移除字符串 |
| | | */ |
| | | public String trimEnd(String source, String trimChar) { |
| | | if(source==null){ |
| | | return ""; |
| | | } |
| | | source = source.trim(); |
| | | if(source.isEmpty()){ |
| | | return ""; |
| | | } |
| | | String endChar = source.substring(source.length() - 1, source.length()); |
| | | if (endChar.equalsIgnoreCase(trimChar)) { |
| | | source = source.substring(0, source.length() - 1); |
| | | } |
| | | return source; |
| | | } |
| | | |
| | | /** |
| | | * 字符串枚举值转成枚举对象 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param enumType 枚举类型 |
| | | * @param value 枚举值 |
| | | * @param <T> 枚举类型 |
| | | * @return 枚举对象 |
| | | */ |
| | | public static <T extends Enum<T>> T parseEnum(Class<T> enumType, String value) { |
| | | if(isNullOrEmpty(value)) { |
| | | return null; |
| | | } |
| | | |
| | | T result = null; |
| | | try { |
| | | T[] values = enumType.getEnumConstants(); |
| | | Method getValue = enumType.getMethod("getValue"); |
| | | |
| | | for (T e : values) { |
| | | if(getValue.invoke(e).toString().equals(value)) { |
| | | result = e; |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 字符串枚举值转成枚举对象 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param enumType 枚举类型 |
| | | * @param name 枚举名称 |
| | | * @param <T> 枚举类型 |
| | | * @return 枚举对象 |
| | | */ |
| | | public static <T extends Enum<T>> T parseEnumByName(Class<T> enumType, String name) { |
| | | if(isNullOrEmpty(name)) { |
| | | return null; |
| | | } |
| | | |
| | | T result = null; |
| | | try { |
| | | result = EnumUtils.getEnum(enumType, name); |
| | | } catch (Exception e) { |
| | | //TODO log |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 判断枚举是否申明了传入枚举值 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param enumType 枚举类型 |
| | | * @param value 枚举值 |
| | | * @param <T> 枚举类型 |
| | | * @return 是否包含 |
| | | */ |
| | | public static <T extends Enum<T>> boolean isEnum(Class<T> enumType, String value) { |
| | | return (null != parseEnum(enumType, value)); |
| | | } |
| | | |
| | | /** |
| | | * 判断枚举是否申明了传入枚举值 |
| | | * @author linliu |
| | | * @date 2018-12-24 |
| | | * @param enumType 枚举类型 |
| | | * @param name 枚举名称 |
| | | * @param <T> 枚举类型 |
| | | * @return 是否包含 |
| | | */ |
| | | public static <T extends Enum<T>> boolean isEnumName(Class<T> enumType, String name) { |
| | | return EnumUtils.isValidEnum(enumType, name); |
| | | } |
| | | |
| | | /** |
| | | * 字符串是否为空 |
| | | * @author linliu |
| | | * @date 2018-12-25 |
| | | * @param str 字符串 |
| | | * @return 是否为空 |
| | | */ |
| | | public static boolean isNullOrEmpty(String str){ |
| | | return (str==null || str.equals("") || str.replace(" ","").length() == 0); |
| | | } |
| | | |
| | | /** |
| | | * 字符串非空 |
| | | * @author linliu |
| | | * @date 2018-12-25 |
| | | * @param str 字符串 |
| | | * @return 是否非空 |
| | | */ |
| | | public static boolean isNotNullOrEmpty(String str){ |
| | | return !isNullOrEmpty(str); |
| | | } |
| | | |
| | | /** |
| | | * 集合,使用英文逗号“,”拼接成一个字符串 |
| | | * @param list 集合 |
| | | */ |
| | | public static String join(Collection<String> list){ |
| | | return StringUtil.join(list, ","); |
| | | } |
| | | /** |
| | | * 集合,使用指定的字符,拼接成一个字符串 |
| | | * @param list 集合 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String join(Collection<String> list, String separator){ |
| | | if(ListUtil.isNullOrEmpty(list)){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(list.toArray(), separator); |
| | | } |
| | | /** |
| | | * 数组,使用英文逗号“,”拼接成一个字符串 |
| | | * @param array 数组 |
| | | */ |
| | | public static String join(String[] array){ |
| | | return StringUtil.join(array, ","); |
| | | } |
| | | /** |
| | | * 数组,使用指定的字符,拼接成一个字符串 |
| | | * @param array 数组 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String join(String[] array, String separator){ |
| | | if(array == null){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(array, separator); |
| | | } |
| | | |
| | | /** |
| | | * 集合,使用英文逗号“,”拼接成一个字符串 |
| | | * @param list 集合 |
| | | */ |
| | | public static String joinNumber(Collection<Number> list){ |
| | | return StringUtil.joinNumber(list, ","); |
| | | } |
| | | /** |
| | | * 集合,使用指定的字符,拼接成一个字符串 |
| | | * @param list 集合 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String joinNumber(Collection<Number> list, String separator){ |
| | | if(ListUtil.isNullOrEmpty(list)){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(list.toArray(), separator); |
| | | } |
| | | /** |
| | | * 数组,使用英文逗号“,”拼接成一个字符串 |
| | | * @param array 数组 |
| | | */ |
| | | public static String joinNumber(Number[] array){ |
| | | return joinNumber(array, ","); |
| | | } |
| | | /** |
| | | * 数组,使用指定的字符,拼接成一个字符串 |
| | | * @param array 数组 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String joinNumber(Number[] array, String separator){ |
| | | if(array == null){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(array, separator); |
| | | } |
| | | |
| | | /** |
| | | * base64解码(utf-8编码) |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String base64Encode(String str) { |
| | | return base64Encode(str, DEFAULT); |
| | | } |
| | | /** |
| | | * base64解码 |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @param encoding 编码格式[默认utf-8] |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String base64Encode(String str, String encoding) { |
| | | if(isNullOrEmpty(str)) { |
| | | return ""; |
| | | } |
| | | if(isNullOrEmpty(encoding)) { |
| | | encoding = DEFAULT; |
| | | } |
| | | byte[] bytes = str.getBytes(Charset.forName(encoding)); |
| | | return Base64.getEncoder().encodeToString(bytes); |
| | | } |
| | | |
| | | /** |
| | | * base64解码(utf-8编码) |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String base64Decode(String str) { |
| | | return base64Decode(str, DEFAULT); |
| | | } |
| | | /** |
| | | * base64解码 |
| | | * @author linliu |
| | | * @date 2019-06-14 |
| | | * @param str 密文字符串 |
| | | * @param encoding 编码格式[默认utf-8] |
| | | * @return 解码后的明文 |
| | | */ |
| | | public static String base64Decode(String str, String encoding) { |
| | | if(isNullOrEmpty(str)) { |
| | | return ""; |
| | | } |
| | | if(isNullOrEmpty(encoding)) { |
| | | encoding = DEFAULT; |
| | | } |
| | | byte[] bytes = Base64.getDecoder().decode(str); |
| | | return new String(bytes, Charset.forName(encoding)); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的手机号码 |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isMobilePhone(String str) { |
| | | return Pattern.matches(REGX_MOBILEPHONE, str); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的座机号码 |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isTelPhone(String str) { |
| | | return Pattern.matches(REGX_TELEPHONE, str); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的身份证号码 |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isIdCard(String str) { |
| | | return Pattern.matches(REGX_IDCARD, str); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的网址 |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isWebUrl(String str) { |
| | | return Pattern.matches(REGX_WEBURL, str); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的电子邮件邮箱地址 |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isEmail(String str) { |
| | | return Pattern.matches(REGX_EMAIL, str); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的金额 |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isMoney(String str) { |
| | | return Pattern.matches(REGX_MONEY, str); |
| | | } |
| | | |
| | | /** |
| | | * 是否满足正则表达式规则 |
| | | * @author linliu |
| | | * @date 2019-01-04 |
| | | * @param str 字符串 |
| | | * @param regex 正则表达式 |
| | | * @return 是否匹配 |
| | | */ |
| | | public static Boolean isMatch(String str,String regex) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return Boolean.FALSE; |
| | | } |
| | | return Pattern.matches(regex, str); |
| | | } |
| | | |
| | | /** |
| | | * 正则获取Xml中的内容 |
| | | * @author xiangyuanzhang |
| | | * @date 2019-01-09 |
| | | * @param xml 传入的xml字符串 |
| | | * @param label 指定的标签中的内容 |
| | | */ |
| | | public static String regexXml(String xml, String label) { |
| | | String context = ""; |
| | | String rgex = "<" + label + ">(.*?)</" + label + ">"; |
| | | Pattern pattern = Pattern.compile(rgex,Pattern.CASE_INSENSITIVE); |
| | | Matcher m = pattern.matcher(xml); |
| | | List<String> list = new ArrayList<>(); |
| | | int i = 1; |
| | | while (m.find()) { |
| | | list.add(m.group(i)); |
| | | i++; |
| | | } |
| | | if (!list.isEmpty()) { |
| | | context = list.get(0); |
| | | } |
| | | return context; |
| | | } |
| | | |
| | | /** |
| | | * 获取<![CDATA 中内容 |
| | | * @author xiangyuanzhang |
| | | * @date 2019-01-14 |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String getCDATAContent(String str) { |
| | | Pattern p = Pattern.compile(".*<!\\[CDATA\\[(.*)\\]\\]>.*"); |
| | | Matcher m = p.matcher(str); |
| | | if(m.matches()) { |
| | | return m.group(1); |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串转成 Integer 类型 |
| | | * @param str 字符串 |
| | | */ |
| | | public static int parseInt(String str) { |
| | | return Integer.parseInt(str); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串转成 Long 类型 |
| | | * @param str 字符串 |
| | | */ |
| | | public static long parseLong(String str) { |
| | | return Long.parseLong(str); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串转成精度为2位小数的 BigDecimal 类型 |
| | | * @param str 字符串 |
| | | */ |
| | | public static BigDecimal parseBigDecimal(String str) { |
| | | return parseBigDecimal(str, Integer.parseInt("2")); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串转成指定精度的 BigDecimal 类型 |
| | | * @param str 字符串 |
| | | */ |
| | | public static BigDecimal parseBigDecimal(String str, Integer length) { |
| | | BigDecimal bd = new BigDecimal(str); |
| | | return bd.setScale(length, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | | /** |
| | | * 传入字符串是否是有效的 BigDecimal |
| | | * @param str 字符串 |
| | | */ |
| | | public static boolean isBigDecimal(String str) { |
| | | try{ |
| | | if(isNullOrEmpty(str)) { |
| | | return false; |
| | | } |
| | | new BigDecimal(str); |
| | | return true; |
| | | }catch (NumberFormatException e){ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将传入指定格式的字符串转成 Calendar 类型(默认“yyyy-MM-dd HH:mm:ss”) |
| | | * @param str 时间字符串 |
| | | * @param format 时间格式 |
| | | */ |
| | | public static Calendar parseDate(String str, String... format) { |
| | | String f = ConstantFactory.STR_DATE_FULL; |
| | | if(format.length>0) { |
| | | f = format[0]; |
| | | } |
| | | return CalendarUtil.fromStr(str, f); |
| | | } |
| | | |
| | | /** |
| | | * md5加密 |
| | | * @param content 待加密明文字符串 |
| | | */ |
| | | public static String md5(String content) { |
| | | return MD5Util.encrypt(content); |
| | | } |
| | | |
| | | /** |
| | | * 集合,使用英文逗号“,”拼接成一个字符串 |
| | | * @param list 集合 |
| | | */ |
| | | public static String joinInt(List<Integer> list){ |
| | | return joinInt(list, ","); |
| | | } |
| | | /** |
| | | * 集合,使用指定的字符,拼接成一个字符串 |
| | | * @param list 集合 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String joinInt(List<Integer> list, String separator){ |
| | | if(ListUtil.isNullOrEmpty(list)){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(list.toArray(), separator); |
| | | } |
| | | |
| | | /** |
| | | * 数组,使用英文逗号“,”拼接成一个字符串 |
| | | * @param array 数组 |
| | | */ |
| | | public static String joinInt(Integer[] array){ |
| | | return joinInt(array, ","); |
| | | } |
| | | /** |
| | | * 数组,使用指定的字符,拼接成一个字符串 |
| | | * @param array 数组 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String joinInt(Integer[] array, String separator){ |
| | | if(array == null){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(array, separator); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串按指定分隔符,拆分成数组 |
| | | * @param str 字符串 |
| | | * @param splitChar 分隔符 |
| | | */ |
| | | public static String[] split(String str, String splitChar) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new String[0]; |
| | | } |
| | | return str.split(splitChar); |
| | | } |
| | | /** |
| | | * 将传入字符串按英文逗号“,”分隔,拆分成数组 |
| | | * @param str 字符串 |
| | | */ |
| | | public static String[] split(String str) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new String[0]; |
| | | } |
| | | return str.split("\\,"); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串按指定分隔符,拆分成集合 |
| | | * @param str 字符串 |
| | | * @param splitChar 分隔符 |
| | | */ |
| | | public static List<String> splitList(String str, String splitChar) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return ListUtil.toList(split(str, splitChar)); |
| | | } |
| | | /** |
| | | * 将传入字符串按英文逗号“,”分隔,拆分成集合 |
| | | * @param str 字符串 |
| | | */ |
| | | public static List<String> splitList(String str) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return splitList(str, ","); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串按指定分隔符,拆分成集合 |
| | | * @param str 字符串 |
| | | * @param splitChar 分隔符 |
| | | */ |
| | | public static List<Integer> splitIntList(String str, String splitChar) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return ListUtil.toIntList(splitList(str, splitChar)); |
| | | } |
| | | /** |
| | | * 将传入字符串按英文逗号“,”分隔,拆分成集合 |
| | | * @param str 字符串 |
| | | */ |
| | | public static List<Integer> splitIntList(String str) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return splitIntList(str, ","); |
| | | } |
| | | |
| | | /** |
| | | * 将传入字符串按指定分隔符,拆分成集合 |
| | | * @param str 字符串 |
| | | * @param splitChar 分隔符 |
| | | */ |
| | | public static List<Long> splitLongList(String str, String splitChar) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return ListUtil.toLongList(splitList(str, splitChar)); |
| | | } |
| | | /** |
| | | * 将传入字符串按英文逗号“,”分隔,拆分成集合 |
| | | * @param str 字符串 |
| | | */ |
| | | public static List<Long> splitLongList(String str) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return splitLongList(str, ","); |
| | | } |
| | | |
| | | /** |
| | | * 集合,使用英文逗号“,”拼接成一个字符串 |
| | | * @param list 集合 |
| | | */ |
| | | public static String joinLong(Collection<Long> list) { |
| | | return StringUtil.joinLong(list, ","); |
| | | } |
| | | /** |
| | | * 集合,使用指定的字符,拼接成一个字符串 |
| | | * @param list 集合 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String joinLong(Collection<Long> list, String separator) { |
| | | if(ListUtil.isNullOrEmpty(list)){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(list.toArray(), separator); |
| | | } |
| | | |
| | | /** |
| | | * 数组,使用英文逗号“,”拼接成一个字符串 |
| | | * @param array 数组 |
| | | */ |
| | | public static String joinLong(Long[] array) { |
| | | return joinLong(array, ","); |
| | | } |
| | | /** |
| | | * 数组,使用指定的字符,拼接成一个字符串 |
| | | * @param array 数组 |
| | | * @param separator 拼接字符 |
| | | */ |
| | | public static String joinLong(Long[] array, String separator){ |
| | | if(array == null){ |
| | | return ""; |
| | | } |
| | | return StringUtils.join(array, separator); |
| | | } |
| | | |
| | | /** |
| | | * 将字符串按英文逗号“,”分割,拆分成日期集合 |
| | | * @param str |
| | | * @param dateFormat |
| | | * @return |
| | | */ |
| | | public static List<Date> splitListDate(String str, String dateFormat) { |
| | | return splitListDate(str, dateFormat, ","); |
| | | } |
| | | /** |
| | | * 将字符串按指定分隔符,拆分成日期集合 |
| | | * @param str 字符串 |
| | | * @param dateFormat 日期格式 |
| | | * @return |
| | | */ |
| | | public static List<Date> splitListDate(String str, String dateFormat, String separator) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<String> lstDate = splitList(str, separator); |
| | | return lstDate.stream().map(d -> { |
| | | try { |
| | | return CalendarUtil.fromStr(d, dateFormat).getTime(); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 按指定字符串分割字符串 |
| | | * @author linliu |
| | | * @date 2019-06-19 |
| | | * @param str 字符串 |
| | | * @param onceQuantity 拆分后单个字符串的字符数 |
| | | */ |
| | | public static String[] split(String str, Integer onceQuantity) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new String[]{}; |
| | | } |
| | | if(Integer.valueOf(0).compareTo(onceQuantity)>-1) { |
| | | onceQuantity = str.length(); |
| | | } |
| | | int size = str.length() / onceQuantity; |
| | | String[] result = new String[size]; |
| | | if(size==1) { |
| | | result[0] = str; |
| | | return result; |
| | | } |
| | | for (int idx=0; idx<size; idx++) { |
| | | result[idx] = substring(str, onceQuantity*idx, onceQuantity*(idx+1)); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 按指定字符串分割字符串 |
| | | * @author linliu |
| | | * @date 2019-06-19 |
| | | * @param str 字符串 |
| | | * @param onceQuantity 拆分后单个字符串的字符数 |
| | | */ |
| | | public static List<String> splitList(String str, Integer onceQuantity) { |
| | | if(StringUtil.isNullOrEmpty(str)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | if(Integer.valueOf(0).compareTo(onceQuantity)>-1) { |
| | | onceQuantity = str.length(); |
| | | } |
| | | int size = str.length() / onceQuantity; |
| | | List<String> result = new ArrayList<>(); |
| | | if(size==1) { |
| | | result.add(str); |
| | | return result; |
| | | } |
| | | if(str.length()%onceQuantity != 0) { |
| | | size += 1; |
| | | } |
| | | for (int idx=0; idx<size; idx++) { |
| | | result.add(substring(str, onceQuantity*idx, onceQuantity*(idx+1))); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 分割字符串,如果开始位置大于字符串长度,返回空 |
| | | * @author linliu |
| | | * @date 2019-06-19 |
| | | * @param str 原始字符串 |
| | | * @param start 开始位置 |
| | | * @param end 结束位置 |
| | | */ |
| | | public static String substring(String str, Integer start, Integer end) { |
| | | if (StringUtil.isNullOrEmpty(str) || start > str.length()) { |
| | | return ""; |
| | | } |
| | | if (end > str.length()) { |
| | | return str.substring(start, str.length()); |
| | | } else { |
| | | return str.substring(start, end); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 截取字符串长度 |
| | | * @param content 字符串 |
| | | * @param length 截取长度 |
| | | */ |
| | | public static String cutStr(String content, Integer length) { |
| | | return StringUtil.substring(content, 0, length); |
| | | } |
| | | |
| | | /** |
| | | * 判断是否为空,如果为空返回空字符串 |
| | | * @param str 字符串 |
| | | */ |
| | | public static String getStringDefault(String str) { |
| | | if (StringUtil.isNullOrEmpty(str)) { |
| | | return ""; |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * 将小驼峰字符串转为_连接的 |
| | | * @param input 字符串 |
| | | */ |
| | | public static String camelCaseToUnderscore(String input) { |
| | | if (input == null) { |
| | | return null; |
| | | } |
| | | |
| | | StringBuilder result = new StringBuilder(); |
| | | boolean prevIsLowerCase = false; |
| | | |
| | | for (char c : input.toCharArray()) { |
| | | if (Character.isUpperCase(c)) { |
| | | if (prevIsLowerCase) { |
| | | result.append('_'); |
| | | } |
| | | result.append(Character.toLowerCase(c)); |
| | | prevIsLowerCase = false; |
| | | } else { |
| | | result.append(c); |
| | | prevIsLowerCase = true; |
| | | } |
| | | } |
| | | |
| | | return result.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 字符串转16进制字符 |
| | | * @param input 字符串 |
| | | */ |
| | | public static String toHexString(String input) { |
| | | StringBuilder str = new StringBuilder(); |
| | | for (int i = 0; i < input.length(); i++) { |
| | | int ch = input.charAt(i); |
| | | String s4 = Integer.toHexString(ch); |
| | | str.append(s4); |
| | | } |
| | | return str.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.util; |
| | | |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | |
| | | /** |
| | | * 线程池管理类 |
| | | */ |
| | | public final class ThreadPoolUtil { |
| | | /** |
| | | * 多线程允许最大并发线程数的默认大小 |
| | | */ |
| | | private static final Integer THREAD_DEFAULT_MAXQUANTITY = 50; |
| | | |
| | | /** |
| | | * 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待。 |
| | | */ |
| | | private static ExecutorService THREADPOOL_DEFAULT = Executors.newFixedThreadPool(THREAD_DEFAULT_MAXQUANTITY); |
| | | |
| | | /** |
| | | * 获取默认线程池 |
| | | * @return |
| | | */ |
| | | public static ExecutorService getDefaultPool() { |
| | | return THREADPOOL_DEFAULT; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.validator; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 参数验证类型 枚举 |
| | | * @author linliu |
| | | * @date 2019-04-19 |
| | | */ |
| | | public enum EParameterValidateType { |
| | | /** |
| | | * 不能为空 |
| | | */ |
| | | NOT_NULLOREMPTY(", 不能为空 ", 1), |
| | | |
| | | |
| | | |
| | | /** |
| | | * 必须大于 |
| | | */ |
| | | MUST_GREATER(", 必须大于 ", 2), |
| | | /** |
| | | * 必须大于等于 |
| | | */ |
| | | MUST_GREATER_THAN(", 必须大于等于 ", 3), |
| | | |
| | | |
| | | |
| | | /** |
| | | * 必须小于 |
| | | */ |
| | | MUST_LESS(", 必须小于 ", 4), |
| | | /** |
| | | * 必须小于等于 |
| | | */ |
| | | MUST_LESS_THAN(", 必须小于等于 ", 5), |
| | | |
| | | |
| | | |
| | | /** |
| | | * 必须是枚举 |
| | | */ |
| | | MUST_ENUM(", 必须是合法的枚举值", 6), |
| | | |
| | | |
| | | |
| | | /** |
| | | * 必须是有效的日期(yyyy-MM-dd) |
| | | */ |
| | | MUST_DATE(", 必须是有效的日期格式(yyyy-MM-dd)", 7), |
| | | /** |
| | | * 必须是有效的时间(yyyy-MM-dd HH:mm:ss) |
| | | */ |
| | | MUST_DATE_TIME(", 必须是有效的日期格式(yyyy-MM-dd HH:mm:ss)", 8), |
| | | |
| | | |
| | | |
| | | /** |
| | | * 必须是有效电话号码 |
| | | */ |
| | | MUST_PHONE_NUMBER(", 必须是有效的联系方式", 9), |
| | | /** |
| | | * 必须是有效座机号码 |
| | | */ |
| | | MUST_TELEPHONE_NUMBER(", 必须是有效的座机号码", 10), |
| | | /** |
| | | * 必须是有效手机号码 |
| | | */ |
| | | MUST_MOBILE_NUMBER(", 必须是有效的手机号码", 11), |
| | | |
| | | |
| | | |
| | | /** |
| | | * 必须是有效电子邮箱地址 |
| | | */ |
| | | MUST_EMAIL(", 必须是有效的电子邮箱", 12), |
| | | |
| | | /** |
| | | * 不能超出取值范围 |
| | | */ |
| | | MUST_IN_RANGE(", 取值超出允许范围 ", 13), |
| | | |
| | | /** |
| | | * 长度不能小于 |
| | | */ |
| | | MUST_LENGTH_MIN(", 字符长度不能少于 ", 14), |
| | | /** |
| | | * 长度不能大于 |
| | | */ |
| | | MUST_LENGTH_MAX(", 字符长度不能超过 ", 15), |
| | | |
| | | /** |
| | | * 必须满足正则表达式规则 |
| | | */ |
| | | MUST_PASS_REGEX(", 必须满足正则表达式规则 ", 16) |
| | | ; |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | private EParameterValidateType(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EParameterValidateType getByValue(Integer value) { |
| | | return Arrays.stream(EParameterValidateType.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EParameterValidateType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.validator; |
| | | |
| | | public class ParameterRunnable<T> implements Runnable { |
| | | T param; |
| | | public ParameterRunnable(T param) { |
| | | this.param = param; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | new ParameterRunnable(param); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.validator; |
| | | |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * 参数验证 对象 |
| | | * @author linliu |
| | | * @date 2019-04-19 |
| | | * @param <T> 枚举类型 |
| | | */ |
| | | public class ParameterValidateItem<T extends Enum> { |
| | | private String fieldName; |
| | | private EParameterValidateType type; |
| | | private Object value; |
| | | private Object rangeMin; |
| | | private Object rangeMax; |
| | | private Class<T> enumType; |
| | | private Function<Object, Boolean> validateFunc = null; |
| | | private String regex; |
| | | |
| | | public ParameterValidateItem() {} |
| | | public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value) { |
| | | this.fieldName = fieldName; |
| | | this.type = type; |
| | | this.value = value; |
| | | } |
| | | public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) { |
| | | this.fieldName = fieldName; |
| | | this.type = type; |
| | | this.value = value; |
| | | this.validateFunc = validateFunc; |
| | | } |
| | | public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax) { |
| | | this.fieldName = fieldName; |
| | | this.type = type; |
| | | this.value = value; |
| | | this.rangeMin = rangeMin; |
| | | this.rangeMax = rangeMax; |
| | | } |
| | | public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax, Class<T> enumType) { |
| | | this.fieldName = fieldName; |
| | | this.type = type; |
| | | this.value = value; |
| | | this.rangeMin = rangeMin; |
| | | this.rangeMax = rangeMax; |
| | | this.enumType = enumType; |
| | | } |
| | | public ParameterValidateItem(String fieldName, Object value, Object rangeMin, Object rangeMax) { |
| | | this.fieldName = fieldName; |
| | | this.type = EParameterValidateType.MUST_IN_RANGE; |
| | | this.value = value; |
| | | this.rangeMin = rangeMin; |
| | | this.rangeMax = rangeMax; |
| | | } |
| | | public ParameterValidateItem(String fieldName, Object value , Class<T> enumType) { |
| | | this.fieldName = fieldName; |
| | | this.type = EParameterValidateType.MUST_ENUM; |
| | | this.value = value; |
| | | this.enumType = enumType; |
| | | } |
| | | public ParameterValidateItem(String fieldName, Object value , String regex) { |
| | | this.fieldName = fieldName; |
| | | this.type = EParameterValidateType.MUST_PASS_REGEX; |
| | | this.value = value; |
| | | this.regex = regex; |
| | | } |
| | | |
| | | public String getFieldName() { |
| | | return fieldName; |
| | | } |
| | | public void setFieldName(String fieldName) { |
| | | this.fieldName = fieldName; |
| | | } |
| | | |
| | | public EParameterValidateType getType() { |
| | | return type; |
| | | } |
| | | public void setType(EParameterValidateType type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public Object getValue() { |
| | | return value; |
| | | } |
| | | public void setValue(Object value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public Object getRangeMin() { |
| | | return rangeMin; |
| | | } |
| | | public void setRangeMin(Object rangeMin) { |
| | | this.rangeMin = rangeMin; |
| | | } |
| | | |
| | | public Object getRangeMax() { |
| | | return rangeMax; |
| | | } |
| | | public void setRangeMax(Object rangeMax) { |
| | | this.rangeMax = rangeMax; |
| | | } |
| | | |
| | | public Class<T> getEnumType() { |
| | | return enumType; |
| | | } |
| | | public void setEnumType(Class<T> enumType) { |
| | | this.enumType = enumType; |
| | | } |
| | | |
| | | public Function<Object, Boolean> getValidateFunc() { |
| | | return validateFunc; |
| | | } |
| | | public void setValidateFunc(Function<Object, Boolean> validateFunc) { |
| | | this.validateFunc = validateFunc; |
| | | } |
| | | |
| | | public String getRegex() { |
| | | return regex; |
| | | } |
| | | |
| | | public void setRegex(String regex) { |
| | | this.regex = regex; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.validator; |
| | | |
| | | public class ParameterValidateResult { |
| | | private Boolean isSuccess; |
| | | private String errorMsg; |
| | | |
| | | public ParameterValidateResult() {} |
| | | public ParameterValidateResult(Boolean isSuccess, String errorMsg) { |
| | | this.isSuccess = isSuccess; |
| | | this.errorMsg = errorMsg; |
| | | } |
| | | |
| | | public Boolean getIsSuccess() { |
| | | return isSuccess; |
| | | } |
| | | public void setIsSuccess(Boolean success) { |
| | | isSuccess = success; |
| | | } |
| | | |
| | | public Boolean getIsFiled() { |
| | | return !isSuccess; |
| | | } |
| | | |
| | | public String getErrorMsg() { |
| | | return errorMsg; |
| | | } |
| | | public void setErrorMsg(String errorMsg) { |
| | | this.errorMsg = errorMsg; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ParameterValidateResult{" + |
| | | "isSuccess=" + isSuccess + |
| | | ", errorMsg='" + errorMsg + '\'' + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.common.validator; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * 参数验证 |
| | | * @author linliu |
| | | * @date 2019-04-19 |
| | | */ |
| | | public class ParameterValidator { |
| | | /** |
| | | * 验证参数列表 |
| | | */ |
| | | public List<ParameterValidateItem> listParameter; |
| | | public List<ParameterValidateItem> getListParameter() { |
| | | return listParameter; |
| | | } |
| | | public void setListParameter(List<ParameterValidateItem> listParameter) { |
| | | this.listParameter = listParameter; |
| | | } |
| | | |
| | | public ParameterValidator() { |
| | | listParameter = new ArrayList<>(); |
| | | } |
| | | |
| | | /** |
| | | * 添加一个需要验证的参数 |
| | | * @param item 参数验证对象 |
| | | */ |
| | | public ParameterValidator addParameter(ParameterValidateItem... item) { |
| | | this.listParameter.addAll(Arrays.asList(item)); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 添加一个需要验证的参数 |
| | | * @param fieldName 参数名称“自行构建参数描述"userName" 或者 "the parameter which named “userName”"” |
| | | * @param type 需要验证的类型 |
| | | * @param value 参数的值 |
| | | * @param validateFunc 是否通过验证的自函数 |
| | | */ |
| | | public ParameterValidator addParameter(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, type, value, validateFunc)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加一个“不能为空”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | */ |
| | | public ParameterValidator addNotNullOrEmpty(String fieldName, Object value) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.NOT_NULLOREMPTY, value)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须是一个有效日期”(yyyy-MM-dd)的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | */ |
| | | public ParameterValidator addMustDate(String fieldName, Object value) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_DATE, value)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须是一个有效时间”(yyyy-MM-dd HH:mm:ss)的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | */ |
| | | public ParameterValidator addMustDateTime(String fieldName, Object value) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_DATE_TIME, value)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须是指定枚举类型的有效值”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param enumType 枚举类型 |
| | | */ |
| | | public <T extends Enum> ParameterValidator addMustEnum(String fieldName, Object value, Class<T> enumType) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, value, enumType)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须是有效电子邮箱地址”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | */ |
| | | public ParameterValidator addMustEmail(String fieldName, Object value) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_EMAIL, value)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须是有效手机号码”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | */ |
| | | public ParameterValidator addMustMobile(String fieldName, Object value) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_MOBILE_NUMBER, value)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须是有效手机号码”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | */ |
| | | public ParameterValidator addMustPassRegex(String fieldName, Object value, String regex) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, value, regex)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加一个“必须大于最小值”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param minValue 校验允许的最小值 |
| | | */ |
| | | public ParameterValidator addGreater(String fieldName, Object value, Object minValue) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_GREATER, value, minValue, null)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须大于等于最小值”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param minValue 校验允许的最小值 |
| | | */ |
| | | public ParameterValidator addGreaterThan(String fieldName, Object value, Object minValue) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_GREATER_THAN, value, minValue, null)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加一个“必须小于最大值”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param maxValue 校验允许的最大值 |
| | | */ |
| | | public ParameterValidator addLess(String fieldName, Object value, Object maxValue) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LESS, value, null, maxValue)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“必须小于等于最大值”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param maxValue 校验允许的最大值 |
| | | */ |
| | | public ParameterValidator addLessThan(String fieldName, Object value, Object maxValue) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LESS_THAN, value, null, maxValue)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加一个“字符串必须大于等于最小长度”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param minLength 校验允许的最小长度 |
| | | */ |
| | | public ParameterValidator addLengthMin(String fieldName, Object value, Integer minLength) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LENGTH_MIN, value, minLength, null, null)); |
| | | return this; |
| | | } |
| | | /** |
| | | * 添加一个“字符串必须小于等于最大长度”的参数 验证 |
| | | * @param fieldName 参数名称 |
| | | * @param value 参数值 |
| | | * @param maxLength 校验允许的最大长度 |
| | | */ |
| | | public ParameterValidator addLengthMax(String fieldName, Object value, Integer maxLength) { |
| | | this.listParameter.add(new ParameterValidateItem(fieldName, EParameterValidateType.MUST_LENGTH_MAX, value, null, maxLength, null)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 执行验证参数 |
| | | * @return 验证结果 |
| | | */ |
| | | public ParameterValidateResult validate() { |
| | | if(ListUtil.isNotNullOrEmpty((this.listParameter))) { |
| | | return this.checkParameterValidate(); |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | |
| | | private ParameterValidateResult checkParameterValidate() { |
| | | for (ParameterValidateItem item : this.listParameter) { |
| | | ParameterValidateResult result = this.checkParameterValidateItem(item); |
| | | if(result.getIsFiled()) { |
| | | return result; |
| | | } |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | private ParameterValidateResult checkParameterValidateItem(ParameterValidateItem item) { |
| | | Function<Object, Boolean> func = item.getValidateFunc(); |
| | | if(null != func) { |
| | | if(func.apply(item.getValue())) { |
| | | return new ParameterValidateResult(true, ""); |
| | | } else { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); |
| | | } |
| | | } |
| | | switch (item.getType()) { |
| | | case NOT_NULLOREMPTY: |
| | | if(!ParameterValidator.checkNotNull(item.getValue())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); |
| | | } |
| | | break; |
| | | |
| | | |
| | | |
| | | case MUST_ENUM: |
| | | if(!ParameterValidator.checkIsEnum(item.getValue(), item.getEnumType())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getEnumType().getName().replace(item.getEnumType().getPackage().getName()+".", "")+":"+item.getValue()); |
| | | } |
| | | break; |
| | | case MUST_IN_RANGE: |
| | | if(!ParameterValidator.checkInRange(item.getValue(), item.getRangeMin(), item.getRangeMax())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getEnumType().getTypeName()); |
| | | } |
| | | break; |
| | | default: |
| | | return this.checkMustGreaterLess(item); |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | private ParameterValidateResult checkMustGreaterLess(ParameterValidateItem item) { |
| | | switch (item.getType()) { |
| | | case MUST_GREATER: |
| | | if(!ParameterValidator.checkGreater(item.getValue(), item.getRangeMin())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMin().toString()); |
| | | } |
| | | break; |
| | | case MUST_GREATER_THAN: |
| | | if(!ParameterValidator.checkGreaterThan(item.getValue(), item.getRangeMin())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMin().toString()); |
| | | } |
| | | break; |
| | | case MUST_LESS: |
| | | if(!ParameterValidator.checkLess(item.getValue(), item.getRangeMax())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMax().toString()); |
| | | } |
| | | break; |
| | | case MUST_LESS_THAN: |
| | | if(!checkLessThan(item.getValue(), item.getRangeMax())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+item.getRangeMax().toString()); |
| | | } |
| | | break; |
| | | default: |
| | | return this.checkDateTime(item); |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | private ParameterValidateResult checkDateTime(ParameterValidateItem item) { |
| | | switch (item.getType()) { |
| | | case MUST_DATE: |
| | | if(!checkIsMatch(item.getValue(), item.getType()) || !LocalDateTimeUtil.getDate(item.getValue().toString()).isAfter(LocalDateTimeUtil.DEFAULT_DATE)) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); |
| | | } |
| | | break; |
| | | case MUST_DATE_TIME: |
| | | if(!checkIsMatch(item.getValue(), item.getType()) || !LocalDateTimeUtil.getDateTime(item.getValue().toString()).isAfter(LocalDateTimeUtil.DEFAULT_DATETIME)) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); |
| | | } |
| | | break; |
| | | default: |
| | | return this.checkLength(item); |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | private ParameterValidateResult checkLength(ParameterValidateItem item) { |
| | | switch (item.getType()) { |
| | | case MUST_LENGTH_MIN: |
| | | String strMin = item.getRangeMin().toString(); |
| | | int minLength = Integer.valueOf(strMin); |
| | | if(null==item.getValue() || item.getValue().toString().length()<minLength) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+strMin); |
| | | } |
| | | break; |
| | | case MUST_LENGTH_MAX: |
| | | String strMax = item.getRangeMax().toString(); |
| | | int maxLength = Integer.valueOf(strMax); |
| | | if(null!=item.getValue() && item.getValue().toString().length()>maxLength) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()+strMax); |
| | | } |
| | | break; |
| | | default: |
| | | return this.checkOther(item); |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | private ParameterValidateResult checkOther(ParameterValidateItem item) { |
| | | switch (item.getType()) { |
| | | case MUST_EMAIL: |
| | | case MUST_MOBILE_NUMBER: |
| | | case MUST_TELEPHONE_NUMBER: |
| | | case MUST_PHONE_NUMBER: |
| | | if(!checkIsMatch(item.getValue(), item.getType())) { |
| | | return new ParameterValidateResult(false, item.getFieldName()+item.getType().getDesc()); |
| | | } |
| | | break; |
| | | |
| | | case MUST_PASS_REGEX: |
| | | if (!checkIsMatch(item.getRegex(), item.getValue())) { |
| | | return new ParameterValidateResult(false, item.getFieldName() + item.getType().getDesc() + item.getRegex()); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | return new ParameterValidateResult(true, ""); |
| | | } |
| | | |
| | | /** |
| | | * 验证传入参数“不为空”(非null且非空) |
| | | * @param value 参数值 |
| | | * @return 是否“不为空” |
| | | */ |
| | | public static Boolean checkNotNull(Object value) { |
| | | if(null == value) { |
| | | return false; |
| | | } |
| | | if(value instanceof String) { |
| | | String realValue = (String) value; |
| | | return realValue.replaceAll(ConstantFactory.STR_REGEX_SPACE, "").length()>0; |
| | | } else if(value instanceof List) { |
| | | List<?> realValue = (List)value; |
| | | return ListUtil.isNotNullOrEmpty(realValue); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 验证传入参数是否“大于”传入最小值 |
| | | * @param value 参数值 |
| | | * @param minValue 校验允许的最小值 |
| | | * @return 是否“大于”最小值 |
| | | */ |
| | | public static Boolean checkGreater(Object value, Object minValue) { |
| | | if(null == value) { |
| | | return false; |
| | | } |
| | | if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { |
| | | BigDecimal realValue = new BigDecimal(value.toString()); |
| | | BigDecimal realMin = new BigDecimal(minValue.toString()); |
| | | return realValue.compareTo(realMin)>0; |
| | | } else if(value instanceof Calendar) { |
| | | Calendar realValue = (Calendar)value; |
| | | Calendar realMin = (Calendar)minValue; |
| | | return realValue.compareTo(realMin)>0; |
| | | } else if(value instanceof LocalDateTime) { |
| | | LocalDateTime realValue = (LocalDateTime)value; |
| | | LocalDateTime realMin = (LocalDateTime)minValue; |
| | | return realValue.compareTo(realMin)>0; |
| | | } else if(value instanceof LocalDate) { |
| | | LocalDate realValue = (LocalDate)value; |
| | | LocalDate realMin = (LocalDate)minValue; |
| | | return realValue.compareTo(realMin)>0; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 验证传入参数是否“大于等于”传入最小值 |
| | | * @param value 参数值 |
| | | * @param minValue 校验允许的最小值 |
| | | * @return 是否“大于等于”传入最小值 |
| | | */ |
| | | public static Boolean checkGreaterThan(Object value, Object minValue) { |
| | | if(null == value) { |
| | | return false; |
| | | } |
| | | if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { |
| | | BigDecimal realValue = new BigDecimal(value.toString()); |
| | | BigDecimal realMin = new BigDecimal(minValue.toString()); |
| | | return realValue.compareTo(realMin)>=0; |
| | | }else if(value instanceof Calendar) { |
| | | Calendar realValue = (Calendar)value; |
| | | Calendar realMin = (Calendar)minValue; |
| | | return realValue.compareTo(realMin)>=0; |
| | | } else if(value instanceof LocalDateTime) { |
| | | LocalDateTime realValue = (LocalDateTime)value; |
| | | LocalDateTime realMin = (LocalDateTime)minValue; |
| | | return realValue.compareTo(realMin)>=0; |
| | | } else if(value instanceof LocalDate) { |
| | | LocalDate realValue = (LocalDate)value; |
| | | LocalDate realMin = (LocalDate)minValue; |
| | | return realValue.compareTo(realMin)>=0; |
| | | } |
| | | return true; |
| | | } |
| | | /** |
| | | * 验证传入参数是否“小于”传入最大值 |
| | | * @param value 参数值 |
| | | * @param maxValue 校验允许的最大值 |
| | | * @return 是否“小于”最大值 |
| | | */ |
| | | public static Boolean checkLess(Object value, Object maxValue) { |
| | | if(null == value) { |
| | | return true; |
| | | } |
| | | if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { |
| | | BigDecimal realValue = new BigDecimal(value.toString()); |
| | | BigDecimal realMax = new BigDecimal(maxValue.toString()); |
| | | return realValue.compareTo(realMax)<0; |
| | | } else if(value instanceof Calendar) { |
| | | Calendar realValue = (Calendar)value; |
| | | Calendar realMax = (Calendar)maxValue; |
| | | return realValue.compareTo(realMax)<0; |
| | | } else if(value instanceof LocalDateTime) { |
| | | LocalDateTime realValue = (LocalDateTime)value; |
| | | LocalDateTime realMax = (LocalDateTime)maxValue; |
| | | return realValue.compareTo(realMax)<0; |
| | | } else if(value instanceof LocalDate) { |
| | | LocalDate realValue = (LocalDate)value; |
| | | LocalDate realMax = (LocalDate)maxValue; |
| | | return realValue.compareTo(realMax)<0; |
| | | } |
| | | return true; |
| | | } |
| | | /** |
| | | * 验证传入参数是否“小于等于”传入最小值 |
| | | * @param value 参数值 |
| | | * @param maxValue 校验允许的最大值 |
| | | * @return 是否“小于等于”传入最小值 |
| | | */ |
| | | public static Boolean checkLessThan(Object value, Object maxValue) { |
| | | if(null == value) { |
| | | return true; |
| | | } |
| | | if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { |
| | | BigDecimal realValue = new BigDecimal(value.toString()); |
| | | BigDecimal realMax = new BigDecimal(maxValue.toString()); |
| | | return realValue.compareTo(realMax)<=0; |
| | | } else if(value instanceof Calendar) { |
| | | Calendar realValue = (Calendar)value; |
| | | Calendar realMax = (Calendar)maxValue; |
| | | return realValue.compareTo(realMax)<=0; |
| | | } else if(value instanceof LocalDateTime) { |
| | | LocalDateTime realValue = (LocalDateTime)value; |
| | | LocalDateTime realMax = (LocalDateTime)maxValue; |
| | | return realValue.compareTo(realMax)<=0; |
| | | } else if(value instanceof LocalDate) { |
| | | LocalDate realValue = (LocalDate)value; |
| | | LocalDate realMax = (LocalDate)maxValue; |
| | | return realValue.compareTo(realMax)<=0; |
| | | } |
| | | return true; |
| | | } |
| | | /** |
| | | * 验证传入参数是否符合指定“参数校验类型”格式 |
| | | * @param value 参数值 |
| | | * @param type 参数校验类型 |
| | | * @return 是否符合指定“参数校验类型”格式 |
| | | */ |
| | | public static Boolean checkIsMatch(Object value, EParameterValidateType type) { |
| | | Boolean result = false; |
| | | String realValue = String.valueOf(value); |
| | | switch (type) { |
| | | case MUST_DATE: |
| | | result = StringUtil.isMatch(realValue, ConstantFactory.REGEX_DATE); |
| | | break; |
| | | case MUST_DATE_TIME: |
| | | result = StringUtil.isMatch(realValue, ConstantFactory.REGEX_DATETIME); |
| | | break; |
| | | case MUST_EMAIL: |
| | | result = StringUtil.isEmail(realValue); |
| | | break; |
| | | case MUST_MOBILE_NUMBER: |
| | | result = StringUtil.isMobilePhone(realValue); |
| | | break; |
| | | case MUST_TELEPHONE_NUMBER: |
| | | result = StringUtil.isTelPhone(realValue); |
| | | break; |
| | | case MUST_PHONE_NUMBER: |
| | | result = (StringUtil.isTelPhone(realValue) || StringUtil.isMobilePhone(realValue)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * 验证传入参数是否符合指定“参数校验类型”格式 |
| | | * @param regex 正则表达式 |
| | | * @param value 参数值 |
| | | * @return 是否符合指定“参数校验类型”格式 |
| | | */ |
| | | public static Boolean checkIsMatch(String regex, Object value) { |
| | | return StringUtil.isMatch(String.valueOf(value), regex); |
| | | } |
| | | /** |
| | | * 验证传入参数是否是指定类型的“有效枚举值” |
| | | * @param value 参数值 |
| | | * @param enumType 枚举类型 |
| | | * @param <T> 枚举类型 |
| | | * @return 是否是“有效枚举值” |
| | | */ |
| | | public static <T extends Enum<T>> Boolean checkIsEnum(Object value, Class<T> enumType) { |
| | | if(value instanceof String) { |
| | | return StringUtil.isEnum(enumType, value.toString()); |
| | | } else if(value instanceof Integer) { |
| | | return NumericUtil.isEnum(enumType, ((Integer) value)); |
| | | } |
| | | return false; |
| | | } |
| | | /** |
| | | * 验证传入参数值是否在指定“最大值”和“最小值”范围内 |
| | | * @param value 参数值 |
| | | * @param minValue 校验允许的最大值 |
| | | * @param maxValue 校验允许的最小值 |
| | | * @return 是否在指定“最大值”和“最小值”范围内 |
| | | */ |
| | | public static Boolean checkInRange(Object value, Object minValue, Object maxValue) { |
| | | if(null == value) { |
| | | return false; |
| | | } |
| | | if(value instanceof Integer || value instanceof Long || value instanceof Double || value instanceof BigDecimal) { |
| | | BigDecimal realValue = new BigDecimal(value.toString()); |
| | | BigDecimal realMin = new BigDecimal(minValue.toString()); |
| | | BigDecimal realMax = new BigDecimal(maxValue.toString()); |
| | | return (realValue.compareTo(realMin)>=0 && realValue.compareTo(realMax)<=0); |
| | | } else if(value instanceof Calendar) { |
| | | Calendar realValue = (Calendar)value; |
| | | Calendar realMin = (Calendar)minValue; |
| | | Calendar realMax = (Calendar)maxValue; |
| | | return (realValue.compareTo(realMin)>=0 && realValue.compareTo(realMax)<=0); |
| | | } |
| | | return true; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | /** |
| | | * 键值对 dto |
| | | * @author lin.liu |
| | | * @description 键值对 dto |
| | | * @date 2021/4/7 |
| | | **/ |
| | | public class KeyValueDTO { |
| | | private String key; |
| | | private String value; |
| | | |
| | | public String getKey() { |
| | | return key; |
| | | } |
| | | |
| | | public void setKey(String key) { |
| | | this.key = key; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | public class NameSortDTO { |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Integer getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(Integer sort) { |
| | | this.sort = sort; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | public class NameSortIdDTO { |
| | | private Long id; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Integer getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(Integer sort) { |
| | | this.sort = sort; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | /** |
| | | * 名称-值 数据对象 |
| | | */ |
| | | public class NameValueDTO<T> { |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 值 |
| | | */ |
| | | private T value; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public T getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(T value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public NameValueDTO() { |
| | | } |
| | | |
| | | public NameValueDTO(String name, T value) { |
| | | this.name = name; |
| | | this.value = value; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | public class OrderByDTO { |
| | | /** |
| | | * 排序字段枚举(支持的枚举值请参照字段“ orderByEnum”说明中的枚举类型,无特殊说明使用通用排序枚举,“EOrderBy”) |
| | | */ |
| | | private Integer orderBy; |
| | | /** |
| | | * 是否升序排序 true=升序,不传或者其他任意值=降序(默认) |
| | | */ |
| | | private Boolean isAsc; |
| | | |
| | | public Integer getOrderBy() { |
| | | return orderBy; |
| | | } |
| | | |
| | | public void setOrderBy(Integer orderBy) { |
| | | this.orderBy = orderBy; |
| | | } |
| | | |
| | | public Boolean getIsAsc() { |
| | | return isAsc; |
| | | } |
| | | |
| | | public void setIsAsc(Boolean asc) { |
| | | isAsc = asc; |
| | | } |
| | | } |
| | | |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | /** |
| | | * 分页基本属性 dto |
| | | * @Author lin.liu |
| | | * @Description 分页基本属性 dto |
| | | * @Date 2021/4/7 |
| | | **/ |
| | | public class PagerBasicDTO { |
| | | /** |
| | | * 最后一条记录的id |
| | | * @ignore |
| | | */ |
| | | private Long lastRowNo; |
| | | /** |
| | | * 页大小(每页返回的记录条数) |
| | | */ |
| | | private Integer limit; |
| | | /** |
| | | * 页号(第几页,从1开始) |
| | | */ |
| | | private Integer page; |
| | | |
| | | public Long getLastRowNo() { |
| | | return lastRowNo; |
| | | } |
| | | |
| | | public void setLastRowNo(Long lastRowNo) { |
| | | this.lastRowNo = lastRowNo; |
| | | } |
| | | |
| | | public Integer getLimit() { |
| | | return limit; |
| | | } |
| | | |
| | | public void setLimit(Integer limit) { |
| | | this.limit = limit; |
| | | } |
| | | |
| | | public Integer getPage() { |
| | | return page; |
| | | } |
| | | |
| | | public void setPage(Integer page) { |
| | | this.page = page; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public class RequestDTO { |
| | | private Map<String, String> requestDataMap; |
| | | private String businessCode; |
| | | private String approveCode; |
| | | private String conditionColumn; |
| | | private Long conditionValue; |
| | | private Long creator_id; |
| | | private String creator_name; |
| | | private Long listAppRover; |
| | | private Integer applyStatus; |
| | | private Long id; |
| | | private String comment; |
| | | private Integer type; |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getComment() { |
| | | return comment; |
| | | } |
| | | |
| | | public void setComment(String comment) { |
| | | this.comment = comment; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getApplyStatus() { |
| | | return applyStatus; |
| | | } |
| | | |
| | | public void setApplyStatus(Integer applyStatus) { |
| | | this.applyStatus = applyStatus; |
| | | } |
| | | |
| | | public Long getListAppRover() { |
| | | return listAppRover; |
| | | } |
| | | |
| | | public void setListAppRover(Long listAppRover) { |
| | | this.listAppRover = listAppRover; |
| | | } |
| | | |
| | | public Long getCreator_id() { |
| | | return creator_id; |
| | | } |
| | | |
| | | public void setCreator_id(Long creator_id) { |
| | | this.creator_id = creator_id; |
| | | } |
| | | |
| | | public String getCreator_name() { |
| | | return creator_name; |
| | | } |
| | | |
| | | public void setCreator_name(String creator_name) { |
| | | this.creator_name = creator_name; |
| | | } |
| | | |
| | | public String getConditionColumn() { |
| | | return conditionColumn; |
| | | } |
| | | |
| | | public void setConditionColumn(String conditionColumn) { |
| | | this.conditionColumn = conditionColumn; |
| | | } |
| | | |
| | | public Long getConditionValue() { |
| | | return conditionValue; |
| | | } |
| | | |
| | | public void setConditionValue(Long conditionValue) { |
| | | this.conditionValue = conditionValue; |
| | | } |
| | | |
| | | public String getApproveCode() { |
| | | return approveCode; |
| | | } |
| | | |
| | | public void setApproveCode(String approveCode) { |
| | | this.approveCode = approveCode; |
| | | } |
| | | |
| | | public Map<String, String> getRequestDataMap() { |
| | | return requestDataMap; |
| | | } |
| | | |
| | | public void setRequestDataMap(Map<String, String> requestDataMap) { |
| | | this.requestDataMap = requestDataMap; |
| | | } |
| | | |
| | | public String getBusinessCode() { |
| | | return businessCode; |
| | | } |
| | | |
| | | public void setBusinessCode(String businessCode) { |
| | | this.businessCode = businessCode; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 分页查询基础 dto |
| | | * @Author lin.liu |
| | | * @Description 分页查询基础 dto |
| | | * @Date 2021/4/7 |
| | | **/ |
| | | public class SearchBasicDTO extends PagerBasicDTO { |
| | | /** |
| | | * 关键字 |
| | | */ |
| | | private String keywords; |
| | | /** |
| | | * 自增id列表 |
| | | */ |
| | | private List<Long> listId; |
| | | /** |
| | | * 数据状态 EState |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 数据状态列表 |
| | | */ |
| | | private List<Integer> listStatus; |
| | | /** |
| | | * 数据创建时间-范围(eg: 2021-01-01 00:00:00 ~ 2021-01-01 23:59:59)" |
| | | */ |
| | | private String createTimeRange; |
| | | /** |
| | | * 数据创建时间-起始 |
| | | * @ignore |
| | | */ |
| | | private Long createTimeStart; |
| | | /** |
| | | * 数据创建时间-截止 |
| | | * @ignore |
| | | */ |
| | | private Long createTimeEnd; |
| | | /** |
| | | * 上次请求最后一条数据的id |
| | | */ |
| | | private Long lastId; |
| | | /** |
| | | * 排序列表 |
| | | */ |
| | | private List<OrderByDTO> orderBy; |
| | | |
| | | public String getKeywords() { |
| | | return keywords; |
| | | } |
| | | |
| | | public void setKeywords(String keywords) { |
| | | this.keywords = keywords; |
| | | } |
| | | |
| | | public List<Long> getListId() { |
| | | return listId; |
| | | } |
| | | |
| | | public void setListId(List<Long> listId) { |
| | | this.listId = listId; |
| | | } |
| | | |
| | | public Integer getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(Integer status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public List<Integer> getListStatus() { |
| | | return listStatus; |
| | | } |
| | | |
| | | public void setListStatus(List<Integer> listStatus) { |
| | | this.listStatus = listStatus; |
| | | } |
| | | |
| | | public String getCreateTimeRange() { |
| | | return createTimeRange; |
| | | } |
| | | |
| | | public void setCreateTimeRange(String createTimeRange) { |
| | | this.createTimeRange = createTimeRange; |
| | | } |
| | | |
| | | public Long getCreateTimeStart() { |
| | | return createTimeStart; |
| | | } |
| | | |
| | | public void setCreateTimeStart(Long createTimeStart) { |
| | | this.createTimeStart = createTimeStart; |
| | | } |
| | | |
| | | public Long getCreateTimeEnd() { |
| | | return createTimeEnd; |
| | | } |
| | | |
| | | public void setCreateTimeEnd(Long createTimeEnd) { |
| | | this.createTimeEnd = createTimeEnd; |
| | | } |
| | | |
| | | public Long getLastId() { |
| | | return lastId; |
| | | } |
| | | |
| | | public void setLastId(Long lastId) { |
| | | this.lastId = lastId; |
| | | } |
| | | |
| | | public List<OrderByDTO> getOrderBy() { |
| | | return orderBy; |
| | | } |
| | | |
| | | public void setOrderBy(List<OrderByDTO> orderBy) { |
| | | this.orderBy = orderBy; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SearchBasicDTO{" + |
| | | "keywords='" + keywords + '\'' + |
| | | ", listId=" + listId + |
| | | ", status=" + status + |
| | | ", listStatus=" + listStatus + |
| | | ", createTimeRange='" + createTimeRange + '\'' + |
| | | ", createTimeStart=" + createTimeStart + |
| | | ", createTimeEnd=" + createTimeEnd + |
| | | ", lastId=" + lastId + |
| | | ", orderBy='" + orderBy + '\'' + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | public class UploadResultVo { |
| | | /** |
| | | * 文件id,传参后原样输出,前端比对文件用,无实际意义。 |
| | | */ |
| | | private String fileId; |
| | | /** |
| | | * 原始文件名称 传参后原样输出 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 新文件名称(需要保存数据库的虚拟路径) |
| | | */ |
| | | private String newFileName; |
| | | /** |
| | | * 文件预览地址 |
| | | */ |
| | | private String newFileView; |
| | | /** |
| | | * 文件类型 |
| | | */ |
| | | private String fileType; |
| | | /** |
| | | * 文件媒体类型 |
| | | */ |
| | | private String contentType; |
| | | /** |
| | | * 文件大小(kb) |
| | | */ |
| | | private Long size; |
| | | |
| | | public String getFileId() { |
| | | return fileId; |
| | | } |
| | | |
| | | public void setFileId(String fileId) { |
| | | this.fileId = fileId; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getNewFileName() { |
| | | return newFileName; |
| | | } |
| | | |
| | | public void setNewFileName(String newFileName) { |
| | | this.newFileName = newFileName; |
| | | } |
| | | |
| | | public String getNewFileView() { |
| | | return newFileView; |
| | | } |
| | | |
| | | public void setNewFileView(String newFileView) { |
| | | this.newFileView = newFileView; |
| | | } |
| | | |
| | | public String getFileType() { |
| | | return fileType; |
| | | } |
| | | |
| | | public void setFileType(String fileType) { |
| | | this.fileType = fileType; |
| | | } |
| | | |
| | | public String getContentType() { |
| | | return contentType; |
| | | } |
| | | |
| | | public void setContentType(String contentType) { |
| | | this.contentType = contentType; |
| | | } |
| | | |
| | | public Long getSize() { |
| | | return size; |
| | | } |
| | | |
| | | public void setSize(Long size) { |
| | | this.size = size; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.dto; |
| | | |
| | | public class UserInfoDto { |
| | | /** |
| | | * 联系方式 |
| | | */ |
| | | private String contact; |
| | | /** |
| | | * 数据创建时间 |
| | | */ |
| | | private Long createTime; |
| | | private String createTimeView; |
| | | /** |
| | | * 联系邮箱 |
| | | */ |
| | | private String email; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String headImg; |
| | | /** |
| | | * 自增id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String nickName; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | /** |
| | | * 状态(EState) 正常=1,关闭=2 |
| | | */ |
| | | private Long status; |
| | | /** |
| | | * 数据最后更新时间 |
| | | */ |
| | | private String updateTime; |
| | | private String updateTimeView; |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String userName; |
| | | /** |
| | | * 用户关联id,和“user_type”对应,如:客户id等 |
| | | */ |
| | | private Long userRelId; |
| | | /** |
| | | * 用户类型 EUserType |
| | | */ |
| | | private Long userType; |
| | | |
| | | public String getContact() { |
| | | return contact; |
| | | } |
| | | |
| | | public void setContact(String contact) { |
| | | this.contact = contact; |
| | | } |
| | | |
| | | public Long getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Long createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public String getCreateTimeView() { |
| | | return createTimeView; |
| | | } |
| | | |
| | | public void setCreateTimeView(String createTimeView) { |
| | | this.createTimeView = createTimeView; |
| | | } |
| | | |
| | | public String getEmail() { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) { |
| | | this.email = email; |
| | | } |
| | | |
| | | public String getHeadImg() { |
| | | return headImg; |
| | | } |
| | | |
| | | public void setHeadImg(String headImg) { |
| | | this.headImg = headImg; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getNickName() { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | public String getPassword() { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) { |
| | | this.password = password; |
| | | } |
| | | |
| | | public Long getRoleId() { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(Long roleId) { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public Long getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(Long status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(String updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getUpdateTimeView() { |
| | | return updateTimeView; |
| | | } |
| | | |
| | | public void setUpdateTimeView(String updateTimeView) { |
| | | this.updateTimeView = updateTimeView; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public Long getUserRelId() { |
| | | return userRelId; |
| | | } |
| | | |
| | | public void setUserRelId(Long userRelId) { |
| | | this.userRelId = userRelId; |
| | | } |
| | | |
| | | public Long getUserType() { |
| | | return userType; |
| | | } |
| | | |
| | | public void setUserType(Long userType) { |
| | | this.userType = userType; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 数据变更类型 通用枚举 |
| | | * @author linliu |
| | | * @date 2019-01-02 |
| | | */ |
| | | public enum EDataChangeType { |
| | | /** |
| | | * 新增 |
| | | */ |
| | | CREATE("新增", 1), |
| | | /** |
| | | * 修改 |
| | | */ |
| | | MODIFY("修改", 2), |
| | | /** |
| | | * 停用 |
| | | */ |
| | | DISABLED("停用", 3), |
| | | /** |
| | | * 启用 |
| | | */ |
| | | ENABLED("启用", 4), |
| | | /** |
| | | * 删除 |
| | | */ |
| | | DELETED("删除", 5); |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | private EDataChangeType(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EDataChangeType getByValue(Integer value) { |
| | | return Arrays.stream(EDataChangeType.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EDataChangeType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | public enum EExecuteType { |
| | | /** |
| | | * 待执行 |
| | | */ |
| | | NOT_EXECUTE("待执行", 1), |
| | | /** |
| | | * 执行中 |
| | | */ |
| | | IN_EXECUTE("执行中", 2), |
| | | /** |
| | | * 已执行 |
| | | */ |
| | | YES_EXECUTE("已执行", 3), |
| | | /** |
| | | * 撤销 |
| | | */ |
| | | ANNUL_EXECUTE("撤销", 4); |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | private EExecuteType(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EExecuteType getByValue(Integer value) { |
| | | return Arrays.stream(EExecuteType.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EExecuteType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 数据处理状态 通用枚举 |
| | | * @author lin.liu |
| | | * @date 2019-01-08 |
| | | */ |
| | | public enum EHandleStatus { |
| | | /** |
| | | * 待处理 |
| | | */ |
| | | AWAITING("待处理", 100), |
| | | /** |
| | | *处理中 |
| | | */ |
| | | PROCESSING("处理中", 101), |
| | | /** |
| | | * 已处理 |
| | | */ |
| | | SUCCESS("已处理", 200), |
| | | /** |
| | | * 处理失败 |
| | | */ |
| | | FAILED("处理失败", 300); |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EHandleStatus(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EHandleStatus getByValue(Integer value) { |
| | | return Arrays.stream(EHandleStatus.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EHandleStatus{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | public enum ELockValue { |
| | | /** |
| | | * 管理员变更 |
| | | */ |
| | | ADMIN_CHANGE |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | public enum EMenuType { |
| | | /** |
| | | * 目录=1, |
| | | */ |
| | | FOLDER("目录", 1), |
| | | /** |
| | | * 页面=2, |
| | | */ |
| | | PAGE("页面", 2), |
| | | ; |
| | | |
| | | /** |
| | | * 枚举描述 |
| | | */ |
| | | private String desc; |
| | | /** |
| | | * 枚举值 |
| | | */ |
| | | private Integer value; |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EMenuType(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EMenuType getByValue(Integer value) { |
| | | return Arrays.stream(EMenuType.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EMenuType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 操作类型 |
| | | * @author linliu |
| | | * @date 2019-01-02 |
| | | */ |
| | | public enum EOperation { |
| | | /** |
| | | * 搜索 |
| | | */ |
| | | LIST("搜索", "list"), |
| | | /** |
| | | * 保存(新增+编辑) |
| | | */ |
| | | SAVE("保存(新增+编辑)", "save"), |
| | | /** |
| | | * 新增 |
| | | */ |
| | | ADD("新增", "add"), |
| | | /** |
| | | * 详情 |
| | | */ |
| | | DETAIL("详情", "detail"), |
| | | /** |
| | | * 修改 |
| | | */ |
| | | UPDATE("修改", "update"), |
| | | /** |
| | | * 停用 |
| | | */ |
| | | DISABLED("停用", "disable"), |
| | | /** |
| | | * 启用 |
| | | */ |
| | | ENABLED("启用", "enable"), |
| | | /** |
| | | * 删除 |
| | | */ |
| | | DELETED("删除", "delete"), |
| | | /** |
| | | * 导入 |
| | | */ |
| | | IMPORT("导入", "import"), |
| | | /** |
| | | * 导出 |
| | | */ |
| | | EXPORT("导出", "export"), |
| | | /** |
| | | * 打印 |
| | | */ |
| | | PRINT("打印", "print"), |
| | | ; |
| | | |
| | | private String desc;//枚举描述 |
| | | private String value;//枚举值 |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EOperation(String desc, String value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EOperation getByValue(String value) { |
| | | return Arrays.stream(EOperation.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EOperation{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 通用排序类型 枚举 |
| | | */ |
| | | public enum EOrderBy { |
| | | /** |
| | | * 自增id=1, |
| | | */ |
| | | ID("自增id", 1), |
| | | /** |
| | | * 创建时间=2, |
| | | */ |
| | | CREATE_TIME("创建时间", 2), |
| | | /** |
| | | * 更新时间=3, |
| | | */ |
| | | UPDATE_TIME("更新时间", 3); |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EOrderBy(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EOrderBy getByValue(Integer value) { |
| | | return Arrays.stream(EOrderBy.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EOrderBy{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | public enum EParameterType { |
| | | /** |
| | | * 固定值=1, |
| | | */ |
| | | CONSTANT("固定值", 1), |
| | | /** |
| | | * 范围=2, |
| | | */ |
| | | RANGE("范围", 2); |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EParameterType(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EParameterType getByValue(Integer value) { |
| | | return Arrays.stream(EParameterType.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EParameterType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | public enum ESex { |
| | | /** |
| | | * 男=1, |
| | | */ |
| | | MALE("男", 1), |
| | | /** |
| | | * 女=2, |
| | | */ |
| | | FEMALE("女", 2), |
| | | /** |
| | | * 其他=3, |
| | | */ |
| | | OTHER("其他", 3); |
| | | |
| | | /** |
| | | * 枚举描述 |
| | | */ |
| | | private String desc; |
| | | /** |
| | | * 枚举值 |
| | | */ |
| | | private Integer value; |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | ESex(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static ESex getByValue(Integer value) { |
| | | return Arrays.stream(ESex.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ESex{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 带排序值的排序类型 枚举 |
| | | */ |
| | | public enum ESortOrderBy { |
| | | /** |
| | | * 自增id=1, |
| | | */ |
| | | ID("自增id", 1), |
| | | /** |
| | | * 创建时间=2, |
| | | */ |
| | | CREATE_TIME("创建时间", 2), |
| | | /** |
| | | * 更新时间=3, |
| | | */ |
| | | UPDATE_TIME("更新时间", 3), |
| | | /** |
| | | * 排序值=4, |
| | | */ |
| | | SORT("排序值", 4); |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | ESortOrderBy(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static ESortOrderBy getByValue(Integer value) { |
| | | return Arrays.stream(ESortOrderBy.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ESortOrderBy{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 状态 枚举 |
| | | */ |
| | | public enum EState { |
| | | /** |
| | | * 正常=1, |
| | | */ |
| | | NORMAL("正常", 1), |
| | | /** |
| | | * 关闭/停用=2, |
| | | */ |
| | | DISABLED("关闭/停用", 2), |
| | | /** |
| | | * 删除=3, |
| | | */ |
| | | DELETED("删除", 3); |
| | | |
| | | /** |
| | | * 枚举描述 |
| | | */ |
| | | private String desc; |
| | | /** |
| | | * 枚举值 |
| | | */ |
| | | private Integer value; |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EState(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EState getByValue(Integer value) { |
| | | return Arrays.stream(EState.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EState{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.enums; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 用户类型 枚举 |
| | | */ |
| | | public enum EUserType { |
| | | /** |
| | | * 超级管理员=1, |
| | | */ |
| | | ADMIN("超级管理员", 1), |
| | | /** |
| | | * 普通管理员=2, |
| | | */ |
| | | ADMIN_USER("普通管理员", 2), |
| | | |
| | | ; |
| | | |
| | | private String desc;//枚举描述 |
| | | private Integer value;//枚举值 |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * 构造方法 |
| | | * @param desc 枚举描述 |
| | | * @param value 枚举值 |
| | | */ |
| | | EUserType(String desc, Integer value) { |
| | | this.desc = desc; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * 根据值获取枚举 |
| | | * |
| | | * @param value 枚举值 |
| | | * @return |
| | | */ |
| | | public static EUserType getByValue(Integer value) { |
| | | return Arrays.stream(EUserType.values()) |
| | | .filter(e -> Objects.equals(e.getValue(), value)) |
| | | .findAny() |
| | | .orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "EUserType{" + |
| | | "desc='" + desc + '\'' + |
| | | ", value=" + value + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | public class AdminSendMail { |
| | | |
| | | private String username; |
| | | private String password; |
| | | |
| | | public String getUsername() { |
| | | return username; |
| | | } |
| | | |
| | | public void setUsername(String username) { |
| | | this.username = username; |
| | | } |
| | | |
| | | public String getPassword() { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) { |
| | | this.password = password; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | public class ReqChangePassword { |
| | | /** |
| | | * 旧密码 |
| | | * @required |
| | | */ |
| | | private String oldPassword; |
| | | /** |
| | | * 新密码 |
| | | * @required |
| | | */ |
| | | private String newPassword; |
| | | |
| | | public String getOldPassword() { |
| | | return oldPassword; |
| | | } |
| | | |
| | | public void setOldPassword(String oldPassword) { |
| | | this.oldPassword = oldPassword; |
| | | } |
| | | |
| | | public String getNewPassword() { |
| | | return newPassword; |
| | | } |
| | | |
| | | public void setNewPassword(String newPassword) { |
| | | this.newPassword = newPassword; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class ReqListId { |
| | | /** |
| | | * id列表 |
| | | * @required |
| | | */ |
| | | private List<Long> listId; |
| | | |
| | | public List<Long> getListId() { |
| | | return listId; |
| | | } |
| | | |
| | | public void setListId(List<Long> listId) { |
| | | this.listId = listId; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 批量设置顺序 对象 |
| | | */ |
| | | public class ReqListSetSort { |
| | | /** |
| | | * 设置顺序列表 |
| | | * @required |
| | | */ |
| | | private List<ReqSetSort> list; |
| | | |
| | | public List<ReqSetSort> getList() { |
| | | return list; |
| | | } |
| | | |
| | | public void setList(List<ReqSetSort> list) { |
| | | this.list = list; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class ReqListStatus { |
| | | /** |
| | | * 状态列表 |
| | | */ |
| | | private List<Integer> listStatus; |
| | | |
| | | public List<Integer> getListStatus() { |
| | | return listStatus; |
| | | } |
| | | |
| | | public void setListStatus(List<Integer> listStatus) { |
| | | this.listStatus = listStatus; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | |
| | | |
| | | public class ReqNeedCode { |
| | | /** |
| | | * 编号 |
| | | * @required |
| | | */ |
| | | private String code; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | public class ReqNeedId { |
| | | /** |
| | | * 自增id |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | public class ReqOperate { |
| | | /** |
| | | * 业务id |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 操作备注 |
| | | * @required |
| | | */ |
| | | private String comment; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getComment() { |
| | | return comment; |
| | | } |
| | | |
| | | public void setComment(String comment) { |
| | | this.comment = comment; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | public class ReqSetSort { |
| | | /** |
| | | * 自增id |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 排序值 |
| | | * @required |
| | | */ |
| | | private Integer sort; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(Integer sort) { |
| | | this.sort = sort; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request; |
| | | |
| | | public class ReqUserLogin { |
| | | /** |
| | | * 登录账户 |
| | | * @required |
| | | */ |
| | | private String userName; |
| | | /** |
| | | * 密码 |
| | | * @required |
| | | */ |
| | | private String password; |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public String getPassword() { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) { |
| | | this.password = password; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminmenu; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台菜单 |
| | | * @author lin.liu |
| | | * @description 后台菜单 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminMenu { |
| | | /** |
| | | * 类型 EMenuType |
| | | * @required |
| | | */ |
| | | private Integer type; |
| | | /** |
| | | * 父级ID |
| | | */ |
| | | private Long parentId; |
| | | /** |
| | | * 菜单名称 |
| | | * @required |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 菜单标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 前端资源路径 |
| | | */ |
| | | private String url; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminmenu; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台菜单 |
| | | * @author lin.liu |
| | | * @description 后台菜单 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminMenu { |
| | | /** |
| | | * 主键 |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 类型 EMenuType |
| | | * @required |
| | | */ |
| | | private Integer type; |
| | | /** |
| | | * 父级ID |
| | | */ |
| | | private Long parentId; |
| | | /** |
| | | * 菜单名称 |
| | | * @required |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 菜单标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 前端资源路径 |
| | | */ |
| | | private String url; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminmenus; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminMenus { |
| | | /** |
| | | * 父级id |
| | | */ |
| | | private Long parentId; |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 菜单标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 前端资源路径 |
| | | */ |
| | | private String uri; |
| | | /** |
| | | * 菜单层级 |
| | | */ |
| | | private Integer level; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminmenus; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminMenus { |
| | | /** |
| | | * 主键id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 父级id |
| | | */ |
| | | private Long parentId; |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 菜单标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 前端资源路径 |
| | | */ |
| | | private String uri; |
| | | /** |
| | | * 菜单层级 |
| | | */ |
| | | private Integer level; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminpermission; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台用户权限表 |
| | | * @author lin.liu |
| | | * @description 后台用户权限表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminPermission { |
| | | /** |
| | | * 权限值 |
| | | */ |
| | | private String sn; |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long menuId; |
| | | /** |
| | | * 前端资源url |
| | | */ |
| | | private String menuUrl; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | /** |
| | | * 权限类型 EOperation |
| | | */ |
| | | private String type; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminpermission; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台用户权限表 |
| | | * @author lin.liu |
| | | * @description 后台用户权限表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminPermission { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 权限值 |
| | | */ |
| | | private String sn; |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long menuId; |
| | | /** |
| | | * 前端资源url |
| | | */ |
| | | private String menuUrl; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | /** |
| | | * 权限类型 EOperation |
| | | */ |
| | | private String type; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrole; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台用户角色表 |
| | | * @author lin.liu |
| | | * @description 后台用户角色表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminRole { |
| | | /** |
| | | * 角色名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 描述 |
| | | */ |
| | | private String description; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrole; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台用户角色表 |
| | | * @author lin.liu |
| | | * @description 后台用户角色表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminRole { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 角色名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 描述 |
| | | */ |
| | | private String description; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrolemenurelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台角色菜单关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色菜单关系表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminRoleMenuRelation { |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long menuId; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrolemenurelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台角色菜单关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色菜单关系表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminRoleMenuRelation { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long menuId; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.adminrolemenurelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ReqSetListMenu4Role { |
| | | /** |
| | | * 角色id |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 菜单列表 |
| | | * @required |
| | | **/ |
| | | private List<Long> listMenu; |
| | | /** |
| | | * 权限列表 |
| | | * @required |
| | | **/ |
| | | private List<Long> listPermission; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.adminrolemenurelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ReqSetListRole4Admin { |
| | | /** |
| | | * 管理员id |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 角色列表 |
| | | * @required |
| | | **/ |
| | | private List<Long> listRole; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrolepermissionrelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台角色权限关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色权限关系表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminRolePermissionRelation { |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | /** |
| | | * 权限id |
| | | */ |
| | | private Long permissionId; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrolepermissionrelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台角色权限关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色权限关系表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminRolePermissionRelation { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | /** |
| | | * 权限id |
| | | */ |
| | | private Long permissionId; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrolerelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台用户和角色关系表 |
| | | * @author lin.liu |
| | | * @description 后台用户和角色关系表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminRoleRelation { |
| | | /** |
| | | * 管理员id |
| | | */ |
| | | private Long adminId; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminrolerelation; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台用户和角色关系表 |
| | | * @author lin.liu |
| | | * @description 后台用户和角色关系表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminRoleRelation { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 管理员id |
| | | */ |
| | | private Long adminId; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.adminuser; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ReqAdminLogin { |
| | | /** |
| | | * 登录账户 |
| | | * @required |
| | | */ |
| | | private String userName; |
| | | /** |
| | | * 密码 |
| | | * @required |
| | | */ |
| | | private String password; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminuser; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 管理员帐号 |
| | | * @author lin.liu |
| | | * @description 管理员帐号 |
| | | */ |
| | | @Data |
| | | public class ReqCreateAdminUser { |
| | | /** |
| | | * 用户类型 EUserType |
| | | */ |
| | | private Integer userType; |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String userName; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String nickName; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String headImg; |
| | | /** |
| | | * 联系方式 |
| | | */ |
| | | private String contact; |
| | | /** |
| | | * 联系邮箱 |
| | | */ |
| | | private String email; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.adminuser; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 管理员帐号 |
| | | * @author lin.liu |
| | | * @description 管理员帐号 |
| | | */ |
| | | @Data |
| | | public class ReqModifyAdminUser { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 用户类型 EUserType |
| | | */ |
| | | private Integer userType; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String nickName; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String headImg; |
| | | /** |
| | | * 联系方式 |
| | | */ |
| | | private String contact; |
| | | /** |
| | | * 联系邮箱 |
| | | */ |
| | | private String email; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.adminuser; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ReqSetListRole4Admin { |
| | | /** |
| | | * 管理员id |
| | | * @required |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 角色列表 |
| | | * @required |
| | | **/ |
| | | private List<Long> listRole; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.notice; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 公告 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class ReqCreateNotice { |
| | | /** |
| | | * 发布人 |
| | | */ |
| | | private String publishUser; |
| | | /** |
| | | * 标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 摘要 |
| | | */ |
| | | private String summary; |
| | | /** |
| | | * 内容 |
| | | */ |
| | | private String content; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer sort; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.notice; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 公告 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class ReqModifyNotice { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 发布人 |
| | | */ |
| | | private String publishUser; |
| | | /** |
| | | * 标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 摘要 |
| | | */ |
| | | private String summary; |
| | | /** |
| | | * 内容 |
| | | */ |
| | | private String content; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 状态(EState) |
| | | */ |
| | | private Integer status; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.quartztaskerror; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务错误信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务错误信息表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateQuartzTaskError { |
| | | /** |
| | | * 任务执行记录Id |
| | | */ |
| | | private String taskExecuteRecordId; |
| | | /** |
| | | * 任务执行记录Id |
| | | */ |
| | | private String errorKey; |
| | | /** |
| | | * 任务执行记录Id |
| | | */ |
| | | private String errorValue; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.quartztaskerror; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务错误信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务错误信息表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyQuartzTaskError { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 任务执行记录Id |
| | | */ |
| | | private String taskExecuteRecordId; |
| | | /** |
| | | * 任务执行记录Id |
| | | */ |
| | | private String errorKey; |
| | | /** |
| | | * 任务执行记录Id |
| | | */ |
| | | private String errorValue; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.quartztaskinfo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务信息表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateQuartzTaskInfo { |
| | | /** |
| | | * 任务名称 |
| | | */ |
| | | private String taskName; |
| | | /** |
| | | * 定时规则表达式 |
| | | */ |
| | | private String schedulerRule; |
| | | /** |
| | | * 执行方 |
| | | */ |
| | | private String executor; |
| | | /** |
| | | * 执行参数 |
| | | */ |
| | | private String executeParameter; |
| | | /** |
| | | * 执行结果发送方式 |
| | | */ |
| | | private String sendType; |
| | | /** |
| | | * 执行结果发送请求地址 |
| | | */ |
| | | private String url; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.quartztaskinfo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务信息表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyQuartzTaskInfo { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 任务名称 |
| | | */ |
| | | private String taskName; |
| | | /** |
| | | * 定时规则表达式 |
| | | */ |
| | | private String schedulerRule; |
| | | /** |
| | | * 执行方 |
| | | */ |
| | | private String executor; |
| | | /** |
| | | * 执行参数 |
| | | */ |
| | | private String executeParameter; |
| | | /** |
| | | * 任务状态 EState |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 执行结果发送方式 |
| | | */ |
| | | private String sendType; |
| | | /** |
| | | * 执行结果发送请求地址 |
| | | */ |
| | | private String url; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.quartztaskinfo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ReqRunTaskRightNow { |
| | | /** |
| | | * 任务id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 执行参数 |
| | | */ |
| | | private String executeParameter; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.quartztaskrecord; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务执行情况记录表 |
| | | * @author lin.liu |
| | | * @description 定时任务执行情况记录表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateQuartzTaskRecord { |
| | | /** |
| | | * 任务编号 |
| | | */ |
| | | private String taskNo; |
| | | /** |
| | | * 执行时间格式值 |
| | | */ |
| | | private String timeKeyValue; |
| | | /** |
| | | * 执行时间 |
| | | */ |
| | | private Long executeTime; |
| | | /** |
| | | * 任务状态 |
| | | */ |
| | | private String taskStatus; |
| | | /** |
| | | * 失败统计数 |
| | | */ |
| | | private Long failCount; |
| | | /** |
| | | * 失败错误描述 |
| | | */ |
| | | private String failReason; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.quartztaskrecord; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务执行情况记录表 |
| | | * @author lin.liu |
| | | * @description 定时任务执行情况记录表 |
| | | */ |
| | | @Data |
| | | public class ReqModifyQuartzTaskRecord { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 任务编号 |
| | | */ |
| | | private String taskNo; |
| | | /** |
| | | * 执行时间格式值 |
| | | */ |
| | | private String timeKeyValue; |
| | | /** |
| | | * 执行时间 |
| | | */ |
| | | private Long executeTime; |
| | | /** |
| | | * 任务状态 |
| | | */ |
| | | private String taskStatus; |
| | | /** |
| | | * 失败统计数 |
| | | */ |
| | | private Long failCount; |
| | | /** |
| | | * 失败错误描述 |
| | | */ |
| | | private String failReason; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.sysdictdata; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 字典数据表 |
| | | * @author lin.liu |
| | | * @description 字典数据表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateSysDictData { |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | private String dictType; |
| | | /** |
| | | * 字典标题 |
| | | */ |
| | | private String dictLabel; |
| | | /** |
| | | * 字典键值 |
| | | */ |
| | | private String dictValue; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.sysdictdata; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 字典数据表 |
| | | * @author lin.liu |
| | | * @description 字典数据表 |
| | | */ |
| | | @Data |
| | | public class ReqModifySysDictData { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 字典标题 |
| | | */ |
| | | private String dictLabel; |
| | | /** |
| | | * 字典键值 |
| | | */ |
| | | private String dictValue; |
| | | /** |
| | | * 状态 |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.sysdicttype; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 字典类型表 |
| | | * @author lin.liu |
| | | * @description 字典类型表 |
| | | */ |
| | | @Data |
| | | public class ReqCreateSysDictType { |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | private String dictType; |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | private String dictName; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.sysdicttype; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 字典类型表 |
| | | * @author lin.liu |
| | | * @description 字典类型表 |
| | | */ |
| | | @Data |
| | | public class ReqModifySysDictType { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | private String dictName; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.test; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class ReqCreateTestInfo { |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private Long userId; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 余额 |
| | | */ |
| | | private BigDecimal balance; |
| | | /** |
| | | * 性别 ESex |
| | | */ |
| | | private Integer sex; |
| | | /** |
| | | * 生日 |
| | | */ |
| | | private String birthday; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String comment; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Long getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Long userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public String getPhone() { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | public BigDecimal getBalance() { |
| | | return balance; |
| | | } |
| | | |
| | | public void setBalance(BigDecimal balance) { |
| | | this.balance = balance; |
| | | } |
| | | |
| | | public Integer getSex() { |
| | | return sex; |
| | | } |
| | | |
| | | public void setSex(Integer sex) { |
| | | this.sex = sex; |
| | | } |
| | | |
| | | public String getBirthday() { |
| | | return birthday; |
| | | } |
| | | |
| | | public void setBirthday(String birthday) { |
| | | this.birthday = birthday; |
| | | } |
| | | |
| | | public Integer getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(Integer sort) { |
| | | this.sort = sort; |
| | | } |
| | | |
| | | public String getComment() { |
| | | return comment; |
| | | } |
| | | |
| | | public void setComment(String comment) { |
| | | this.comment = comment; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.request.test; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class ReqModifyTestInfo { |
| | | /** |
| | | * 自增id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private Long userId; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 余额 |
| | | */ |
| | | private BigDecimal balance; |
| | | /** |
| | | * 性别 ESex |
| | | */ |
| | | private Integer sex; |
| | | /** |
| | | * 生日 |
| | | */ |
| | | private String birthday; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String comment; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Long getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Long userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public String getPhone() { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | public BigDecimal getBalance() { |
| | | return balance; |
| | | } |
| | | |
| | | public void setBalance(BigDecimal balance) { |
| | | this.balance = balance; |
| | | } |
| | | |
| | | public Integer getSex() { |
| | | return sex; |
| | | } |
| | | |
| | | public void setSex(Integer sex) { |
| | | this.sex = sex; |
| | | } |
| | | |
| | | public String getBirthday() { |
| | | return birthday; |
| | | } |
| | | |
| | | public void setBirthday(String birthday) { |
| | | this.birthday = birthday; |
| | | } |
| | | |
| | | public Integer getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(Integer sort) { |
| | | this.sort = sort; |
| | | } |
| | | |
| | | public String getComment() { |
| | | return comment; |
| | | } |
| | | |
| | | public void setComment(String comment) { |
| | | this.comment = comment; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.testinfo; |
| | | |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 测试信息表 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class ReqCreateTestInfo { |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private Long userId; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * balance余额 |
| | | */ |
| | | private BigDecimal balance; |
| | | /** |
| | | * 性别 男=1,女=2,其他=3 |
| | | */ |
| | | private Integer sex; |
| | | /** |
| | | * 生日 |
| | | */ |
| | | private String birthday; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String comment; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.entity.request.testinfo; |
| | | |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 测试信息表 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class ReqModifyTestInfo { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private Long userId; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * balance余额 |
| | | */ |
| | | private BigDecimal balance; |
| | | /** |
| | | * 性别 男=1,女=2,其他=3 |
| | | */ |
| | | private Integer sex; |
| | | /** |
| | | * 生日 |
| | | */ |
| | | private String birthday; |
| | | /** |
| | | * 排序值 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String comment; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.response; |
| | | |
| | | public class ResNameValue { |
| | | /** |
| | | * 名称 |
| | | **/ |
| | | private String name; |
| | | /** |
| | | * 值 |
| | | **/ |
| | | private String value; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.response.admin; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ResAdminLogin { |
| | | /** |
| | | * 管理员id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 用户类型 EUserType |
| | | */ |
| | | private Integer userType; |
| | | |
| | | /** |
| | | * 管理员名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 请求令牌 |
| | | */ |
| | | private String token; |
| | | /** |
| | | * 菜单列表 |
| | | */ |
| | | private List<ResAdminMenuTree> menus; |
| | | /** |
| | | * 权限列表 |
| | | */ |
| | | private List<String> listPermission; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.response.admin; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ResAdminMenuTree { |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 类型 EMenuType |
| | | * @required |
| | | */ |
| | | private Integer type; |
| | | /** |
| | | * 父级ID |
| | | */ |
| | | private Long parentId; |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 菜单标题 |
| | | */ |
| | | private String title; |
| | | /** |
| | | * 前端资源路径 |
| | | */ |
| | | private String url; |
| | | /** |
| | | * 菜单层级 |
| | | */ |
| | | private Integer level; |
| | | /** |
| | | * 排序 越大越靠前 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | /** |
| | | * 子级菜单列表 |
| | | */ |
| | | private List<ResAdminMenuTreeAndPermission> children; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.response.admin; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ResAdminMenuTreeAndPermission extends ResAdminMenuTree { |
| | | /** |
| | | * 权限列表 |
| | | */ |
| | | private List<ResAdminPermission> permissions; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.response.admin; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ResAdminPermission { |
| | | /** |
| | | * 权限id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 权限值 |
| | | */ |
| | | private String sn; |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long menuId; |
| | | |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 状态 EState |
| | | */ |
| | | private Integer status; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.response.admin; |
| | | |
| | | import com.fengdu.gas.repository.vo.AdminMenuVO; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ResAdminPower { |
| | | /** |
| | | * 菜单列表 |
| | | */ |
| | | private List<AdminMenuVO> menus; |
| | | /** |
| | | * 权限列表 |
| | | */ |
| | | private List<ResAdminPermission> permissions; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 后台菜单 |
| | | * @author lin.liu |
| | | * @description 后台菜单 |
| | | */ |
| | | @Data |
| | | public class SearchAdminMenu extends SearchBasicDTO { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class SearchAdminMenus extends SearchBasicDTO { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 后台用户权限表 |
| | | * @author lin.liu |
| | | * @description 后台用户权限表 |
| | | */ |
| | | public class SearchAdminPermission extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchAdminPermission{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 后台用户角色表 |
| | | * @author lin.liu |
| | | * @description 后台用户角色表 |
| | | */ |
| | | public class SearchAdminRole extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchAdminRole{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 后台角色菜单关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色菜单关系表 |
| | | */ |
| | | public class SearchAdminRoleMenuRelation extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchAdminRoleMenuRelation{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 后台角色权限关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色权限关系表 |
| | | */ |
| | | public class SearchAdminRolePermissionRelation extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchAdminRolePermissionRelation{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 后台用户和角色关系表 |
| | | * @author lin.liu |
| | | * @description 后台用户和角色关系表 |
| | | */ |
| | | public class SearchAdminRoleRelation extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchAdminRoleRelation{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 管理员帐号 |
| | | * @author lin.liu |
| | | * @description 管理员帐号 |
| | | */ |
| | | public class SearchAdminUser extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchAdminUser{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 公告 |
| | | * @author lin.liu |
| | | */ |
| | | @Data |
| | | public class SearchNotice extends SearchBasicDTO { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 定时任务错误信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务错误信息表 |
| | | */ |
| | | public class SearchQuartzTaskError extends SearchBasicDTO { |
| | | @Override |
| | | public String toString() { |
| | | return "SearchQuartzTaskError{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务信息表 |
| | | */ |
| | | @Data |
| | | public class SearchQuartzTaskInfo extends SearchBasicDTO { |
| | | /** |
| | | * 任务编号 |
| | | */ |
| | | private String taskNo; |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SearchQuartzTaskInfo{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 定时任务执行情况记录表 |
| | | * @author lin.liu |
| | | * @description 定时任务执行情况记录表 |
| | | */ |
| | | @Data |
| | | public class SearchQuartzTaskRecord extends SearchBasicDTO { |
| | | /** |
| | | * 任务编号 |
| | | */ |
| | | private String taskNo; |
| | | /** |
| | | * 执行时间-范围(eg: 2021-01-01 00:00:00 ~ 2021-01-01 23:59:59)" |
| | | */ |
| | | private String executeTimeRange; |
| | | /** |
| | | * 执行时间-起始 |
| | | * @ignore |
| | | */ |
| | | private Long executeTimeStart; |
| | | /** |
| | | * 执行时间-截止 |
| | | * @ignore |
| | | */ |
| | | private Long executeTimeEnd; |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SearchQuartzTaskRecord{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", orderBy='" + getOrderBy() + "'" + |
| | | ", taskNo='" + taskNo + "'" + |
| | | ", executeTimeRange='" + executeTimeRange + "'" + |
| | | ", executeTimeStart =" + executeTimeStart + |
| | | ", executeTimeEnd =" + executeTimeEnd + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 字典数据表 |
| | | * @author lin.liu |
| | | * @description 字典数据表 |
| | | */ |
| | | @Data |
| | | public class SearchSysDictData extends SearchBasicDTO { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 字典类型表 |
| | | * @author lin.liu |
| | | * @description 字典类型表 |
| | | */ |
| | | @Data |
| | | public class SearchSysDictType extends SearchBasicDTO { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.entity.search; |
| | | |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | |
| | | /** |
| | | * 测试信息 查询条件dto |
| | | * @author lin.liu |
| | | * @description 测试信息 查询条件dto |
| | | * @date 2021/11/23 |
| | | */ |
| | | public class SearchTestInfo extends SearchBasicDTO { |
| | | /** |
| | | * EOrderBy-此字段仅为“orderBy”说明枚举类型,无需传参 |
| | | */ |
| | | private String orderByEnum; |
| | | |
| | | public String getOrderByEnum() { |
| | | return orderByEnum; |
| | | } |
| | | |
| | | public void setOrderByEnum(String orderByEnum) { |
| | | this.orderByEnum = orderByEnum; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SearchTestInfo{" + "'" + |
| | | "keywords='" + getKeywords() + |
| | | ", listId =" + getListId() + |
| | | ", status =" + getStatus() + |
| | | ", listStatus =" + getListStatus() + |
| | | ", createTimeRange='" + getCreateTimeRange() + "'" + |
| | | ", createTimeStart =" + getCreateTimeEnd() + |
| | | ", createTimeEnd =" + getCreateTimeEnd() + |
| | | ", lastId =" + getListId() + |
| | | ", orderByEnum='" + getOrderByEnum() + '\'' + |
| | | ", orderBy='" + getOrderBy() + '\'' + |
| | | '}'; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host; |
| | | |
| | | import com.yomahub.tlog.core.enhance.AspectLogEnhance; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | import org.springframework.boot.web.servlet.ServletComponentScan; |
| | | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | | |
| | | @SpringBootApplication(scanBasePackages = { "com.lunhan" }) |
| | | @ServletComponentScan |
| | | @MapperScan("com.fengdu.gas.repository.mapper") |
| | | // 开启缓存 |
| | | @EnableCaching |
| | | public class ApplicationStarter extends SpringBootServletInitializer { |
| | | static { |
| | | // 进行日志增强,自动判断日志框架。自动给每条日志加上一个全局唯一的traceId |
| | | AspectLogEnhance.enhance(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(ApplicationStarter.class, args); |
| | | } |
| | | |
| | | @Override |
| | | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
| | | return application.sources(ApplicationStarter.class); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.config.SysConfig; |
| | | import com.fengdu.gas.common.jwt.JWTUtil; |
| | | import com.fengdu.gas.common.jwt.LoginUserDTO; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * 基础controller |
| | | */ |
| | | public class BasicController { |
| | | |
| | | /** |
| | | * 获取当前请求上下文的“HttpServletRequest”对象 |
| | | */ |
| | | protected HttpServletRequest ServletRequest() { |
| | | RequestAttributes reqAttributes = RequestContextHolder.currentRequestAttributes(); |
| | | if (null == reqAttributes) { |
| | | return null; |
| | | } |
| | | ServletRequestAttributes servletReqAttributes = (ServletRequestAttributes)reqAttributes; |
| | | return servletReqAttributes.getRequest(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前请求上下文的“HttpServletResponse”对象 |
| | | */ |
| | | protected HttpServletResponse ServletResponse() { |
| | | RequestAttributes reqAttributes = RequestContextHolder.currentRequestAttributes(); |
| | | if (null == reqAttributes) { |
| | | return null; |
| | | } |
| | | ServletRequestAttributes servletReqAttributes = (ServletRequestAttributes)reqAttributes; |
| | | return servletReqAttributes.getResponse(); |
| | | } |
| | | |
| | | protected String getToken() { |
| | | return this.ServletRequest().getHeader(SysConfig.getTokenHeader()); |
| | | } |
| | | |
| | | protected String getHeader(String key) { |
| | | return this.ServletRequest().getHeader(key); |
| | | } |
| | | |
| | | protected LoginUserDTO getTokenUser() { |
| | | return JWTUtil.getUser(this.getToken()); |
| | | } |
| | | |
| | | protected <T> ExecutedResult<T> success(T data) { |
| | | return ExecutedResult.success(data); |
| | | } |
| | | |
| | | protected <T> ExecutedResult<T> failed(String msg) { |
| | | return ExecutedResult.failed(msg); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | public class ApiRequestLogDTO { |
| | | private String requestId; |
| | | private String requestIP; |
| | | private String path; |
| | | private String desc; |
| | | private String method; |
| | | private Long requestTime; |
| | | private String requestData; |
| | | private String requestToken; |
| | | private String requestHeaders; |
| | | private Long responseTime; |
| | | private Long spendTime; |
| | | private String responseData; |
| | | |
| | | |
| | | public String getRequestId() { |
| | | return requestId; |
| | | } |
| | | |
| | | public void setRequestId(String requestId) { |
| | | this.requestId = requestId; |
| | | } |
| | | |
| | | public String getRequestIP() { |
| | | return requestIP; |
| | | } |
| | | |
| | | public void setRequestIP(String requestIP) { |
| | | this.requestIP = requestIP; |
| | | } |
| | | |
| | | public String getPath() { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public String getMethod() { |
| | | return method; |
| | | } |
| | | |
| | | public void setMethod(String method) { |
| | | this.method = method; |
| | | } |
| | | |
| | | public Long getRequestTime() { |
| | | return requestTime; |
| | | } |
| | | |
| | | public void setRequestTime(Long requestTime) { |
| | | this.requestTime = requestTime; |
| | | } |
| | | |
| | | public String getRequestData() { |
| | | return requestData; |
| | | } |
| | | |
| | | public void setRequestData(String requestData) { |
| | | this.requestData = requestData; |
| | | } |
| | | |
| | | public String getRequestToken() { |
| | | return requestToken; |
| | | } |
| | | |
| | | public void setRequestToken(String requestToken) { |
| | | this.requestToken = requestToken; |
| | | } |
| | | |
| | | public String getRequestHeaders() { |
| | | return requestHeaders; |
| | | } |
| | | |
| | | public void setRequestHeaders(String requestHeaders) { |
| | | this.requestHeaders = requestHeaders; |
| | | } |
| | | |
| | | public Long getResponseTime() { |
| | | return responseTime; |
| | | } |
| | | |
| | | public void setResponseTime(Long responseTime) { |
| | | this.responseTime = responseTime; |
| | | } |
| | | |
| | | public Long getSpendTime() { |
| | | return spendTime; |
| | | } |
| | | |
| | | public void setSpendTime(Long spendTime) { |
| | | this.spendTime = spendTime; |
| | | } |
| | | |
| | | public String getResponseData() { |
| | | return responseData; |
| | | } |
| | | |
| | | public void setResponseData(String responseData) { |
| | | this.responseData = responseData; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.cors.CorsConfiguration; |
| | | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
| | | import org.springframework.web.filter.CorsFilter; |
| | | |
| | | // 一定不能忽略此注解 |
| | | @Configuration |
| | | public class CorsFilterConfig { |
| | | /** |
| | | * 跨域过滤器 TODO 如果通过ngix或者其他方式配置了跨域,请注释掉 @Bean 注解 |
| | | * @return CorsFilter 跨域过滤器对象 |
| | | */ |
| | | |
| | | @Bean |
| | | public CorsFilter corsFilter() { |
| | | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
| | | source.registerCorsConfiguration("/**", buildConfig()); |
| | | return new CorsFilter(source); |
| | | } |
| | | |
| | | private CorsConfiguration buildConfig() { |
| | | CorsConfiguration corsConfiguration = new CorsConfiguration(); |
| | | corsConfiguration.addAllowedOrigin("*"); |
| | | corsConfiguration.addAllowedHeader("*"); |
| | | corsConfiguration.addAllowedMethod("*"); |
| | | return corsConfiguration; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.enums.ELogger; |
| | | import com.fengdu.gas.common.enums.EResultCode; |
| | | import com.fengdu.gas.common.exceptions.BusinessException; |
| | | import com.google.common.base.Charsets; |
| | | import com.fengdu.gas.common.util.*; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.web.bind.annotation.ControllerAdvice; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * 全局异常处理 |
| | | */ |
| | | @ControllerAdvice |
| | | public class GlobalExceptionHandler { |
| | | private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); |
| | | private static final Logger logger = LoggerUtil.get(ELogger.API_REQUEST); |
| | | @ResponseBody |
| | | @ExceptionHandler(value = Exception.class) |
| | | public ExecutedResult<String> handle(Exception e) { |
| | | ExecutedResult<String> result = new ExecutedResult<>(EResultCode.ERROR, "", e.getMessage()); |
| | | |
| | | // 记录请求日志 |
| | | this.writeLog(result); |
| | | |
| | | sysLogger.error("SysError", e); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @ExceptionHandler(value = BusinessException.class) |
| | | public ExecutedResult<String> handle(BusinessException e) { |
| | | ExecutedResult<String> result = new ExecutedResult<>(e.getCode(), "", e.getMessage()); |
| | | |
| | | // 记录请求日志 |
| | | this.writeLog(result); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private void writeLog(ExecutedResult<String> result) { |
| | | //获取当前请求对象 |
| | | ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | if (null == attributes) { |
| | | return; |
| | | } |
| | | HttpServletRequest request = attributes.getRequest(); |
| | | String data; |
| | | try { |
| | | byte[] buffer = HttpUtil.getBytesFromInputStream(request.getInputStream()); |
| | | data = new String(buffer, Charsets.UTF_8); |
| | | } catch (Exception e) { |
| | | data = ""; |
| | | } |
| | | ApiRequestLogDTO webLog = HttpRequestLogPool.getRequestInfo(); |
| | | if (null == webLog) { |
| | | return; |
| | | } |
| | | String log = String.format("[%s]" + |
| | | "%nrequestPath: %s[%s]" + |
| | | "%nreponseData: %s" + |
| | | "%nrequestTime: %s" + |
| | | "%nresponseTime: %s" + |
| | | "%nspendTime: %s" + |
| | | "%nmethod: %s" + |
| | | "%nrequestIp: %s" + |
| | | "%ntokenCode: %s" + |
| | | "%nrequestData: %s", |
| | | |
| | | "", |
| | | webLog.getPath(), |
| | | "", |
| | | SerializeUtil.toJson(result), |
| | | LocalDateTimeUtil.toFormatFullString(webLog.getRequestTime()), |
| | | LocalDateTimeUtil.nowDateTimeFullStr(), |
| | | LocalDateTimeUtil.nowTimeStamp() - webLog.getRequestTime(), |
| | | webLog.getMethod(), |
| | | webLog.getRequestIP(), |
| | | webLog.getRequestToken(), |
| | | data |
| | | ); |
| | | logger.info(log); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | class HttpRequestLogPool { |
| | | private static ThreadLocal<ApiRequestLogDTO> requestThreadLocal = new ThreadLocal<>(); |
| | | |
| | | public static void setRequestInfo(ApiRequestLogDTO requestInfo) { |
| | | requestThreadLocal.set(requestInfo); |
| | | } |
| | | |
| | | public static ApiRequestLogDTO getRequestInfo() { |
| | | ApiRequestLogDTO result = requestThreadLocal.get(); |
| | | requestThreadLocal.remove(); |
| | | return result; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * 标记必须是管理员(作用整个controller类,或者某个接口方法) |
| | | */ |
| | | |
| | | @Target(value = { ElementType.TYPE, ElementType.METHOD }) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface MustAdmin { |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistration; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | @Configuration |
| | | public class MvcTokenInterceptors implements WebMvcConfigurer { |
| | | @Autowired |
| | | private TokenFilter tokenFilter; |
| | | |
| | | |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | //添加处理拦截器,拦截所有请求 |
| | | InterceptorRegistration interceptorRegistration = registry.addInterceptor(tokenFilter); |
| | | //配置拦截策略 所有路径都被拦截 |
| | | interceptorRegistration.addPathPatterns("/**"); |
| | | //排除配置 这里接口的跳过不使用此方式排除,通过注解“NonLogin”跳过拦截 |
| | | interceptorRegistration.excludePathPatterns( |
| | | "/**/*.html", |
| | | "/**/*.vue" |
| | | , "/**/*.css" |
| | | , "/**/*.js" |
| | | , "/**/*.js.map" |
| | | , "/*.ico" |
| | | , "/**/*.jpg" |
| | | , "/**/*.png" |
| | | , "/**/*.woff" |
| | | , "/**/*.ttf" |
| | | ,"/**/*.json" |
| | | , "/doc/*" |
| | | , "/swagger/*" |
| | | , "/swagger\\-ui/*" |
| | | , "/swagger3/*" |
| | | // , "/login/*" |
| | | // , "/user/login" |
| | | ); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class MyBatisPlusConfig { |
| | | @Bean |
| | | public MybatisPlusInterceptor paginationInterceptor() { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); |
| | | return interceptor; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * 不需要登陆注解(作用整个controller类,或者某个接口方法) |
| | | */ |
| | | |
| | | @Target(value = { ElementType.TYPE, ElementType.METHOD }) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface NonLogin { |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import com.fengdu.gas.common.config.SysConfig; |
| | | import com.fengdu.gas.common.enums.EResultCode; |
| | | import com.fengdu.gas.common.exceptions.BusinessException; |
| | | import com.fengdu.gas.common.jwt.JWTUtil; |
| | | import com.fengdu.gas.common.jwt.LoginUserDTO; |
| | | import com.fengdu.gas.common.util.IPUtils; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.RandVerifyCode; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.enums.EUserType; |
| | | import org.apache.commons.lang3.BooleanUtils; |
| | | import org.springframework.core.annotation.AnnotationUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.method.HandlerMethod; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | |
| | | @Component |
| | | public class TokenFilter implements HandlerInterceptor { |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { |
| | | String method = request.getMethod(); |
| | | if ("options".equalsIgnoreCase(method)) { |
| | | |
| | | return true; |
| | | } |
| | | Long now = LocalDateTimeUtil.nowTimeStamp(); |
| | | String reqId = now + RandVerifyCode.complexCode(6); |
| | | ApiRequestLogDTO req = new ApiRequestLogDTO(); |
| | | req.setRequestTime(now); |
| | | req.setRequestId(reqId); |
| | | req.setRequestIP(IPUtils.getIpAddress(request)); |
| | | String urlParams = request.getQueryString(); |
| | | if (StringUtil.isNotNullOrEmpty(urlParams)) { |
| | | urlParams = "?" + urlParams; |
| | | } |
| | | req.setPath(request.getRequestURI() + urlParams); |
| | | req.setMethod(method); |
| | | req.setRequestData(""); |
| | | // Map<String, String> mapHeaders = new HashMap<>(); |
| | | // Enumeration<String> headerNames = request.getHeaderNames(); |
| | | // String key = headerNames.nextElement(); |
| | | // while (StringUtil.isNotNullOrEmpty(key)) { |
| | | // mapHeaders.put(key, request.getHeader(key)); |
| | | // key = headerNames.nextElement(); |
| | | // } |
| | | req.setRequestHeaders(""); |
| | | String token = request.getHeader(SysConfig.getTokenHeader()); |
| | | req.setRequestToken(token); |
| | | HttpRequestLogPool.setRequestInfo(req); |
| | | |
| | | List<Class<?>> listHas = new ArrayList<>(); |
| | | if (handler instanceof HandlerMethod) { |
| | | HandlerMethod methodHandle = (HandlerMethod) handler; |
| | | Class<?> clazz = ((HandlerMethod) handler).getBeanType(); |
| | | |
| | | NonLogin nonLogin = methodHandle.getMethodAnnotation(NonLogin.class); |
| | | // 如果方法拥有跳过登陆验权的注解,则返回成功 |
| | | if (Objects.nonNull(nonLogin)) { |
| | | return true; |
| | | } |
| | | nonLogin = AnnotationUtils.findAnnotation(clazz, NonLogin.class); |
| | | // 如果此方法所属类拥有跳过登陆验权的注解,则返回成功 |
| | | if (Objects.nonNull(nonLogin)) { |
| | | return true; |
| | | } |
| | | |
| | | MustAdmin mustAdmin = methodHandle.getMethodAnnotation(MustAdmin.class); |
| | | if (Objects.nonNull(mustAdmin)) { |
| | | listHas.add(MustAdmin.class); |
| | | } |
| | | mustAdmin = AnnotationUtils.findAnnotation(clazz, MustAdmin.class); |
| | | if (Objects.nonNull(mustAdmin)) { |
| | | listHas.add(MustAdmin.class); |
| | | } |
| | | } |
| | | if (Objects.isNull(token)) { |
| | | throw new BusinessException(EResultCode.UNAUTHORIZED, "token未传入"); |
| | | } |
| | | |
| | | // 验证token |
| | | LoginUserDTO user = JWTUtil.getUser(token); |
| | | // 超级管理员拥有所有权限 |
| | | if (Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) { |
| | | return true; |
| | | } |
| | | if ( |
| | | listHas.contains(MustAdmin.class) && ( |
| | | BooleanUtils.isFalse(Objects.equals(user.getUserType(), EUserType.ADMIN.getValue())) && |
| | | BooleanUtils.isFalse(Objects.equals(user.getUserType(), EUserType.ADMIN_USER.getValue())) |
| | | ) |
| | | ) { |
| | | throw new BusinessException(EResultCode.FORBIDDEN, "没有权限"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { |
| | | |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.Parameter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.fengdu.gas.common.enums.ELogger; |
| | | import com.fengdu.gas.common.util.*; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | /** |
| | | * 统一日志处理切面 |
| | | * Created by macro on 2018/4/26. |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | @Order(1) |
| | | public class WebLogAspect { |
| | | private static final Logger logger = LoggerUtil.get(ELogger.API_REQUEST); |
| | | private static final Logger sysLogger = LoggerUtil.get(ELogger.SYS_ERROR); |
| | | /** |
| | | * 100毫秒 |
| | | */ |
| | | private static final long MS_100 = 100; |
| | | /** |
| | | * 2秒 |
| | | */ |
| | | private static final long SEC_1 = 1000; |
| | | /** |
| | | * 2秒 |
| | | */ |
| | | private static final long SEC_2 = 2 * 1000; |
| | | /** |
| | | * 10秒 |
| | | */ |
| | | private static final long SEC_10 = 10 * 1000; |
| | | /** |
| | | * 1分钟 |
| | | */ |
| | | private static final long MINS_1 = 60 * 1000; |
| | | /** |
| | | * 5分钟 |
| | | */ |
| | | private static final long MINS_5 = 5 * 60 * 1000; |
| | | |
| | | @Pointcut( |
| | | "execution(public * com.lunhan.*.host.controller.*.*(..))" + |
| | | "||execution(public * com.lunhan.*.host.admin.*.*(..))" + |
| | | "||execution(public * com.lunhan.*.host.customer.*.*(..))" |
| | | ) |
| | | public void webLog() { |
| | | } |
| | | |
| | | @Before("webLog()") |
| | | public void doBefore(JoinPoint joinPoint) { |
| | | } |
| | | |
| | | @AfterReturning(value = "webLog()", returning = "ret") |
| | | public void doAfterReturning(Object ret) { |
| | | } |
| | | |
| | | |
| | | @Around("webLog()") |
| | | public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | long startTime = System.currentTimeMillis(); |
| | | //获取当前请求对象 |
| | | ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = attributes.getRequest(); |
| | | //记录请求信息(通过Logstash传入Elasticsearch) |
| | | ApiRequestLogDTO webLog = HttpRequestLogPool.getRequestInfo(); |
| | | Object result = joinPoint.proceed(); |
| | | Signature signature = joinPoint.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method method = methodSignature.getMethod(); |
| | | // if (method.isAnnotationPresent(ApiOperation.class)) { |
| | | // ApiOperation log = method.getAnnotation(ApiOperation.class); |
| | | // webLog.setDescription(log.value()); |
| | | // } |
| | | String desc; |
| | | switch (webLog.getMethod()) { |
| | | case "POST": |
| | | desc = method.getAnnotation(PostMapping.class).name(); |
| | | break; |
| | | case "GET": |
| | | desc = method.getAnnotation(GetMapping.class).name(); |
| | | break; |
| | | case "PUT": |
| | | desc = method.getAnnotation(PutMapping.class).name(); |
| | | break; |
| | | case "Delete": |
| | | desc = method.getAnnotation(DeleteMapping.class).name(); |
| | | break; |
| | | default: |
| | | desc = ""; |
| | | break; |
| | | } |
| | | webLog.setDesc(desc); |
| | | |
| | | Long endTime = LocalDateTimeUtil.nowTimeStamp(); |
| | | webLog.setResponseTime(endTime); |
| | | webLog.setRequestData(SerializeUtil.toJson(getParameter(method, joinPoint.getArgs()))); |
| | | webLog.setResponseData(SerializeUtil.toJson(result)); |
| | | webLog.setSpendTime((endTime - startTime)); |
| | | |
| | | String usedTimesLevel; |
| | | if (webLog.getSpendTime() > MINS_5) {//大于5分钟 |
| | | usedTimesLevel = "F"; |
| | | } else if (webLog.getSpendTime() > MINS_1) {//1 - 5分钟 |
| | | usedTimesLevel = "E"; |
| | | } else if (webLog.getSpendTime() > SEC_10) {//10秒 - 1分钟 |
| | | usedTimesLevel = "D"; |
| | | } else if (webLog.getSpendTime() > SEC_2) {//2秒 - 10秒 |
| | | usedTimesLevel = "C"; |
| | | } else if (webLog.getSpendTime() > SEC_1) {//1秒 - 2秒 |
| | | usedTimesLevel = "B"; |
| | | } else if (webLog.getSpendTime() > MS_100) {//100毫秒 - 1秒 |
| | | usedTimesLevel = "A"; |
| | | } else {//100毫秒以内 |
| | | usedTimesLevel = "SSS"; |
| | | } |
| | | |
| | | List<String> listTag = new ArrayList<>(); |
| | | listTag.add("url=" + webLog.getPath()); |
| | | listTag.add("method=" + webLog.getMethod()); |
| | | listTag.add("spendTime=" + webLog.getSpendTime()); |
| | | listTag.add("description=" + webLog.getDesc()); |
| | | listTag.add("tokenCode=" + webLog.getRequestToken()); |
| | | listTag.add("usedTimesLevel=" + usedTimesLevel); |
| | | |
| | | String log = String.format("[%s]" + |
| | | "%nrequestPath: %s[%s]" + |
| | | "%nreponseData: %s" + |
| | | "%nrequestTime: %s" + |
| | | "%nresponseTime: %s" + |
| | | "%nspendTime: %s" + |
| | | "%nmethod: %s" + |
| | | "%nrequestIp: %s" + |
| | | "%ntokenCode: %s" + |
| | | "%nrequestData: %s", |
| | | |
| | | StringUtil.join(listTag, "],["), |
| | | webLog.getPath(), |
| | | webLog.getDesc(), |
| | | webLog.getResponseData(), |
| | | LocalDateTimeUtil.toFormatFullString(webLog.getRequestTime()), |
| | | LocalDateTimeUtil.toFormatFullString(webLog.getResponseTime()), |
| | | webLog.getSpendTime(), |
| | | webLog.getMethod(), |
| | | webLog.getRequestIP(), |
| | | webLog.getRequestToken(), |
| | | webLog.getRequestData() |
| | | ); |
| | | |
| | | logger.info(log); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据方法和传入的参数获取请求参数 |
| | | */ |
| | | private Object getParameter(Method method, Object[] args) { |
| | | List<Object> argList = new ArrayList<>(); |
| | | Parameter[] parameters = method.getParameters(); |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | //将RequestBody注解修饰的参数作为请求参数 |
| | | RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class); |
| | | if (requestBody != null) { |
| | | argList.add(args[i]); |
| | | } |
| | | //将RequestParam注解修饰的参数作为请求参数 |
| | | RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class); |
| | | if (requestParam != null) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String key = parameters[i].getName(); |
| | | if (!StringUtils.isEmpty(requestParam.value())) { |
| | | key = requestParam.value(); |
| | | } |
| | | map.put(key, args[i]); |
| | | argList.add(map); |
| | | } |
| | | } |
| | | if (argList.size() == 0) { |
| | | return null; |
| | | } else if (argList.size() == 1) { |
| | | return argList.get(0); |
| | | } else { |
| | | return argList; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.api; |
| | | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | @Configuration |
| | | public class WebMvcConfig implements WebMvcConfigurer { |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | // 添加一个静态资源映射 将/logs/upload/xxx 映射到文件上传目录 |
| | | registry.addResourceHandler("/upload/**").addResourceLocations("file:" + System.getProperty("user.dir") + "/logs/upload/"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.enums.ESex; |
| | | import com.fengdu.gas.entity.request.ReqListId; |
| | | import com.fengdu.gas.entity.request.ReqListSetSort; |
| | | import com.fengdu.gas.entity.request.ReqSetSort; |
| | | import com.fengdu.gas.entity.request.test.ReqCreateTestInfo; |
| | | import com.fengdu.gas.entity.request.test.ReqModifyTestInfo; |
| | | import com.fengdu.gas.entity.search.SearchTestInfo; |
| | | import com.fengdu.gas.service.TestInfoService; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.host.api.NonLogin; |
| | | import com.fengdu.gas.repository.vo.TestInfoVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 99999.测试信息相关接口 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | * @order 99999 |
| | | */ |
| | | @NonLogin |
| | | @RestController |
| | | @RequestMapping(value = "testInfo") |
| | | public class TestInfoServiceController extends BasicController { |
| | | @Autowired |
| | | private TestInfoService service; |
| | | /** |
| | | * 创建[测试信息] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateTestInfo request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) |
| | | // 限制最大长度 |
| | | .addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("用户id"), request.getUserId(), 0L) |
| | | // 必须是手机号码(正则) |
| | | .addMustMobile(ParameterUtil.named("电话"), request.getPhone()) |
| | | // 金额大于0 |
| | | .addGreaterThan(ParameterUtil.named("余额"), request.getBalance(), BigDecimal.ZERO) |
| | | // 必须是枚举值 |
| | | .addMustEnum(ParameterUtil.named("性别"), request.getSex(), ESex.class) |
| | | // 必须是日期字符串(yyyy-MM-dd) |
| | | .addMustDate(ParameterUtil.named("生日"), request.getBirthday()) |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("排序值"), request.getSort(), 0) |
| | | // 限制最大长度 |
| | | .addLengthMax(ParameterUtil.named("备注"), request.getComment(), ConstantFactory.LENGTH_MAX500); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.create(request); |
| | | } |
| | | |
| | | /** |
| | | * 编辑[测试信息] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifyTestInfo request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("[测试信息]id"), request.getId(), 0L) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) |
| | | // 限制最大长度 |
| | | .addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("用户id"), request.getUserId(), 0L) |
| | | // 必须是手机号码(正则) |
| | | .addMustMobile(ParameterUtil.named("电话"), request.getPhone()) |
| | | // 金额大于0 |
| | | .addGreaterThan(ParameterUtil.named("余额"), request.getBalance(), BigDecimal.ZERO) |
| | | // 必须是枚举值 |
| | | .addMustEnum(ParameterUtil.named("性别"), request.getSex(), ESex.class) |
| | | // 必须是日期字符串(yyyy-MM-dd) |
| | | .addMustDate(ParameterUtil.named("生日"), request.getBirthday()) |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("排序值"), request.getSort(), 0) |
| | | // 限制最大长度 |
| | | .addLengthMax(ParameterUtil.named("备注"), request.getComment(), ConstantFactory.LENGTH_MAX500); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.modify(request); |
| | | } |
| | | |
| | | /** |
| | | * 获取[测试信息] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @GetMapping(value = "get/{id}") |
| | | public ExecutedResult<TestInfoVO> get(@PathVariable Long id) { |
| | | return this.service.get(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据id批量获取[测试信息] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "getList") |
| | | public ExecutedResult<List<TestInfoVO>> getList(@RequestBody ReqListId request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.getList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * [测试信息]设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "setSort") |
| | | public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("[测试信息]id"), request.getId(), 0L) |
| | | // 必须大于0 |
| | | .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.setSort(request); |
| | | } |
| | | |
| | | /** |
| | | * [测试信息]批量设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "listSetSort") |
| | | ExecutedResult<String> listSetSort(ReqListSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("[测试信息]排序设置列表"), request.getList()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.listSetSort(request); |
| | | } |
| | | |
| | | /** |
| | | * 停用[测试信息] |
| | | * |
| | | * @param id [测试]id |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "stop/{id}") |
| | | public ExecutedResult<String> stop(@PathVariable Long id) { |
| | | return this.service.stop(id); |
| | | } |
| | | |
| | | /** |
| | | * 启用[测试信息] |
| | | * |
| | | * @param id [测试]id |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "enable/{id}") |
| | | public ExecutedResult<String> enable(@PathVariable Long id) { |
| | | return this.service.enable(id); |
| | | } |
| | | |
| | | /** |
| | | * 删除[测试信息] |
| | | * |
| | | * @param id [测试]id |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "remove/{id}") |
| | | public ExecutedResult<String> remove(@PathVariable Long id) { |
| | | return this.service.remove(id); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除[测试信息] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "removeList") |
| | | public ExecutedResult<String> removeList(@RequestBody ReqListId request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.removeList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 查询[测试信息] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @NonLogin |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<TestInfoVO>> search(@RequestBody SearchTestInfo request) { |
| | | return this.service.search(request); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.admin; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.enums.EMenuType; |
| | | import com.fengdu.gas.entity.enums.EState; |
| | | import com.fengdu.gas.entity.request.ReqListId; |
| | | import com.fengdu.gas.entity.request.ReqListSetSort; |
| | | import com.fengdu.gas.entity.request.ReqSetSort; |
| | | import com.fengdu.gas.entity.request.adminmenu.ReqCreateAdminMenu; |
| | | import com.fengdu.gas.entity.request.adminmenu.ReqModifyAdminMenu; |
| | | import com.fengdu.gas.entity.response.admin.ResAdminMenuTreeAndPermission; |
| | | import com.fengdu.gas.entity.search.SearchAdminMenu; |
| | | import com.fengdu.gas.service.AdminPowerService; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.host.api.MustAdmin; |
| | | import com.fengdu.gas.repository.vo.AdminMenuVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 10.菜单相关接口 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | * @order 10 |
| | | */ |
| | | @RestController |
| | | @RequestMapping(value = "admin/menu") |
| | | public class AdminMenuController extends BasicController { |
| | | @Autowired |
| | | private AdminPowerService service; |
| | | |
| | | /** |
| | | * 创建菜单 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateAdminMenu request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须是枚举值 |
| | | .addMustEnum(ParameterUtil.named("类型"), request.getType(), EMenuType.class) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("菜单名称"), request.getName()) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("菜单名称"), request.getName(), ConstantFactory.LENGTH_MAX20) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("菜单标题"), request.getTitle(), ConstantFactory.LENGTH_MAX100) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("前端资源路径"), request.getUrl(), ConstantFactory.LENGTH_MAX200) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.createMenu(request); |
| | | } |
| | | |
| | | /** |
| | | * 编辑菜单 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifyAdminMenu request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须是枚举值 |
| | | .addMustEnum(ParameterUtil.named("类型"), request.getType(), EMenuType.class) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("菜单名称"), request.getName()) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("菜单名称"), request.getName(), ConstantFactory.LENGTH_MAX20) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("菜单标题"), request.getTitle(), ConstantFactory.LENGTH_MAX100) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("前端资源路径"), request.getUrl(), ConstantFactory.LENGTH_MAX200) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.modifyMenu(request); |
| | | } |
| | | |
| | | /** |
| | | * 停用菜单 |
| | | * |
| | | * @param menuId 菜单id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "stop/{menuId}") |
| | | public ExecutedResult<String> stop(@PathVariable Long menuId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.changeMenuStatus(menuId, EState.DISABLED); |
| | | } |
| | | |
| | | /** |
| | | * 启用菜单 |
| | | * |
| | | * @param menuId 菜单id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "enable/menuId") |
| | | public ExecutedResult<String> enable(@PathVariable Long menuId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.changeMenuStatus(menuId, EState.NORMAL); |
| | | } |
| | | |
| | | /** |
| | | * [菜单]设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "setSort") |
| | | public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("菜单id"), request.getId(), 0L) |
| | | // 必须大于0 |
| | | .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.setMenuSort(request); |
| | | } |
| | | |
| | | /** |
| | | * [菜单]批量设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "listSetSort") |
| | | ExecutedResult<String> listSetSort(ReqListSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("菜单排序设置列表"), request.getList()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.listSetMenuSort(request); |
| | | } |
| | | |
| | | /** |
| | | * 删除菜单 |
| | | * |
| | | * @param menuId 菜单id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "remove/{menuId}") |
| | | public ExecutedResult<String> remove(@PathVariable Long menuId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.removeMenu(menuId); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除[删除菜单] |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "removeList") |
| | | public ExecutedResult<String> removeList(@RequestBody ReqListId request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("[测试信息]id列表"), request.getListId()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.removeMenuList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有层级菜单(只返回状态正常的数据) |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping(value = "getListTree") |
| | | public ExecutedResult<List<ResAdminMenuTreeAndPermission>> getListTree() { |
| | | return this.service.getListTreeMenu(); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定菜单的子级菜单 |
| | | * |
| | | * @param menuId 菜单id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping(value = "getListChild/{menuId}") |
| | | public ExecutedResult<List<AdminMenuVO>> getListChild(@PathVariable Long menuId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("菜单id"), menuId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.getListChildMenu(menuId); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询菜单 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<AdminMenuVO>> search(@RequestBody SearchAdminMenu request) { |
| | | return this.service.searchMenu(request); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.admin; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.enums.EState; |
| | | import com.fengdu.gas.entity.request.adminpermission.ReqCreateAdminPermission; |
| | | import com.fengdu.gas.entity.request.adminpermission.ReqModifyAdminPermission; |
| | | import com.fengdu.gas.entity.response.admin.ResAdminPermission; |
| | | import com.fengdu.gas.entity.search.SearchAdminPermission; |
| | | import com.fengdu.gas.service.AdminPowerService; |
| | | import com.fengdu.gas.host.api.MustAdmin; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 20.权限相关接口 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | * @order 20 |
| | | */ |
| | | @MustAdmin |
| | | @RestController |
| | | @RequestMapping(value = "admin/permission") |
| | | public class AdminPermissionController { |
| | | @Autowired |
| | | private AdminPowerService service; |
| | | |
| | | |
| | | /** |
| | | * 创建权限 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateAdminPermission request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addNotNullOrEmpty(ParameterUtil.named("权限值"), request.getSn()) |
| | | .addLengthMax(ParameterUtil.named("权限值"), request.getSn(), ConstantFactory.LENGTH_MAX50) |
| | | .addGreater(ParameterUtil.named("菜单id"), request.getMenuId(), 0) |
| | | .addLengthMax(ParameterUtil.named("前端资源url"), request.getMenuUrl(), ConstantFactory.LENGTH_MAX200) |
| | | .addNotNullOrEmpty(ParameterUtil.named("权限名称"), request.getName()) |
| | | .addLengthMax(ParameterUtil.named("权限名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) |
| | | .addLengthMax(ParameterUtil.named("类型"), request.getType(), ConstantFactory.LENGTH_MAX50) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.createPermission(request); |
| | | } |
| | | |
| | | /** |
| | | * 编辑权限 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifyAdminPermission request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addNotNullOrEmpty(ParameterUtil.named("权限值"), request.getSn()) |
| | | .addLengthMax(ParameterUtil.named("权限值"), request.getSn(), ConstantFactory.LENGTH_MAX50) |
| | | .addGreater(ParameterUtil.named("菜单id"), request.getMenuId(), 0) |
| | | .addLengthMax(ParameterUtil.named("前端资源url"), request.getMenuUrl(), ConstantFactory.LENGTH_MAX200) |
| | | .addNotNullOrEmpty(ParameterUtil.named("权限名称"), request.getName()) |
| | | .addLengthMax(ParameterUtil.named("权限名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("图标"), request.getIcon(), ConstantFactory.LENGTH_MAX200) |
| | | .addLengthMax(ParameterUtil.named("类型"), request.getType(), ConstantFactory.LENGTH_MAX50) |
| | | // 必须是枚举 |
| | | .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.modifyPermission(request); |
| | | } |
| | | |
| | | /** |
| | | * 删除权限 |
| | | * |
| | | * @param powerId 权限id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping(value = "remove/{powerId}") |
| | | public ExecutedResult<String> remove(@PathVariable Long powerId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("权限id"), powerId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.removePermission(powerId); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询权限 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<ResAdminPermission>> search(@RequestBody SearchAdminPermission request) { |
| | | return this.service.searchPermission(request); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.admin; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.enums.EState; |
| | | import com.fengdu.gas.entity.request.ReqListId; |
| | | import com.fengdu.gas.entity.request.ReqListSetSort; |
| | | import com.fengdu.gas.entity.request.ReqSetSort; |
| | | import com.fengdu.gas.entity.request.adminrole.ReqCreateAdminRole; |
| | | import com.fengdu.gas.entity.request.adminrole.ReqModifyAdminRole; |
| | | import com.fengdu.gas.entity.request.adminrolemenurelation.ReqSetListMenu4Role; |
| | | import com.fengdu.gas.entity.request.adminuser.ReqSetListRole4Admin; |
| | | import com.fengdu.gas.entity.response.admin.ResAdminPower; |
| | | import com.fengdu.gas.entity.search.SearchAdminRole; |
| | | import com.fengdu.gas.service.AdminPowerService; |
| | | import com.fengdu.gas.service.AdminService; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.host.api.MustAdmin; |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.repository.vo.AdminRoleVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 30.角色相关接口 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | * @order 30 |
| | | */ |
| | | |
| | | @RestController |
| | | @RequestMapping(value = "admin/role") |
| | | public class AdminRoleController extends BasicController { |
| | | @Autowired |
| | | private AdminPowerService service; |
| | | @Autowired |
| | | private AdminService adminService; |
| | | |
| | | /** |
| | | * 创建角色 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateAdminRole request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("角色名称"), request.getName()) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("角色名称"), request.getName(), ConstantFactory.LENGTH_MAX20) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("描述"), request.getDescription(), ConstantFactory.LENGTH_MAX100) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.createRole(request); |
| | | } |
| | | |
| | | /** |
| | | * 编辑角色 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifyAdminRole request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("角色id"), request.getId(), 0L) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("角色名称"), request.getName()) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("角色名称"), request.getName(), ConstantFactory.LENGTH_MAX100) |
| | | // 限制长度 |
| | | .addLengthMax(ParameterUtil.named("描述"), request.getDescription(), ConstantFactory.LENGTH_MAX200) |
| | | // 必须是枚举值 |
| | | .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.modifyRole(request); |
| | | } |
| | | |
| | | /** |
| | | * 停用角色 |
| | | * |
| | | * @param roleId 角色id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "stop/{roleId}") |
| | | public ExecutedResult<String> stop(@PathVariable Long roleId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("角色id"), roleId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.changeRoleStatus(roleId, EState.DISABLED); |
| | | } |
| | | |
| | | /** |
| | | * 启用角色 |
| | | * |
| | | * @param roleId 角色id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "enable/{roleId}") |
| | | public ExecutedResult<String> enable(@PathVariable Long roleId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("角色id"), roleId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.changeRoleStatus(roleId, EState.NORMAL); |
| | | } |
| | | |
| | | /** |
| | | * [角色]设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "setSort") |
| | | public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("角色id"), request.getId(), 0L) |
| | | // 必须大于0 |
| | | .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.setRoleSort(request); |
| | | } |
| | | |
| | | /** |
| | | * [角色]批量设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "listSetSort") |
| | | ExecutedResult<String> listSetSort(ReqListSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("角色排序设置列表"), request.getList()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.listSetRoleSort(request); |
| | | } |
| | | |
| | | /** |
| | | * 删除角色 |
| | | * |
| | | * @param roleId 角色id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "remove/{roleId}") |
| | | public ExecutedResult<String> remove(@PathVariable Long roleId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("角色id"), roleId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.removeRole(roleId); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除角色 |
| | | * @param request 请求参数 |
| | | * @author lin.liu |
| | | * @date 2021/11/23 |
| | | */ |
| | | @PostMapping(value = "removeList") |
| | | public ExecutedResult<String> removeList(@RequestBody ReqListId request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 不能为空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("角色id列表"), request.getListId()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.removeRoleList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询角色 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<AdminRoleVO>> search(@RequestBody SearchAdminRole request) { |
| | | return this.service.searchRole(request); |
| | | } |
| | | |
| | | /** |
| | | * 设置角色菜单权限列表 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "setListMenuAndPermission") |
| | | public ExecutedResult<String> setListMenuAndPermission(@RequestBody ReqSetListMenu4Role request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("角色id"), request.getId(), 0); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.setListMenu4Role(request); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色菜单权限列表 |
| | | * |
| | | * @param roleId 角色id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping(value = "getListMenuAndPermission/{roleId}") |
| | | public ExecutedResult<ResAdminPower> getListMenuAndPermission(@PathVariable Long roleId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("角色id"), roleId, 0); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.getListMenu4Role(roleId); |
| | | } |
| | | |
| | | /** |
| | | * 设置管理员的角色列表 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "setListRole4Admin") |
| | | public ExecutedResult<String> setListRole4Admin(@RequestBody ReqSetListRole4Admin request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("管理员id"), request.getId(), 0); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return adminService.setListRole4Admin(request); |
| | | } |
| | | |
| | | /** |
| | | * 获取管理员的角色列表 |
| | | * |
| | | * @param adminId 管理员id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping(value = "getListRole4Admin") |
| | | public ExecutedResult<List<AdminRoleVO>> getListRole4Admin(@RequestParam Long adminId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("管理员id"), adminId, 0); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return adminService.getListRole4Admin(adminId); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.admin; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.jwt.LoginUserDTO; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.enums.EState; |
| | | import com.fengdu.gas.entity.enums.EUserType; |
| | | import com.fengdu.gas.entity.request.ReqChangePassword; |
| | | import com.fengdu.gas.entity.request.adminuser.ReqAdminLogin; |
| | | import com.fengdu.gas.entity.request.adminuser.ReqCreateAdminUser; |
| | | import com.fengdu.gas.entity.request.adminuser.ReqModifyAdminUser; |
| | | import com.fengdu.gas.entity.response.admin.ResAdminLogin; |
| | | import com.fengdu.gas.entity.response.admin.ResAdminPower; |
| | | import com.fengdu.gas.entity.search.SearchAdminUser; |
| | | import com.fengdu.gas.service.AdminPowerService; |
| | | import com.fengdu.gas.service.AdminService; |
| | | import com.fengdu.gas.service.dto.ResAdminDetail; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.host.api.MustAdmin; |
| | | import com.fengdu.gas.host.api.NonLogin; |
| | | import com.fengdu.gas.repository.vo.AdminUserVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 40.管理员用户相关接口 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | * @order 40 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("admin/user") |
| | | public class AdminUserController extends BasicController { |
| | | @Autowired |
| | | private AdminService service; |
| | | @Autowired |
| | | private AdminPowerService adminPowerService; |
| | | |
| | | /** |
| | | * 添加后台管理员 |
| | | * |
| | | * @param request 请求参数 |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping("add") |
| | | public ExecutedResult<Long> add(@RequestBody ReqCreateAdminUser request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addMustEnum(ParameterUtil.named("用户类型"), request.getUserType(), EUserType.class) |
| | | .addNotNullOrEmpty(ParameterUtil.named("用户名"), request.getUserName()) |
| | | .addLengthMax(ParameterUtil.named("用户名"), request.getUserName(), ConstantFactory.LENGTH_MAX100) |
| | | .addNotNullOrEmpty(ParameterUtil.named("密码"), request.getPassword()) |
| | | .addLengthMax(ParameterUtil.named("密码"), request.getPassword(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("昵称"), request.getNickName(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("头像"), request.getHeadImg(), ConstantFactory.LENGTH_MAX500) |
| | | .addLengthMax(ParameterUtil.named("联系方式"), request.getContact(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("联系邮箱"), request.getEmail(), ConstantFactory.LENGTH_MAX50); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.createAdmin(request); |
| | | } |
| | | |
| | | /** |
| | | * 修改后台管理员 |
| | | * |
| | | * @param request 请求参数 |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping("modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifyAdminUser request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("用户id"), request.getId(), 0L) |
| | | .addMustEnum(ParameterUtil.named("用户类型"), request.getUserType(), EUserType.class) |
| | | .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) |
| | | .addLengthMax(ParameterUtil.named("昵称"), request.getNickName(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("头像"), request.getHeadImg(), ConstantFactory.LENGTH_MAX500) |
| | | .addLengthMax(ParameterUtil.named("联系方式"), request.getContact(), ConstantFactory.LENGTH_MAX50) |
| | | .addLengthMax(ParameterUtil.named("联系邮箱"), request.getEmail(), ConstantFactory.LENGTH_MAX50); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.modify(request); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定管理员详情 |
| | | * |
| | | * @param userId 用户id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping("detail/{userId}") |
| | | public ExecutedResult<ResAdminDetail> detail(@PathVariable Long userId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("用户id"), userId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.detail(userId); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询所有管理员 |
| | | * |
| | | * @param request 查询参数 |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping("search") |
| | | public ExecutedResult<PagerResult<AdminUserVO>> search(@RequestBody SearchAdminUser request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator(); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.search(request); |
| | | } |
| | | |
| | | /** |
| | | * 管理员登录 |
| | | * |
| | | * @param request 请求参数 |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping("login") |
| | | @NonLogin |
| | | public ExecutedResult<ResAdminLogin> adminLogin(@RequestBody ReqAdminLogin request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addNotNullOrEmpty(ParameterUtil.named("用户名"), request.getUserName()) |
| | | .addNotNullOrEmpty(ParameterUtil.named("密码"), request.getPassword()); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.adminLogin(request); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取管理员权限列表 |
| | | * |
| | | * @param userId 用户id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @GetMapping("getPower/{userId}") |
| | | public ExecutedResult<ResAdminPower> getPower(@PathVariable Long userId) { |
| | | return service.getPower(userId); |
| | | } |
| | | |
| | | /** |
| | | * 修改密码 |
| | | * |
| | | * @param request 请求参数 |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @PostMapping("changePassword") |
| | | public ExecutedResult<String> changePassword(@RequestBody ReqChangePassword request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addNotNullOrEmpty(ParameterUtil.named("旧密码"), request.getOldPassword()) |
| | | .addNotNullOrEmpty(ParameterUtil.named("新密码"), request.getNewPassword()) |
| | | .addLengthMax(ParameterUtil.named("新密码"), request.getNewPassword(), ConstantFactory.LENGTH_MAX50); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | LoginUserDTO user = super.getTokenUser(); |
| | | return service.changePassword(user, request); |
| | | } |
| | | |
| | | /** |
| | | * 重置管理员密码 |
| | | * |
| | | * @param userId 用户id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping("resetPassword/{userId}") |
| | | public ExecutedResult<String> resetPassword(@PathVariable Long userId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("用户id"), userId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.resetPassword(userId); |
| | | } |
| | | |
| | | /** |
| | | * 停用管理员帐号 |
| | | * |
| | | * @param userId 用户id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "stop/{userId}") |
| | | public ExecutedResult<String> stop(@PathVariable Long userId) { |
| | | return this.service.stop(userId); |
| | | } |
| | | |
| | | /** |
| | | * 启用管理员帐号 |
| | | * |
| | | * @param userId 用户id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping(value = "enable/{userId}") |
| | | public ExecutedResult<String> enable(@PathVariable Long userId) { |
| | | return this.service.enable(userId); |
| | | } |
| | | |
| | | /** |
| | | * 删除管理员 |
| | | * |
| | | * @param userId 用户id |
| | | * @author lin.liu |
| | | * @date 2023/02/17 |
| | | */ |
| | | @MustAdmin |
| | | @PostMapping("remove/{userId}") |
| | | public ExecutedResult<String> remove(@PathVariable Long userId) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("用户id"), userId, 0L); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return ExecutedResult.failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return service.remove(userId); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.base; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.entity.dto.NameValueDTO; |
| | | import com.fengdu.gas.host.api.NonLogin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 00.基础接口 |
| | | * @order 00 |
| | | */ |
| | | @NonLogin |
| | | @RestController |
| | | @RequestMapping("base") |
| | | public class BaseController { |
| | | /** |
| | | * 获取指定枚举类型的所有值 |
| | | * @param enumName 枚举类型名称 |
| | | */ |
| | | @GetMapping("listEnumValue/{enumName}") |
| | | public ExecutedResult<List<NameValueDTO>> listEnumValue(@PathVariable String enumName) { |
| | | try { |
| | | Class<?> enumClass = Class.forName("com.fengdu.gas.entity.enums." + enumName); |
| | | Method valuesMethod = enumClass.getMethod("values"); |
| | | Method getValueMethod = enumClass.getMethod("getValue"); |
| | | Method getDescMethod = enumClass.getMethod("getDesc"); |
| | | |
| | | Object valuesObj = valuesMethod.invoke(enumClass); |
| | | Object[] values = (Object[]) valuesObj; |
| | | |
| | | List<NameValueDTO> result = new ArrayList<>(); |
| | | for(Object c : values) { |
| | | String value = getValueMethod.invoke(c).toString(); |
| | | String desc = getDescMethod.invoke(c).toString(); |
| | | result.add(new NameValueDTO(desc, value)); |
| | | } |
| | | return ExecutedResult.success(result); |
| | | } catch (Exception e) { |
| | | return ExecutedResult.failed("获取枚举类型失败(" + enumName + "): " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.base; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.config.SysConfig; |
| | | import com.fengdu.gas.common.enums.EContentType; |
| | | import com.fengdu.gas.common.util.FileUtil; |
| | | import com.fengdu.gas.common.util.LocalDateTimeUtil; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.common.validator.EParameterValidateType; |
| | | import com.fengdu.gas.entity.dto.NameValueDTO; |
| | | import com.fengdu.gas.entity.dto.UploadResultVo; |
| | | import com.google.gson.Gson; |
| | | import com.fengdu.gas.host.api.NonLogin; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ResourceLoader; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 01.文件上传 |
| | | * @author lin.liu |
| | | * @date 2021/11/26 |
| | | * @order 01 |
| | | */ |
| | | @NonLogin |
| | | @RestController |
| | | @RequestMapping("/file") |
| | | public class FileController { |
| | | @Autowired |
| | | private ResourceLoader resourceLoader; |
| | | |
| | | /** |
| | | * 上传文件 |
| | | * |
| | | * @param requestMultipart 复杂请求对象 |
| | | */ |
| | | @PostMapping(value = "upload") |
| | | @NonLogin |
| | | public ExecutedResult<UploadResultVo> upload(MultipartHttpServletRequest requestMultipart, HttpServletRequest request) throws Exception { |
| | | UploadResultVo result = this.defaultResult(); |
| | | |
| | | Map<String, MultipartFile> mapFile = requestMultipart.getFileMap(); |
| | | if (mapFile.isEmpty()) { |
| | | return ExecutedResult.failed("请求中没有找到文件。"); |
| | | } |
| | | if (mapFile.size() > 1) { |
| | | return ExecutedResult.failed("仅支持单个文件上传。"); |
| | | } |
| | | String fileId = requestMultipart.getParameter("fileId"); |
| | | String toPath = requestMultipart.getParameter("path"); |
| | | if (StringUtil.isNullOrEmpty(toPath)) { |
| | | return ExecutedResult.failed(ParameterUtil.named("path") + EParameterValidateType.NOT_NULLOREMPTY.getDesc()); |
| | | } |
| | | Iterator<Map.Entry<String, MultipartFile>> iterator = mapFile.entrySet().iterator(); |
| | | Map.Entry<String, MultipartFile> fileEntry = iterator.next(); |
| | | |
| | | MultipartFile file = fileEntry.getValue(); |
| | | String contentType = file.getContentType(); |
| | | |
| | | InputStream fConfig = resourceLoader.getResource("classpath:upload_allow.json").getInputStream(); |
| | | String allowStr = FileUtil.readFileContent(fConfig); |
| | | Map<String, String> map = new Gson().fromJson(allowStr, Map.class); |
| | | List<NameValueDTO<String>> listConfig = map.entrySet().stream().map(c -> new NameValueDTO<>(c.getKey(), c.getValue())) |
| | | .collect(Collectors.toList()); |
| | | NameValueDTO<String> findConfig = listConfig.stream().filter(c -> c.getName().equals(contentType)) |
| | | .findAny().orElse(null); |
| | | if (Objects.isNull(findConfig)) { |
| | | return ExecutedResult.failed(file.getOriginalFilename() + ", 不支持的文件类型。" + file.getContentType()); |
| | | } |
| | | if (null != file.getOriginalFilename() && !file.getOriginalFilename().contains(findConfig.getValue())) { |
| | | return ExecutedResult.failed(file.getOriginalFilename() + ", 不支持的文件类型。" + file.getContentType()); |
| | | } |
| | | |
| | | EContentType type = EContentType.getByValue(file.getContentType()); |
| | | String filePath = "/" + toPath + "/files/"; |
| | | boolean isMultimedia = false; |
| | | long size = file.getSize() / ConstantFactory.FILE_UNIT; |
| | | if (null != type) { |
| | | switch (type) { |
| | | case GIF: |
| | | case JPG: |
| | | case PNG: |
| | | case JPEG: |
| | | filePath = "/" + toPath + "/images/"; |
| | | if (size > ConstantFactory.FILE_SIZE_20M) { |
| | | return ExecutedResult.failed("图片不能超过20M!"); |
| | | } |
| | | break; |
| | | case GZ: |
| | | case RAR: |
| | | case X7Z: |
| | | case ZIP: |
| | | if (size > ConstantFactory.FILE_SIZE_20M) { |
| | | return ExecutedResult.failed("压缩文件不能超过20M!"); |
| | | } |
| | | break; |
| | | |
| | | case MP3: |
| | | isMultimedia = true; |
| | | if (size > ConstantFactory.FILE_SIZE_20M) { |
| | | return ExecutedResult.failed("音频文件不能超过20M!"); |
| | | } |
| | | break; |
| | | case MP4: |
| | | isMultimedia = true; |
| | | if (size > ConstantFactory.FILE_SIZE_20M) { |
| | | return ExecutedResult.failed("视频文件不能超过20M!"); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | filePath += LocalDateTimeUtil.toFormatString(LocalDateTimeUtil.todayFirst(), "yyyyMMdd") + "/"; |
| | | InputStream fsIn = file.getInputStream(); |
| | | |
| | | String fileSuffix = "." + findConfig.getValue(); |
| | | File directory = new File(SysConfig.fileUploadBasic() + filePath); |
| | | //如果路径不存在,新建 |
| | | if (!directory.exists() && !directory.isDirectory()) { |
| | | directory.mkdirs(); |
| | | } |
| | | |
| | | String newFileName = filePath + StringUtil.md5(file.getOriginalFilename() + LocalDateTimeUtil.nowDateTimeFullStr() + SysConfig.fileDisturbStr()) + fileSuffix; |
| | | File newFile = new File(SysConfig.fileUploadBasic() + newFileName); |
| | | if (!newFile.exists()) { |
| | | //每次写入1MB |
| | | byte[] buffer = new byte[ConstantFactory.FILE_UNIT * ConstantFactory.FILE_SIZE_1M]; |
| | | int len; |
| | | FileOutputStream fsOut = null; |
| | | try { |
| | | fsOut = new FileOutputStream(newFile); |
| | | while ((len = fsIn.read(buffer)) != -1) { |
| | | fsOut.write(buffer, 0, len); |
| | | fsOut.flush(); |
| | | } |
| | | } finally { |
| | | if (Objects.nonNull(fsOut)) { |
| | | fsOut.close(); |
| | | } |
| | | } |
| | | } |
| | | if (Objects.nonNull(fsIn)) { |
| | | fsIn.close(); |
| | | } |
| | | |
| | | result.setFileId(fileId); |
| | | result.setName(file.getOriginalFilename()); |
| | | result.setNewFileName(newFileName); |
| | | result.setSize(size); |
| | | result.setFileType(findConfig.getValue()); |
| | | result.setContentType(findConfig.getName()); |
| | | result.setNewFileView(SysConfig.fileViewBasic() + newFileName); |
| | | |
| | | file = null; |
| | | newFile = null; |
| | | |
| | | return ExecutedResult.success(result); |
| | | } |
| | | |
| | | |
| | | private UploadResultVo defaultResult() { |
| | | UploadResultVo result = new UploadResultVo(); |
| | | result.setFileId(""); |
| | | result.setName(""); |
| | | result.setNewFileName(""); |
| | | result.setNewFileView(""); |
| | | result.setFileType(""); |
| | | result.setContentType(""); |
| | | result.setSize(0L); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.base; |
| | | |
| | | import com.fengdu.gas.common.ConstantFactory; |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.jwt.LoginUserDTO; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.enums.EState; |
| | | import com.fengdu.gas.entity.request.ReqListId; |
| | | import com.fengdu.gas.entity.request.ReqSetSort; |
| | | import com.fengdu.gas.entity.request.notice.ReqCreateNotice; |
| | | import com.fengdu.gas.entity.request.notice.ReqModifyNotice; |
| | | import com.fengdu.gas.entity.search.SearchNotice; |
| | | import com.fengdu.gas.service.NoticeService; |
| | | import com.fengdu.gas.service.dto.NoticeDetail; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.host.api.NonLogin; |
| | | import com.fengdu.gas.repository.vo.NoticeVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 02.公告相关接口 |
| | | * @author lin.liu |
| | | * @order 02 |
| | | */ |
| | | @RestController |
| | | @RequestMapping(value = "notice") |
| | | public class NoticeController extends BasicController { |
| | | @Autowired |
| | | private NoticeService service; |
| | | /** |
| | | * 创建公告 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateNotice request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("标题"), request.getTitle()) |
| | | // 限制最大长度 |
| | | .addLengthMax(ParameterUtil.named("标题"), request.getTitle(), ConstantFactory.LENGTH_MAX50) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("内容"), request.getContent()) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | LoginUserDTO user = super.getTokenUser(); |
| | | return this.service.create(request, user); |
| | | } |
| | | |
| | | /** |
| | | * 编辑公告 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifyNotice request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("公告id"), request.getId(), 0L) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("标题"), request.getTitle()) |
| | | // 限制最大长度 |
| | | .addLengthMax(ParameterUtil.named("标题"), request.getTitle(), ConstantFactory.LENGTH_MAX50) |
| | | // 非空 |
| | | .addNotNullOrEmpty(ParameterUtil.named("内容"), request.getContent()) |
| | | // 必须是枚举值 |
| | | .addMustEnum(ParameterUtil.named("状态"), request.getStatus(), EState.class) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.modify(request); |
| | | } |
| | | |
| | | /** |
| | | * 获取公告 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @GetMapping(value = "get/{id}") |
| | | public ExecutedResult<NoticeDetail> get(@PathVariable Long id) { |
| | | return this.service.get(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据id批量获取公告 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "getList") |
| | | public ExecutedResult<List<NoticeVO>> getList(@RequestBody ReqListId request) { |
| | | return this.service.getList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 公告设置排序值 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "setSort") |
| | | public ExecutedResult<String> setSort(@RequestBody ReqSetSort request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | .addGreater(ParameterUtil.named("公告id"), request.getId(), 0L) |
| | | .addGreaterThan(ParameterUtil.named("排序值"), request.getSort(), 0); |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.setSort(request); |
| | | } |
| | | |
| | | /** |
| | | * 停用公告 |
| | | * |
| | | * @param id 项目id |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "stop") |
| | | public ExecutedResult<String> stop(@RequestParam Long id) { |
| | | return this.service.changeStatus(id, EState.DISABLED); |
| | | } |
| | | |
| | | /** |
| | | * 启用公告 |
| | | * |
| | | * @param id 项目id |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "enable") |
| | | public ExecutedResult<String> enable(@RequestParam Long id) { |
| | | return this.service.changeStatus(id, EState.NORMAL); |
| | | } |
| | | |
| | | /** |
| | | * 删除公告 |
| | | * |
| | | * @param id 项目id |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @PostMapping(value = "remove") |
| | | public ExecutedResult<String> remove(@RequestParam Long id) { |
| | | return this.service.changeStatus(id, EState.DELETED); |
| | | } |
| | | |
| | | /** |
| | | * 查询公告 |
| | | * |
| | | * @author lin.liu |
| | | * @date 2023/02/26 |
| | | */ |
| | | @NonLogin |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<NoticeVO>> search(@RequestBody SearchNotice request) { |
| | | return this.service.search(request); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.host.controller.base; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.entity.request.quartztaskinfo.ReqCreateQuartzTaskInfo; |
| | | import com.fengdu.gas.entity.request.quartztaskinfo.ReqModifyQuartzTaskInfo; |
| | | import com.fengdu.gas.entity.request.quartztaskinfo.ReqRunTaskRightNow; |
| | | import com.fengdu.gas.entity.search.SearchQuartzTaskInfo; |
| | | import com.fengdu.gas.entity.search.SearchQuartzTaskRecord; |
| | | import com.fengdu.gas.service.quartz.QuartzService; |
| | | import com.fengdu.gas.host.api.NonLogin; |
| | | import com.fengdu.gas.repository.vo.QuartzTaskErrorVO; |
| | | import com.fengdu.gas.repository.vo.QuartzTaskInfoVO; |
| | | import com.fengdu.gas.repository.vo.QuartzTaskRecordVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 05.任务调度 |
| | | * @author lin.liu |
| | | * @order 05 |
| | | */ |
| | | @NonLogin |
| | | @Controller |
| | | @RequestMapping("quartz") |
| | | public class QuartzController { |
| | | private static final Logger logger = LoggerFactory.getLogger(QuartzController.class); |
| | | |
| | | @Autowired |
| | | private QuartzService quartzService; |
| | | |
| | | /** |
| | | * 任务列表 |
| | | * @param request 请求参数 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("listTask") |
| | | public ExecutedResult<PagerResult<QuartzTaskInfoVO>> listTask(@RequestBody SearchQuartzTaskInfo request) { |
| | | try { |
| | | return quartzService.listTask(request); |
| | | } catch (Exception e) { |
| | | logger.error("listTask", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加任务 |
| | | * @param request 请求参数 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("addTask") |
| | | public ExecutedResult<String> addTask(@RequestBody ReqCreateQuartzTaskInfo request) { |
| | | try { |
| | | return quartzService.addTask(request); |
| | | } catch (Exception e) { |
| | | logger.error("addTask", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改任务 |
| | | * @param request 请求参数 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("editTask") |
| | | public ExecutedResult<String> editTask(@RequestBody ReqModifyQuartzTaskInfo request) { |
| | | try { |
| | | return quartzService.updateTask(request); |
| | | } catch (Exception e) { |
| | | logger.error("editTask", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 启动 或者 暂定定时任务 |
| | | * @param taskId 任务id |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("optionJob/{taskId}") |
| | | public ExecutedResult<String> optionJob(@PathVariable Long taskId) { |
| | | try { |
| | | return quartzService.optionJob(taskId); |
| | | } catch (Exception e) { |
| | | logger.error("optionJob", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 立即运行一次定时任务 |
| | | * @param request 请求参数 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("runTaskRightNow") |
| | | public ExecutedResult<String> runTaskRightNow(@RequestBody ReqRunTaskRightNow request) { |
| | | try { |
| | | return quartzService.runTaskRightNow(request); |
| | | } catch (Exception e) { |
| | | logger.error("/runTaskRightNow", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时任务执行情况 |
| | | * |
| | | * @param search 请求参数 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("taskRecords") |
| | | public ExecutedResult<PagerResult<QuartzTaskRecordVO>> taskRecords(@RequestBody SearchQuartzTaskRecord search) { |
| | | try { |
| | | return quartzService.taskRecords(search); |
| | | } catch (Exception e) { |
| | | logger.error("/taskRecords", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时任务错误详情 |
| | | * |
| | | * @param recordId 执行记录id |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("taskErrors/{recordId}") |
| | | public ExecutedResult<QuartzTaskErrorVO> detailTaskErrors(@PathVariable String recordId) { |
| | | try { |
| | | return quartzService.detailTaskErrors(recordId); |
| | | } catch (Exception e) { |
| | | logger.error("/taskErrors", e); |
| | | return ExecutedResult.failed(e.getMessage()); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.host.controller.base; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.request.ReqListId; |
| | | import com.fengdu.gas.entity.request.sysdictdata.ReqCreateSysDictData; |
| | | import com.fengdu.gas.entity.request.sysdictdata.ReqModifySysDictData; |
| | | import com.fengdu.gas.entity.search.SearchSysDictData; |
| | | import com.fengdu.gas.service.SysDictDataService; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.repository.vo.SysDictDataVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 04.字典数据 |
| | | * @author lin.liu |
| | | * @description 字典数据 |
| | | * @order 04 |
| | | */ |
| | | @RestController |
| | | @RequestMapping(value = "sysDictData") |
| | | public class SysDictDataController extends BasicController { |
| | | @Autowired |
| | | private SysDictDataService service; |
| | | |
| | | /** |
| | | * 创建[字典数据表] |
| | | * @author lin.liu |
| | | * @description 创建[字典数据表] |
| | | */ |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictData request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 非空 |
| | | //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) |
| | | // 限制最大长度 |
| | | //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.create(request, super.getTokenUser()); |
| | | } |
| | | |
| | | /** |
| | | * 编辑[字典数据表] |
| | | * @author lin.liu |
| | | * @description 编辑[字典数据表] |
| | | */ |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifySysDictData request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("[字典数据表]id"), request.getId(), 0L) |
| | | // 非空 |
| | | //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) |
| | | // 限制最大长度 |
| | | //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.modify(request, super.getTokenUser()); |
| | | } |
| | | |
| | | /** |
| | | * 获取[字典数据表] |
| | | * @author lin.liu |
| | | */ |
| | | @GetMapping(value = "get/{id}") |
| | | public ExecutedResult<SysDictDataVO> get(@PathVariable Long id) { |
| | | return this.service.get(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据id删除[字典数据表] |
| | | * @author zr |
| | | * @description 根据id删除[字典数据表] |
| | | */ |
| | | @PostMapping(value = "remove/{id}") |
| | | public ExecutedResult<String> remove(@PathVariable Long id){ |
| | | return this.service.remove(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据id批量删除字典数据 |
| | | * @author zr |
| | | */ |
| | | @PostMapping(value = "removeList") |
| | | public ExecutedResult<String> removeList(@RequestBody ReqListId reqListId){ |
| | | return this.service.removeList(reqListId.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 根据类型获取[字典数据表] |
| | | * @author zr |
| | | */ |
| | | @GetMapping(value = "getListByType/{type}") |
| | | public ExecutedResult<List<SysDictDataVO>> getListByType(@PathVariable String type) { |
| | | return this.service.getListByType(type); |
| | | } |
| | | |
| | | /** |
| | | * 查询[字典数据表] |
| | | * @author lin.liu |
| | | */ |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<SysDictDataVO>> search(@RequestBody SearchSysDictData request) { |
| | | return this.service.search(request); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.host.controller.base; |
| | | |
| | | import com.fengdu.gas.common.ExecutedResult; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ParameterUtil; |
| | | import com.fengdu.gas.common.validator.ParameterValidateResult; |
| | | import com.fengdu.gas.common.validator.ParameterValidator; |
| | | import com.fengdu.gas.entity.request.ReqListId; |
| | | import com.fengdu.gas.entity.request.sysdicttype.ReqCreateSysDictType; |
| | | import com.fengdu.gas.entity.request.sysdicttype.ReqModifySysDictType; |
| | | import com.fengdu.gas.entity.search.SearchSysDictType; |
| | | import com.fengdu.gas.service.SysDictTypeService; |
| | | import com.fengdu.gas.host.BasicController; |
| | | import com.fengdu.gas.repository.vo.SysDictTypeVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 03.字典类型 |
| | | * @author lin.liu |
| | | * @order 03 |
| | | */ |
| | | @RestController |
| | | @RequestMapping(value = "sysDictType") |
| | | public class SysDictTypeController extends BasicController { |
| | | @Autowired |
| | | private SysDictTypeService service; |
| | | |
| | | /** |
| | | * 创建[字典类型表] |
| | | * @author lin.liu |
| | | */ |
| | | @PostMapping(value = "create") |
| | | public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictType request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 非空 |
| | | //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) |
| | | // 限制最大长度 |
| | | //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.create(request); |
| | | } |
| | | |
| | | /** |
| | | * 编辑[字典类型表] |
| | | * @author lin.liu |
| | | */ |
| | | @PostMapping(value = "modify") |
| | | public ExecutedResult<String> modify(@RequestBody ReqModifySysDictType request) { |
| | | //#region 参数验证 |
| | | ParameterValidator validator = new ParameterValidator() |
| | | // 必须大于0 |
| | | .addGreater(ParameterUtil.named("[字典类型表]id"), request.getId(), 0L) |
| | | // 非空 |
| | | //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName()) |
| | | // 限制最大长度 |
| | | //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50) |
| | | ; |
| | | ParameterValidateResult result = validator.validate(); |
| | | if (result.getIsFiled()) { |
| | | return failed(result.getErrorMsg()); |
| | | } |
| | | //#endregion |
| | | return this.service.modify(request); |
| | | } |
| | | |
| | | /** |
| | | * 获取[字典类型表] |
| | | * @author lin.liu |
| | | */ |
| | | @GetMapping(value = "get/{id}") |
| | | public ExecutedResult<SysDictTypeVO> get(@PathVariable Long id) { |
| | | return this.service.get(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据id删除[字典类型表] |
| | | * @author zr |
| | | * @description 根据id删除[字典类型表] |
| | | */ |
| | | @PostMapping(value = "remove/{id}") |
| | | ExecutedResult<String> remove(@PathVariable Long id){ |
| | | return this.service.remove(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据id批量删除字典类型 |
| | | */ |
| | | @PostMapping(value = "removeList") |
| | | public ExecutedResult<String> removeList(@RequestBody ReqListId request) { |
| | | return service.removeList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id批量获取[字典类型表] |
| | | * @author zr |
| | | * @description 根据id批量获取[字典类型表] |
| | | */ |
| | | @PostMapping(value = "getList") |
| | | public ExecutedResult<List<SysDictTypeVO>> getList(@RequestBody ReqListId request) { |
| | | return this.service.getList(request.getListId()); |
| | | } |
| | | |
| | | /** |
| | | * 查询[字典类型表] |
| | | * @author lin.liu |
| | | * @description 查询[字典类型表] |
| | | */ |
| | | @PostMapping(value = "search") |
| | | public ExecutedResult<PagerResult<SysDictTypeVO>> search(@RequestBody SearchSysDictType request) { |
| | | return this.service.search(request); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import org.apache.ibatis.session.ResultHandler; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface BasicMapper<T> extends BaseMapper<T> { |
| | | /** |
| | | * 批量新增 |
| | | * @param list 数据实体列表 |
| | | */ |
| | | Boolean addList(List<T> list); |
| | | |
| | | /** |
| | | * 批量更新 |
| | | * @param list 数据实体列表 |
| | | */ |
| | | Boolean modifyList(List<T> list); |
| | | |
| | | /** |
| | | * 批量查询其他实体列表 |
| | | * @param queryWrapper 查询条件 |
| | | * @param <E> 实体类型 |
| | | */ |
| | | <E> List<E> selectListObject(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * 批量查询其他实体列表 |
| | | * @param queryWrapper 查询条件 |
| | | * @param resultHandler 查询结果处理器 |
| | | * @param <E> 实体类型 |
| | | */ |
| | | <E> void selectListObject(Wrapper<T> queryWrapper, ResultHandler<E> resultHandler); |
| | | |
| | | /** |
| | | * 根据主键查询单个数据实体 |
| | | * |
| | | * @param id 主键值 |
| | | */ |
| | | T get(Serializable id); |
| | | |
| | | /** |
| | | * 条件查询单个数据实体 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | T get(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * 根据主键批量获取 |
| | | * @param listId 主键列表 |
| | | */ |
| | | <E extends Serializable> List<T> getList(List<E> listId); |
| | | |
| | | |
| | | /** |
| | | * 获取全量数据(慎重) |
| | | */ |
| | | List<T> getList(); |
| | | |
| | | /** |
| | | * 根据传入sql查询数据 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | List<Map<String, Object>> getMap(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * 查询记录条数 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | Long getCount(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * 根据主键id删除数据 |
| | | * |
| | | * @param id 主键id |
| | | * @return 是否成功 |
| | | */ |
| | | Boolean remove(Serializable id); |
| | | |
| | | /** |
| | | * 根据主键id删除数据 |
| | | * |
| | | * @param listId id列表 |
| | | * @return 是否成功 |
| | | */ |
| | | <E extends Serializable> Boolean remove(List<E> listId); |
| | | |
| | | /** |
| | | * 根据条件删除数据 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | Boolean remove(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * 根据主键id逻辑删除数据(逻辑删除) |
| | | * |
| | | * @param id 主键id |
| | | * @return 是否成功 |
| | | */ |
| | | Boolean deleteLogic(Serializable id); |
| | | |
| | | /** |
| | | * 根据逐渐删除数据(逻辑删除) |
| | | * |
| | | * @param listId id列表 |
| | | * @return 是否成功 |
| | | */ |
| | | <E extends Serializable> Boolean deleteLogic(List<E> listId); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param search 查询参数 |
| | | */ |
| | | PagerResult<T> search(SearchBasicDTO search); |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.core.batch.BatchSqlSession; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.ELogger; |
| | | import com.fengdu.gas.common.enums.EResultCode; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.exceptions.BusinessException; |
| | | import com.fengdu.gas.common.util.LoggerUtil; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.executor.BatchResult; |
| | | import org.apache.ibatis.session.ResultHandler; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.dao.EmptyResultDataAccessException; |
| | | |
| | | import java.io.Serializable; |
| | | import java.lang.reflect.ParameterizedType; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.BiPredicate; |
| | | |
| | | /** |
| | | * 数据访问 实现类 |
| | | * |
| | | * @param <T> 数据实体 |
| | | */ |
| | | public abstract class BasicMapperImpl<T, M extends BasicMapper<T>> implements BasicMapper<T> { |
| | | protected M DB; |
| | | protected Class<T> clazz; |
| | | protected String tableName; |
| | | |
| | | protected static final Logger logger = LoggerUtil.get(ELogger.SQL_LOG); |
| | | |
| | | /** |
| | | * 构造方法 |
| | | */ |
| | | public BasicMapperImpl(M db) { |
| | | this.clazz = (Class<T>) ( |
| | | (ParameterizedType) getClass().getGenericSuperclass() |
| | | ).getActualTypeArguments()[0]; |
| | | this.DB = db; |
| | | TableName annotation = clazz.getAnnotation(TableName.class); |
| | | if (null == annotation) { |
| | | this.tableName = StringUtils.camelToUnderline(clazz.getSimpleName().replace("PO", "")); |
| | | return; |
| | | } |
| | | this.tableName = annotation.value(); |
| | | } |
| | | |
| | | public LambdaQueryWrapper<T> query() { |
| | | return Wrappers.lambdaQuery(); |
| | | } |
| | | |
| | | public UpdateWrapper<T> update() { |
| | | return Wrappers.update(); |
| | | } |
| | | |
| | | /** |
| | | * 插入一条记录 |
| | | * |
| | | * @param entity 实体对象 |
| | | */ |
| | | public int insert(T entity) { |
| | | return DB.insert(entity); |
| | | } |
| | | |
| | | /** |
| | | * 根据 ID 删除 |
| | | * |
| | | * @param id 主键 |
| | | */ |
| | | public int deleteById(Serializable id) { |
| | | return DB.deleteById(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据 ID 删除 |
| | | * |
| | | * @param useFill 是否填充 |
| | | * @param obj 主键或实体 |
| | | * @since 3.5.7 |
| | | */ |
| | | public int deleteById(Object obj, boolean useFill) { |
| | | return DB.deleteById(obj, useFill); |
| | | } |
| | | |
| | | /** |
| | | * 根据实体(ID)删除 |
| | | * |
| | | * @param entity 实体对象 |
| | | * @since 3.4.4 |
| | | */ |
| | | public int deleteById(T entity) { |
| | | return DB.deleteById(entity); |
| | | } |
| | | |
| | | /** |
| | | * 根据 columnMap 条件,删除记录 |
| | | * |
| | | * @param columnMap 表字段 map 对象 |
| | | */ |
| | | public int deleteByMap(Map<String, Object> columnMap) { |
| | | return DB.deleteByMap(columnMap); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,删除记录 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句) |
| | | */ |
| | | public int delete(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.delete(queryWrapper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除(根据ID或实体 批量删除) |
| | | * |
| | | * @param idList 主键列表或实体列表(不能为 null 以及 empty) |
| | | * @deprecated 3.5.7 {@link #deleteByIds(Collection)} |
| | | */ |
| | | @Deprecated |
| | | public int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList) { |
| | | return DB.deleteBatchIds(idList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除(根据ID或实体 批量删除) |
| | | * |
| | | * @param idList 主键列表或实体列表(不能为 null 以及 empty) |
| | | * @since 3.5.7 |
| | | */ |
| | | public int deleteByIds(@Param(Constants.COLL) Collection<?> idList) { |
| | | return DB.deleteByIds(idList); |
| | | } |
| | | |
| | | /** |
| | | * 删除(根据ID或实体 批量删除) |
| | | * <p> |
| | | * 普通删除: DELETE FROM h2user WHERE id IN ( ? , ? ) |
| | | * </p> |
| | | * <p> |
| | | * 逻辑删除: UPDATE h2user SET deleted=1 WHERE id IN ( ? , ? ) AND deleted=0 |
| | | * </p> |
| | | * <p> |
| | | * 逻辑删除(填充): UPDATE h2user SET delete_user = 'xxx', deleted=1 WHERE id IN ( ? , ? ) AND deleted=0 |
| | | * <ul>注意:无论参数为id还是实体,填充参数只会以方法追加的et参数为准.<ul/> |
| | | * </p> |
| | | * |
| | | * @param collections 主键列表或实体列表(不能为 null 以及 empty) |
| | | * @param useFill 逻辑删除下是否填充 |
| | | * @since 3.5.7 |
| | | */ |
| | | public int deleteByIds(@Param(Constants.COLL) Collection<?> collections, boolean useFill) { |
| | | return DB.deleteByIds(collections, useFill); |
| | | } |
| | | |
| | | /** |
| | | * 根据 ID 修改 |
| | | * |
| | | * @param entity 实体对象 |
| | | */ |
| | | public int updateById(@Param(Constants.ENTITY) T entity) { |
| | | return DB.updateById(entity); |
| | | } |
| | | |
| | | /** |
| | | * 根据 whereEntity 条件,更新记录 |
| | | * |
| | | * @param entity 实体对象 (set 条件值,可以为 null,当entity为null时,无法进行自动填充) |
| | | * @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句) |
| | | */ |
| | | public int update(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper<T> updateWrapper) { |
| | | return DB.update(entity, updateWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 更新记录 |
| | | * <p>此方法无法进行自动填充,如需自动填充请使用{@link #update(Object, Wrapper)}</p> |
| | | * |
| | | * @param updateWrapper {@link UpdateWrapper} or {@link LambdaUpdateWrapper} |
| | | * @since 3.5.4 |
| | | */ |
| | | public int update(@Param(Constants.WRAPPER) Wrapper<T> updateWrapper) { |
| | | return DB.update(updateWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 ID 查询 |
| | | * |
| | | * @param id 主键 |
| | | */ |
| | | public T selectById(Serializable id) { |
| | | return DB.selectById(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询(根据ID 批量查询) |
| | | * |
| | | * @param idList 主键列表(不能为 null 以及 empty) |
| | | */ |
| | | public List<T> selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList) { |
| | | return DB.selectBatchIds(idList); |
| | | } |
| | | |
| | | /** |
| | | * 查询(根据ID 批量查询) |
| | | * |
| | | * @param idList idList 主键列表(不能为 null 以及 empty) |
| | | * @param resultHandler resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public void selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList, ResultHandler<T> resultHandler) { |
| | | DB.selectBatchIds(idList, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 查询(根据 columnMap 条件) |
| | | * |
| | | * @param columnMap 表字段 map 对象 |
| | | */ |
| | | public List<T> selectByMap(Map<String, Object> columnMap) { |
| | | return DB.selectByMap(columnMap); |
| | | } |
| | | |
| | | /** |
| | | * 查询(根据 columnMap 条件) |
| | | * |
| | | * @param columnMap 表字段 map 对象 |
| | | * @param resultHandler resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public void selectByMap(Map<String, Object> columnMap, ResultHandler<T> resultHandler) { |
| | | DB.selectByMap(columnMap, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询一条记录 |
| | | * <p>查询一条记录,例如 qw.last("limit 1") 限制取一条记录, 注意:多条数据会报异常</p> |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | */ |
| | | public T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectOne(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询一条记录,现在会根据{@code throwEx}参数判断是否抛出异常,如果为false就直接返回一条数据 |
| | | * <p>查询一条记录,例如 qw.last("limit 1") 限制取一条记录, 注意:多条数据会报异常</p> |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | * @param throwEx boolean 参数,为true如果存在多个结果直接抛出异常 |
| | | */ |
| | | public T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, boolean throwEx) { |
| | | return DB.selectOne(queryWrapper, throwEx); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,判断是否存在记录 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类 |
| | | * @return 是否存在记录 |
| | | */ |
| | | public boolean exists(Wrapper<T> queryWrapper) { |
| | | return DB.exists(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询总记录数 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | */ |
| | | public Long selectCount(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectCount(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询全部记录 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | */ |
| | | public List<T> selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询全部记录 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | * @param resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public void selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<T> resultHandler) { |
| | | DB.selectList(queryWrapper, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询全部记录(并翻页) |
| | | * |
| | | * @param page 分页查询条件 |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | * @since 3.5.3.2 |
| | | */ |
| | | public List<T> selectList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectList(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询全部记录(并翻页) |
| | | * |
| | | * @param page 分页查询条件 |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | * @param resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public void selectList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<T> resultHandler) { |
| | | DB.selectList(page, queryWrapper, resultHandler); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类 |
| | | */ |
| | | public List<Map<String, Object>> selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectMaps(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录 |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类 |
| | | * @param resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public void selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) { |
| | | DB.selectMaps(queryWrapper, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录(并翻页) |
| | | * |
| | | * @param page 分页查询条件 |
| | | * @param queryWrapper 实体对象封装操作类 |
| | | * @since 3.5.3.2 |
| | | */ |
| | | public List<Map<String, Object>> selectMaps(IPage<? extends Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectMaps(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录(并翻页) |
| | | * |
| | | * @param page 分页查询条件 |
| | | * @param queryWrapper 实体对象封装操作类 |
| | | * @param resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public void selectMaps(IPage<? extends Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) { |
| | | DB.selectMaps(page, queryWrapper, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录 |
| | | * <p>注意: 只返回第一个字段的值</p> |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | */ |
| | | public <E> List<E> selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectObjs(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录 |
| | | * <p>注意: 只返回第一个字段的值</p> |
| | | * |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | * @param resultHandler 结果处理器 {@link ResultHandler} |
| | | * @since 3.5.4 |
| | | */ |
| | | public <E> void selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, ResultHandler<E> resultHandler) { |
| | | DB.selectObjs(queryWrapper, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 根据 entity 条件,查询全部记录(并翻页) |
| | | * |
| | | * @param page 分页查询条件 |
| | | * @param queryWrapper 实体对象封装操作类(可以为 null) |
| | | */ |
| | | public <P extends IPage<T>> P selectPage(P page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Wrapper 条件,查询全部记录(并翻页) |
| | | * |
| | | * @param page 分页查询条件 |
| | | * @param queryWrapper 实体对象封装操作类 |
| | | */ |
| | | public <P extends IPage<Map<String, Object>>> P selectMapsPage(P page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper) { |
| | | return DB.selectMapsPage(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 主键存在更新记录,否插入一条记录 |
| | | * |
| | | * @param entity 实体对象 (不能为空) |
| | | * @since 3.5.7 |
| | | */ |
| | | public boolean insertOrUpdate(T entity) { |
| | | return DB.insertOrUpdate(entity); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 插入(批量) |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> insert(Collection<T> entityList) { |
| | | return DB.insert(entityList); |
| | | } |
| | | |
| | | /** |
| | | * 插入(批量) |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @param batchSize 插入批次数量 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> insert(Collection<T> entityList, int batchSize) { |
| | | return DB.insert(entityList, batchSize); |
| | | } |
| | | |
| | | /** |
| | | * 根据ID 批量更新 |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> updateById(Collection<T> entityList) { |
| | | return DB.updateById(entityList); |
| | | } |
| | | |
| | | /** |
| | | * 根据ID 批量更新 |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @param batchSize 插入批次数量 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> updateById(Collection<T> entityList, int batchSize) { |
| | | return DB.updateById(entityList, batchSize); |
| | | } |
| | | |
| | | /** |
| | | * 批量修改或插入 |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> insertOrUpdate(Collection<T> entityList) { |
| | | return DB.insertOrUpdate(entityList); |
| | | } |
| | | |
| | | /** |
| | | * 批量修改或插入 |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @param batchSize 插入批次数量 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> insertOrUpdate(Collection<T> entityList, int batchSize) { |
| | | return DB.insertOrUpdate(entityList, batchSize); |
| | | } |
| | | |
| | | /** |
| | | * 批量修改或插入 |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> insertOrUpdate(Collection<T> entityList, BiPredicate<BatchSqlSession, T> insertPredicate) { |
| | | return DB.insertOrUpdate(entityList, insertPredicate); |
| | | } |
| | | |
| | | /** |
| | | * 批量修改或插入 |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @param batchSize 插入批次数量 |
| | | * @since 3.5.7 |
| | | */ |
| | | public List<BatchResult> insertOrUpdate(Collection<T> entityList, BiPredicate<BatchSqlSession, T> insertPredicate, int batchSize) { |
| | | return DB.insertOrUpdate(entityList, insertPredicate, batchSize); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量新增 |
| | | * |
| | | * @param list 数据实体列表 |
| | | */ |
| | | public Boolean addList(List<T> list) { |
| | | List<BatchResult> batchResult = DB.insert(list); |
| | | // TODO 判断成功 |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | /** |
| | | * 批量更新 |
| | | * |
| | | * @param list 数据实体列表 |
| | | */ |
| | | public Boolean modifyList(List<T> list) { |
| | | List<BatchResult> batchResult = DB.updateById(list); |
| | | // TODO 判断成功 |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | /** |
| | | * 批量查询其他实体列表 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | public <E> List<E> selectListObject(Wrapper<T> queryWrapper) { |
| | | return DB.selectObjs(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 批量查询其他实体列表 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @param resultHandler 查询结果处理器 |
| | | */ |
| | | public <E> void selectListObject(Wrapper<T> queryWrapper, ResultHandler<E> resultHandler) { |
| | | DB.selectObjs(queryWrapper, resultHandler); |
| | | } |
| | | |
| | | /** |
| | | * 根据主键查询单个数据实体 |
| | | * |
| | | * @param id 主键值 |
| | | */ |
| | | public T get(Serializable id) { |
| | | return DB.selectById(id); |
| | | } |
| | | |
| | | /** |
| | | * 条件查询单个数据实体 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | public T get(Wrapper<T> queryWrapper) { |
| | | String method = "BasicDao.Wrapper<T> queryWrapper"; |
| | | try { |
| | | return DB.selectOne(queryWrapper); |
| | | } catch (EmptyResultDataAccessException e) { |
| | | logger.error(method, e); |
| | | return null; |
| | | } catch (Exception e) { |
| | | logger.error(method + ", 发生异常", e); |
| | | throw new BusinessException(EResultCode.ERROR, "BasicDao.get(SqlBuilder builder)发生异常." + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据主键批量获取 |
| | | * |
| | | * @param listId 主键列表 |
| | | */ |
| | | public <E extends Serializable> List<T> getList(List<E> listId) { |
| | | return DB.selectBatchIds(listId); |
| | | } |
| | | |
| | | /** |
| | | * 获取全量数据(慎重) |
| | | */ |
| | | public List<T> getList() { |
| | | return DB.selectList(null); |
| | | } |
| | | |
| | | /** |
| | | * 根据传入sql查询数据 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | public List<Map<String, Object>> getMap(Wrapper<T> queryWrapper) { |
| | | return DB.selectMaps(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 查询记录条数 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | public Long getCount(Wrapper<T> queryWrapper) { |
| | | return DB.selectCount(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据主键删除数据 |
| | | * |
| | | * @param id 主键 |
| | | * @return 是否成功 |
| | | */ |
| | | public Boolean remove(Serializable id) { |
| | | int rowCount = DB.deleteById(id); |
| | | if (rowCount > 0) { |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | | } |
| | | |
| | | /** |
| | | * 根据主键删除数据 |
| | | * |
| | | * @param listId id列表 |
| | | * @return 是否成功 |
| | | */ |
| | | public <E extends Serializable> Boolean remove(List<E> listId) { |
| | | int rowCount = DB.deleteByIds(listId); |
| | | if (rowCount > 0) { |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据条件删除数据 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | */ |
| | | public Boolean remove(Wrapper<T> queryWrapper) { |
| | | int rowCount = DB.delete(queryWrapper); |
| | | if (rowCount > 0) { |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | | } |
| | | |
| | | /** |
| | | * 根据主键逻辑删除数据(逻辑删除) |
| | | * |
| | | * @param id 主键 |
| | | * @return 是否成功 |
| | | */ |
| | | public Boolean deleteLogic(Serializable id) { |
| | | UpdateWrapper<T> where = Wrappers.update(); |
| | | where.set("is_delete", EYesOrNo.YES.getValue()); |
| | | where.eq("id", id); |
| | | int rowCount = DB.update(where); |
| | | if (rowCount > 0) { |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | | } |
| | | |
| | | /** |
| | | * 根据逐渐删除数据(逻辑删除) |
| | | * |
| | | * @param listId id列表 |
| | | * @return 是否成功 |
| | | */ |
| | | public <E extends Serializable> Boolean deleteLogic(List<E> listId) { |
| | | UpdateWrapper<T> where = Wrappers.update(); |
| | | where.set("is_delete", EYesOrNo.YES.getValue()); |
| | | where.in("id", listId); |
| | | int rowCount = DB.update(where); |
| | | if (rowCount > 0) { |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param search 查询参数 |
| | | */ |
| | | @Override |
| | | public abstract PagerResult<T> search(SearchBasicDTO search); |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository.bo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("admin_user") |
| | | public class AdminUserBO implements Serializable { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId |
| | | @TableField("id") |
| | | private Long id; |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | @TableField("user_name") |
| | | private String userName; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | @TableField("nick_name") |
| | | private String nickName; |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository.bo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * 公告-不返回内容 |
| | | * @author lin.liu |
| | | * @description 公告 |
| | | * @date 2023/02/26 |
| | | */ |
| | | @Data |
| | | @TableName("notice") |
| | | public class NoticeBO implements Serializable { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId |
| | | @TableField("id") |
| | | private Long id; |
| | | /** |
| | | * 发布人 |
| | | */ |
| | | @TableField("user_id") |
| | | private Long userId; |
| | | /** |
| | | * 发布人昵称 |
| | | */ |
| | | @TableField("user_nick_name") |
| | | private String userNickName; |
| | | /** |
| | | * 标题 |
| | | */ |
| | | @TableField("title") |
| | | private String title; |
| | | /** |
| | | * 摘要 |
| | | */ |
| | | @TableField("summary") |
| | | private String summary; |
| | | /** |
| | | * 排序 越大越靠后 |
| | | */ |
| | | @TableField("sort") |
| | | private Integer sort; |
| | | /** |
| | | * 状态(EState) 正常=1,关闭=2,删除=3 |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField("create_time") |
| | | private Long createTime; |
| | | /** |
| | | * 数据最后更新时间 |
| | | */ |
| | | @TableField("update_time") |
| | | private Timestamp updateTime; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchAdminMenu; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminMenuMapper; |
| | | import com.fengdu.gas.repository.po.AdminMenuPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 后台菜单 |
| | | * @author lin.liu |
| | | * @description 后台菜单 |
| | | */ |
| | | @Repository |
| | | public class AdminMenuMapperImpl extends BasicMapperImpl<AdminMenuPO, AdminMenuMapper> { |
| | | public AdminMenuMapper mapper; |
| | | AdminMenuMapperImpl(AdminMenuMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminMenuPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminMenu search = (SearchAdminMenu)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminMenuPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminMenuPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminMenuPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminMenuPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminMenuPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminMenuPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.and(q -> |
| | | q.like(AdminMenuPO::getName, search.getKeywords()) |
| | | .or().like(AdminMenuPO::getTitle, search.getKeywords()) |
| | | ); |
| | | } |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminMenuPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminMenuPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminMenuPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminMenuPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminMenuPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminMenuPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminMenuPO::getId); |
| | | } |
| | | Page<AdminMenuPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 根据父级菜单获取子菜单列表 |
| | | * @param parentId 父级菜单id |
| | | */ |
| | | public List<AdminMenuPO> list4Parent(Long parentId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminMenuPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(AdminMenuPO::getParentId, parentId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.entity.search.SearchAdminMenus; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminMenusMapper; |
| | | import com.fengdu.gas.common.util.*; |
| | | import com.fengdu.gas.entity.dto.*; |
| | | import com.fengdu.gas.entity.enums.*; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.fengdu.gas.repository.po.AdminMenusPO; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * @author lin.liu |
| | | */ |
| | | @Repository |
| | | public class AdminMenusMapperImpl extends BasicMapperImpl<AdminMenusPO, AdminMenusMapper> { |
| | | AdminMenusMapperImpl(AdminMenusMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminMenusPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminMenus search = (SearchAdminMenus)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminMenusPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminMenusPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminMenusPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminMenusPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminMenusPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminMenusPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(AdminMenusPO::getName, search.getKeywords()) |
| | | // .or().like(AdminMenusPO::getPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminMenusPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminMenusPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminMenusPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminMenusPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminMenusPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminMenusPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminMenusPO::getId); |
| | | } |
| | | Page<AdminMenusPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | public Boolean add(AdminMenusPO item) { |
| | | int rowCount = super.insert(item); |
| | | return rowCount == 1; |
| | | } |
| | | |
| | | public Boolean addNotIncrement(AdminMenusPO item) { |
| | | int rowCount = super.insert(item); |
| | | return rowCount == 1; |
| | | } |
| | | |
| | | public AdminMenusPO getById(Long id) { |
| | | return super.get(id); |
| | | } |
| | | |
| | | public List<AdminMenusPO> getListById(List<Long> listId) { |
| | | return super.getList(listId); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchAdminPermission; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminPermissionMapper; |
| | | import com.fengdu.gas.repository.po.AdminPermissionPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 后台用户权限表 |
| | | * @author lin.liu |
| | | * @description 后台用户权限表 |
| | | */ |
| | | @Repository |
| | | public class AdminPermissionMapperImpl extends BasicMapperImpl<AdminPermissionPO, AdminPermissionMapper> { |
| | | AdminPermissionMapperImpl(AdminPermissionMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminPermissionPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminPermission search = (SearchAdminPermission)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminPermissionPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminPermissionPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminPermissionPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminPermissionPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminPermissionPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.and(q -> |
| | | q.like(AdminPermissionPO::getName, search.getKeywords()) |
| | | .or().like(AdminPermissionPO::getMenuUrl, search.getKeywords()) |
| | | ); |
| | | } |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminPermissionPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminPermissionPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminPermissionPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminPermissionPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminPermissionPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminPermissionPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminPermissionPO::getId); |
| | | } |
| | | Page<AdminPermissionPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 根据菜单id获取权限列表 |
| | | * @param listMenuId 菜单id |
| | | */ |
| | | public List<AdminPermissionPO> list4MenuId(List<Long> listMenuId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); |
| | | queryWrapper.in(AdminPermissionPO::getMenuId, listMenuId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | public AdminPermissionPO get4Sn(String sn) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminPermissionPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(AdminPermissionPO::getSn, sn); |
| | | return DB.selectOne(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.entity.search.SearchAdminRole; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminRoleMapper; |
| | | import com.fengdu.gas.repository.po.AdminRolePO; |
| | | import com.fengdu.gas.common.util.*; |
| | | import com.fengdu.gas.entity.dto.*; |
| | | import com.fengdu.gas.entity.enums.*; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * 后台用户角色表 |
| | | * @author lin.liu |
| | | * @description 后台用户角色表 |
| | | */ |
| | | @Repository |
| | | public class AdminRoleMapperImpl extends BasicMapperImpl<AdminRolePO, AdminRoleMapper> { |
| | | AdminRoleMapperImpl(AdminRoleMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminRolePO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminRole search = (SearchAdminRole)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRolePO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminRolePO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRolePO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRolePO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRolePO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRolePO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.and(q -> |
| | | q.like(AdminRolePO::getName, search.getKeywords()) |
| | | .or().like(AdminRolePO::getDescription, search.getKeywords()) |
| | | ); |
| | | } |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminRolePO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRolePO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRolePO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminRolePO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRolePO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRolePO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminRolePO::getId); |
| | | } |
| | | Page<AdminRolePO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | }} |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchAdminRoleMenuRelation; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminRoleMenuRelationMapper; |
| | | import com.fengdu.gas.repository.po.AdminRoleMenuRelationPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 后台角色菜单关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色菜单关系表 |
| | | */ |
| | | @Repository |
| | | public class AdminRoleMenuRelationMapperImpl extends BasicMapperImpl<AdminRoleMenuRelationPO, AdminRoleMenuRelationMapper> { |
| | | AdminRoleMenuRelationMapperImpl(AdminRoleMenuRelationMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminRoleMenuRelationPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminRoleMenuRelation search = (SearchAdminRoleMenuRelation)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminRoleMenuRelationPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRoleMenuRelationPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRoleMenuRelationPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRoleMenuRelationPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRoleMenuRelationPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(AdminRoleMenuRelationPO::getName, search.getKeywords()) |
| | | // .or().like(AdminRoleMenuRelationPO::getPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRoleMenuRelationPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminRoleMenuRelationPO::getId); |
| | | } |
| | | Page<AdminRoleMenuRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色id获取角色拥有的菜单列表 |
| | | * @param roleId 角色id |
| | | */ |
| | | public List<AdminRoleMenuRelationPO> list4Role(Long roleId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(AdminRoleMenuRelationPO::getRoleId, roleId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色id获取角色拥有的菜单列表 |
| | | * @param listRoleId 角色id列表 |
| | | */ |
| | | public List<AdminRoleMenuRelationPO> list4Role(List<Long> listRoleId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRoleMenuRelationPO> queryWrapper = this.query(); |
| | | queryWrapper.in(AdminRoleMenuRelationPO::getRoleId, listRoleId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchAdminRolePermissionRelation; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminRolePermissionRelationMapper; |
| | | import com.fengdu.gas.repository.po.AdminRolePermissionRelationPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 后台角色权限关系表 |
| | | * @author lin.liu |
| | | * @description 后台角色权限关系表 |
| | | */ |
| | | @Repository |
| | | public class AdminRolePermissionRelationMapperImpl extends BasicMapperImpl<AdminRolePermissionRelationPO, AdminRolePermissionRelationMapper> { |
| | | AdminRolePermissionRelationMapperImpl(AdminRolePermissionRelationMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminRolePermissionRelationPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminRolePermissionRelation search = (SearchAdminRolePermissionRelation)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminRolePermissionRelationPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRolePermissionRelationPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRolePermissionRelationPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRolePermissionRelationPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRolePermissionRelationPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(AdminRolePermissionRelationPO::getName, search.getKeywords()) |
| | | // .or().like(AdminRolePermissionRelationPO::getPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRolePermissionRelationPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminRolePermissionRelationPO::getId); |
| | | } |
| | | Page<AdminRolePermissionRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取拥有的权限列表 |
| | | * @param roleId 角色id |
| | | */ |
| | | public List<AdminRolePermissionRelationPO> list4Role(Long roleId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(AdminRolePermissionRelationPO::getRoleId, roleId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取拥有的权限列表 |
| | | * @param listRoleId 角色id列表 |
| | | */ |
| | | public List<AdminRolePermissionRelationPO> list4Role(List<Long> listRoleId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRolePermissionRelationPO> queryWrapper = this.query(); |
| | | queryWrapper.in(AdminRolePermissionRelationPO::getRoleId, listRoleId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchAdminRoleRelation; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminRoleRelationMapper; |
| | | import com.fengdu.gas.repository.po.AdminRoleRelationPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 后台用户和角色关系表 |
| | | * @author lin.liu |
| | | * @description 后台用户和角色关系表 |
| | | */ |
| | | @Repository |
| | | public class AdminRoleRelationMapperImpl extends BasicMapperImpl<AdminRoleRelationPO, AdminRoleRelationMapper> { |
| | | AdminRoleRelationMapperImpl(AdminRoleRelationMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminRoleRelationPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminRoleRelation search = (SearchAdminRoleRelation)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminRoleRelationPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminRoleRelationPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminRoleRelationPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminRoleRelationPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminRoleRelationPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(AdminRoleRelationPO::getName, search.getKeywords()) |
| | | // .or().like(AdminRoleRelationPO::getPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminRoleRelationPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRoleRelationPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminRoleRelationPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminRoleRelationPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRoleRelationPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminRoleRelationPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminRoleRelationPO::getId); |
| | | } |
| | | Page<AdminRoleRelationPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 根据管理员获取拥有的角色列表 |
| | | * @param adminId 管理员id |
| | | */ |
| | | public List<AdminRoleRelationPO> list4Admin(Long adminId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(AdminRoleRelationPO::getAdminId, adminId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据管理员获取拥有的角色列表 |
| | | * @param listAdminId 管理员id列表 |
| | | */ |
| | | public List<AdminRoleRelationPO> list4Admin(List<Long> listAdminId) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminRoleRelationPO> queryWrapper = this.query(); |
| | | queryWrapper.in(AdminRoleRelationPO::getAdminId, listAdminId); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * # __----~~~~~~~~~~~------___ |
| | | * # . . ~~//====...... __--~ ~~ |
| | | * # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | * # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | * # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | * # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | * # .~ .~ | \\ -_ / /- / || \ / |
| | | * # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | * # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | * # ' ~-| /| |-~\~~ __--~~ |
| | | * # |-~~-_/ | | ~\_ _-~ /\ |
| | | * # / \ \__ \/~ \__ |
| | | * # _--~ _/ | .-~~____--~-/ ~~==. |
| | | * # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | * # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | * # _-~-__ ~) \--______________--~~ |
| | | * # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | * # //.-~~~--\ |
| | | * # 神兽保佑 |
| | | * # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchAdminUser; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.AdminUserMapper; |
| | | import com.fengdu.gas.repository.po.AdminUserPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * 管理员帐号 |
| | | * @author lin.liu |
| | | * @description 管理员帐号 |
| | | */ |
| | | @Repository |
| | | public class AdminUserMapperImpl extends BasicMapperImpl<AdminUserPO, AdminUserMapper> { |
| | | AdminUserMapperImpl(AdminUserMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<AdminUserPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchAdminUser search = (SearchAdminUser) request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminUserPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(AdminUserPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AdminUserPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AdminUserPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AdminUserPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AdminUserPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.and(q -> |
| | | q.like(AdminUserPO::getUserName, search.getKeywords()) |
| | | .or().like(AdminUserPO::getNickName, search.getKeywords()) |
| | | .or().like(AdminUserPO::getContact, search.getKeywords()) |
| | | .or().like(AdminUserPO::getEmail, search.getKeywords()) |
| | | ); |
| | | } |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(AdminUserPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(AdminUserPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(AdminUserPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(AdminUserPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(AdminUserPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(AdminUserPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(AdminUserPO::getId); |
| | | } |
| | | Page<AdminUserPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户名获取管理端用户 |
| | | * @param userName 用户名 |
| | | */ |
| | | public AdminUserPO get4Name(String userName) { |
| | | // 查询条件 |
| | | LambdaQueryWrapper<AdminUserPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(AdminUserPO::getUserName, userName); |
| | | return DB.selectOne(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchNotice; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.NoticeMapper; |
| | | import com.fengdu.gas.repository.po.NoticePO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * 公告 |
| | | * @author lin.liu |
| | | * @description 公告 |
| | | */ |
| | | @Repository |
| | | public class NoticeMapperImpl extends BasicMapperImpl<NoticePO, NoticeMapper> { |
| | | NoticeMapperImpl(NoticeMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<NoticePO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchNotice search = (SearchNotice)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<NoticePO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(NoticePO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, NoticePO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), NoticePO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(NoticePO::getName, search.getKeywords()) |
| | | // .or().like(NoticePO::getPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(NoticePO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(NoticePO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(NoticePO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(NoticePO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(NoticePO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(NoticePO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(NoticePO::getId); |
| | | } |
| | | return new PagerResult<>(search.getLimit(), search.getPage(), 0L, new ArrayList<>()); |
| | | // DB.selectCount() |
| | | // Page<NoticeBO> pageResult = DB.selectObjs(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | // return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | }} |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchQuartzTaskError; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.QuartzTaskErrorMapper; |
| | | import com.fengdu.gas.repository.po.QuartzTaskErrorPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * 定时任务错误信息表 |
| | | * @author lin.liu |
| | | * @description 定时任务错误信息表 |
| | | */ |
| | | @Repository |
| | | public class QuartzTaskErrorMapperImpl extends BasicMapperImpl<QuartzTaskErrorPO, QuartzTaskErrorMapper> { |
| | | public QuartzTaskErrorMapperImpl(QuartzTaskErrorMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param request 请求参数 |
| | | */ |
| | | @Override |
| | | public PagerResult<QuartzTaskErrorPO> search(SearchBasicDTO request) { |
| | | // 查询条件类型还原 |
| | | SearchQuartzTaskError search = (SearchQuartzTaskError)request; |
| | | |
| | | LambdaQueryWrapper<QuartzTaskErrorPO> queryWrapper = this.query(); |
| | | // 状态非逻辑删除 |
| | | queryWrapper.eq(QuartzTaskErrorPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskErrorPO::getState, search.getStatus()); |
| | | // 状态列表 |
| | | //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskErrorPO::getState, search.getListStatus()); |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskErrorPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskErrorPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(QuartzTaskErrorPO::getRealName, search.getKeywords()) |
| | | // .or().like(QuartzTaskErrorPO::getContactPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(QuartzTaskErrorPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskErrorPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskErrorPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(QuartzTaskErrorPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskErrorPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskErrorPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(QuartzTaskErrorPO::getId); |
| | | } |
| | | Page<QuartzTaskErrorPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | public QuartzTaskErrorPO get4RecordId(String recordId) { |
| | | LambdaQueryWrapper<QuartzTaskErrorPO> queryWrapper = this.query(); |
| | | // 执行记录编号 |
| | | queryWrapper.eq(QuartzTaskErrorPO::getTaskExecuteRecordId, recordId); |
| | | return DB.selectOne(queryWrapper); |
| | | } |
| | | |
| | | public int clear4DateTime(long time) { |
| | | LambdaQueryWrapper<QuartzTaskErrorPO> query = this.query(); |
| | | query.lt(QuartzTaskErrorPO::getCreateTime, time); |
| | | return DB.delete(query); |
| | | |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchQuartzTaskInfo; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.QuartzTaskInfoMapper; |
| | | import com.fengdu.gas.repository.po.QuartzTaskInfoPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 定时任务信息表 |
| | | * |
| | | * @author lin.liu |
| | | * @description 定时任务信息表 |
| | | */ |
| | | @Repository |
| | | public class QuartzTaskInfoMapperImpl extends BasicMapperImpl<QuartzTaskInfoPO, QuartzTaskInfoMapper> { |
| | | public QuartzTaskInfoMapperImpl(QuartzTaskInfoMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param request 请求参数 |
| | | */ |
| | | @Override |
| | | public PagerResult<QuartzTaskInfoPO> search(SearchBasicDTO request) { |
| | | // 查询条件类型还原 |
| | | SearchQuartzTaskInfo search = (SearchQuartzTaskInfo) request; |
| | | |
| | | LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); |
| | | // 状态非逻辑删除 |
| | | queryWrapper.eq(QuartzTaskInfoPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskInfoPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskInfoPO::getStatus, search.getListStatus()); |
| | | // 任务编号 |
| | | queryWrapper.eq(StringUtil.isNotNullOrEmpty(search.getTaskNo()), QuartzTaskInfoPO::getTaskNo, search.getTaskNo()); |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskInfoPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskInfoPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.like(QuartzTaskInfoPO::getTaskName, search.getKeywords()); |
| | | } |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(QuartzTaskInfoPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskInfoPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskInfoPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(QuartzTaskInfoPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskInfoPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskInfoPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(QuartzTaskInfoPO::getId); |
| | | } |
| | | Page<QuartzTaskInfoPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | public List<QuartzTaskInfoPO> list4Status(Integer status) { |
| | | LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); |
| | | // 非逻辑删除 |
| | | queryWrapper.eq(QuartzTaskInfoPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | queryWrapper.eq(QuartzTaskInfoPO::getStatus, status); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | public QuartzTaskInfoPO get4No(String taskNo) { |
| | | LambdaQueryWrapper<QuartzTaskInfoPO> queryWrapper = this.query(); |
| | | // 任务编号 |
| | | queryWrapper.eq(QuartzTaskInfoPO::getTaskNo, taskNo); |
| | | return DB.selectOne(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.enums.EYesOrNo; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchQuartzTaskRecord; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.QuartzTaskRecordMapper; |
| | | import com.fengdu.gas.repository.po.QuartzTaskRecordPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * 定时任务执行情况记录表 |
| | | * @author lin.liu |
| | | * @description 定时任务执行情况记录表 |
| | | */ |
| | | @Repository |
| | | public class QuartzTaskRecordMapperImpl extends BasicMapperImpl<QuartzTaskRecordPO, QuartzTaskRecordMapper> { |
| | | public QuartzTaskRecordMapperImpl(QuartzTaskRecordMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param request 请求参数 |
| | | */ |
| | | @Override |
| | | public PagerResult<QuartzTaskRecordPO> search(SearchBasicDTO request) { |
| | | // 查询条件类型还原 |
| | | SearchQuartzTaskRecord search = (SearchQuartzTaskRecord)request; |
| | | |
| | | LambdaQueryWrapper<QuartzTaskRecordPO> queryWrapper = this.query(); |
| | | // 状态非逻辑删除 |
| | | queryWrapper.eq(QuartzTaskRecordPO::getIsDelete, EYesOrNo.NO.getValue()); |
| | | // 状态 |
| | | queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, QuartzTaskRecordPO::getTaskStatus, search.getStatus()); |
| | | // 状态列表 |
| | | queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), QuartzTaskRecordPO::getTaskStatus, search.getListStatus()); |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, QuartzTaskRecordPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, QuartzTaskRecordPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 任务编号 |
| | | queryWrapper.eq(StringUtil.isNotNullOrEmpty(search.getTaskNo()), QuartzTaskRecordPO::getTaskNo, search.getTaskNo()); |
| | | // 执行时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getExecuteTimeStart()).compareTo(0L) > 0, QuartzTaskRecordPO::getStartTime, search.getExecuteTimeStart()); |
| | | // 执行时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getExecuteTimeEnd()).compareTo(0L) > 0, QuartzTaskRecordPO::getStartTime, search.getExecuteTimeEnd()); |
| | | // 关键字 |
| | | //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | // queryWrapper.and(q -> |
| | | // q.like(QuartzTaskRecordPO::getRealName, search.getKeywords()) |
| | | // .or().like(QuartzTaskRecordPO::getContactPhone, search.getKeywords()) |
| | | // ); |
| | | //} |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(QuartzTaskRecordPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskRecordPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskRecordPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(QuartzTaskRecordPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskRecordPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(QuartzTaskRecordPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(QuartzTaskRecordPO::getId); |
| | | } |
| | | Page<QuartzTaskRecordPO> pageResult = DB.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | public int clear4DateTime(long time) { |
| | | LambdaQueryWrapper<QuartzTaskRecordPO> query = this.query(); |
| | | query.lt(QuartzTaskRecordPO::getCreateTime, time); |
| | | return DB.delete(query); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchSysDictData; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.SysDictDataMapper; |
| | | import com.fengdu.gas.repository.po.SysDictDataPO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 字典数据表 |
| | | * @author lin.liu |
| | | * @description 字典数据表 |
| | | */ |
| | | @Repository |
| | | public class SysDictDataMapperImpl extends BasicMapperImpl<SysDictDataPO, SysDictDataMapper> { |
| | | SysDictDataMapperImpl(SysDictDataMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<SysDictDataPO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchSysDictData search = (SearchSysDictData)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); |
| | | // 状态 |
| | | queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, SysDictDataPO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), SysDictDataPO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, SysDictDataPO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, SysDictDataPO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.like(SysDictDataPO::getDictLabel, search.getKeywords()); |
| | | } |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(SysDictDataPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(SysDictDataPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(SysDictDataPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(SysDictDataPO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(SysDictDataPO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(SysDictDataPO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(SysDictDataPO::getId); |
| | | } |
| | | Page<SysDictDataPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | public Boolean add(SysDictDataPO item) { |
| | | int rowCount = super.insert(item); |
| | | return rowCount == 1; |
| | | } |
| | | /** |
| | | * 根据type获取数据列表 |
| | | * @param type 类型 |
| | | */ |
| | | public List<SysDictDataPO> getListByType(String type) { |
| | | LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(SysDictDataPO::getDictType, type); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | public Long count4Type(String type) { |
| | | LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); |
| | | queryWrapper.eq(SysDictDataPO::getDictType, type); |
| | | return DB.getCount(queryWrapper); |
| | | } |
| | | public List<String> findExists4Type(List<String> listType) { |
| | | LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); |
| | | queryWrapper.select(SysDictDataPO.class, c -> c.getColumn().equals("dict_type")); |
| | | queryWrapper.in(SysDictDataPO::getDictType, listType); |
| | | List<Map<String, Object>> result = DB.selectMaps(queryWrapper); |
| | | return result.stream().map(c -> c.get("dict_type").toString()).distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | public Boolean addNotIncrement(SysDictDataPO item) { |
| | | int rowCount = super.insert(item); |
| | | return rowCount == 1; |
| | | } |
| | | |
| | | public SysDictDataPO getById(Long id) { |
| | | return super.get(id); |
| | | } |
| | | |
| | | public List<SysDictDataPO> getListById(List<Long> listId) { |
| | | return super.getList(listId); |
| | | } |
| | | |
| | | public List<SysDictDataPO> listByType(List<String> listType) { |
| | | LambdaQueryWrapper<SysDictDataPO> queryWrapper = this.query(); |
| | | queryWrapper.in(SysDictDataPO::getDictType, listType); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | |
| | | public Map<String, Map<String, String>> map4Type(List<String> listType) { |
| | | Map<String, Map<String, String>> result = new HashMap<>(); |
| | | |
| | | List<SysDictDataPO> listDictData = this.listByType(listType); |
| | | Map<String, List<SysDictDataPO>> map4Type = listDictData.stream().collect(Collectors.groupingBy(SysDictDataPO::getDictType)); |
| | | for (Map.Entry<String, List<SysDictDataPO>> entry : map4Type.entrySet()) { |
| | | Map<String, String> mapData = entry.getValue().stream().collect( |
| | | Collectors.toMap(SysDictDataPO::getDictValue, SysDictDataPO::getDictLabel) |
| | | ); |
| | | result.put(entry.getKey(), mapData); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, SysDictDataPO> map4Type(String type) { |
| | | List<SysDictDataPO> listDictData = this.getListByType(type); |
| | | if (ListUtil.isNullOrEmpty(listDictData)) { |
| | | return new HashMap<>(); |
| | | } |
| | | return listDictData.stream().collect(Collectors.toMap(SysDictDataPO::getDictValue, c -> c)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.repository.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fengdu.gas.common.PagerResult; |
| | | import com.fengdu.gas.common.util.ListUtil; |
| | | import com.fengdu.gas.common.util.NumericUtil; |
| | | import com.fengdu.gas.common.util.StringUtil; |
| | | import com.fengdu.gas.entity.dto.OrderByDTO; |
| | | import com.fengdu.gas.entity.dto.SearchBasicDTO; |
| | | import com.fengdu.gas.entity.enums.EOrderBy; |
| | | import com.fengdu.gas.entity.search.SearchSysDictType; |
| | | import com.fengdu.gas.repository.BasicMapperImpl; |
| | | import com.fengdu.gas.repository.mapper.SysDictTypeMapper; |
| | | import com.fengdu.gas.repository.po.SysDictTypePO; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典类型表 |
| | | * @author lin.liu |
| | | * @description 字典类型表 |
| | | */ |
| | | @Repository |
| | | public class SysDictTypeMapperImpl extends BasicMapperImpl<SysDictTypePO, SysDictTypeMapper> { |
| | | SysDictTypeMapperImpl(SysDictTypeMapper mapper) { |
| | | super(mapper); |
| | | } |
| | | |
| | | @Override |
| | | public PagerResult<SysDictTypePO> search(SearchBasicDTO request) { |
| | | // 还原查询条件真实类型 |
| | | SearchSysDictType search = (SearchSysDictType)request; |
| | | // 查询条件 |
| | | LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); |
| | | // 状态 |
| | | queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, SysDictTypePO::getStatus, search.getStatus()); |
| | | // 状态列表 |
| | | queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), SysDictTypePO::getStatus, search.getListStatus()); |
| | | |
| | | // 数据创建时间-起始 |
| | | queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, SysDictTypePO::getCreateTime, search.getCreateTimeStart()); |
| | | // 数据创建时间-截止 |
| | | queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, SysDictTypePO::getCreateTime, search.getCreateTimeEnd()); |
| | | // 关键字 |
| | | if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { |
| | | queryWrapper.and(q -> |
| | | q.like(SysDictTypePO::getDictType, search.getKeywords()) |
| | | .or().like(SysDictTypePO::getDictName, search.getKeywords()) |
| | | ); |
| | | } |
| | | |
| | | // 排序处理 |
| | | if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { |
| | | for (OrderByDTO item : search.getOrderBy()) { |
| | | EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); |
| | | // 顺序排序 |
| | | if (item.getIsAsc()) { |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByAsc(SysDictTypePO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByAsc(SysDictTypePO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByAsc(SysDictTypePO::getUpdateTime); |
| | | break; |
| | | } |
| | | } else { |
| | | // 倒叙排序 |
| | | switch (orderBy) { |
| | | // 主键 |
| | | case ID: |
| | | queryWrapper.orderByDesc(SysDictTypePO::getId); |
| | | break; |
| | | // 数据创建时间 |
| | | case CREATE_TIME: |
| | | queryWrapper.orderByDesc(SysDictTypePO::getCreateTime); |
| | | break; |
| | | // 最后更新时间 |
| | | case UPDATE_TIME: |
| | | queryWrapper.orderByDesc(SysDictTypePO::getUpdateTime); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc(SysDictTypePO::getId); |
| | | } |
| | | Page<SysDictTypePO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper); |
| | | return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); |
| | | } |
| | | |
| | | public Boolean add(SysDictTypePO item) { |
| | | int rowCount = super.insert(item); |
| | | return rowCount == 1; |
| | | } |
| | | |
| | | public Boolean addNotIncrement(SysDictTypePO item) { |
| | | int rowCount = super.insert(item); |
| | | return rowCount == 1; |
| | | } |
| | | |
| | | public SysDictTypePO getById(Long id) { |
| | | return super.get(id); |
| | | } |
| | | |
| | | public List<SysDictTypePO> getListById(List<Long> listId) { |
| | | return super.getList(listId); |
| | | } |
| | | |
| | | public SysDictTypePO get4Type(String type) { |
| | | LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); |
| | | queryWrapper.eq(SysDictTypePO::getDictType, type); |
| | | return DB.selectOne(queryWrapper); |
| | | } |
| | | |
| | | public List<SysDictTypePO> get4Type(List<String> listType) { |
| | | LambdaQueryWrapper<SysDictTypePO> queryWrapper = this.query(); |
| | | queryWrapper.in(SysDictTypePO::getDictType, listType); |
| | | return DB.selectList(queryWrapper); |
| | | } |
| | | } |
src/main/java/com/fengdu/gas/repository/impl/TestInfoMapperImpl.java
src/main/java/com/fengdu/gas/repository/mapper/AdminMenuMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminMenusMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminPermissionMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminRoleMenuRelationMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminRolePermissionRelationMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminRoleRelationMapper.java
src/main/java/com/fengdu/gas/repository/mapper/AdminUserMapper.java
src/main/java/com/fengdu/gas/repository/mapper/NoticeMapper.java
src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskErrorMapper.java
src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskInfoMapper.java
src/main/java/com/fengdu/gas/repository/mapper/QuartzTaskRecordMapper.java
src/main/java/com/fengdu/gas/repository/mapper/SysDictDataMapper.java
src/main/java/com/fengdu/gas/repository/mapper/SysDictTypeMapper.java
src/main/java/com/fengdu/gas/repository/mapper/TestInfoMapper.java
src/main/java/com/fengdu/gas/repository/po/AdminMenuPO.java
src/main/java/com/fengdu/gas/repository/po/AdminMenusPO.java
src/main/java/com/fengdu/gas/repository/po/AdminPermissionPO.java
src/main/java/com/fengdu/gas/repository/po/AdminRoleMenuRelationPO.java
src/main/java/com/fengdu/gas/repository/po/AdminRolePO.java
src/main/java/com/fengdu/gas/repository/po/AdminRolePermissionRelationPO.java
src/main/java/com/fengdu/gas/repository/po/AdminRoleRelationPO.java
src/main/java/com/fengdu/gas/repository/po/AdminUserPO.java
src/main/java/com/fengdu/gas/repository/po/NoticePO.java
src/main/java/com/fengdu/gas/repository/po/QuartzTaskErrorPO.java
src/main/java/com/fengdu/gas/repository/po/QuartzTaskInfoPO.java
src/main/java/com/fengdu/gas/repository/po/QuartzTaskRecordPO.java
src/main/java/com/fengdu/gas/repository/po/SysDictDataPO.java
src/main/java/com/fengdu/gas/repository/po/SysDictTypePO.java
src/main/java/com/fengdu/gas/repository/po/TestInfoPO.java
src/main/java/com/fengdu/gas/repository/vo/AdminMenuVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminMenusVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminPermissionVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminRoleMenuRelationVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminRolePermissionRelationVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminRoleRelationVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminRoleVO.java
src/main/java/com/fengdu/gas/repository/vo/AdminUserVO.java
src/main/java/com/fengdu/gas/repository/vo/BasicVO.java
src/main/java/com/fengdu/gas/repository/vo/NoticeVO.java
src/main/java/com/fengdu/gas/repository/vo/QuartzTaskErrorVO.java
src/main/java/com/fengdu/gas/repository/vo/QuartzTaskInfoVO.java
src/main/java/com/fengdu/gas/repository/vo/QuartzTaskRecordVO.java
src/main/java/com/fengdu/gas/repository/vo/SysDictDataVO.java
src/main/java/com/fengdu/gas/repository/vo/SysDictTypeVO.java
src/main/java/com/fengdu/gas/repository/vo/TestInfoVO.java
src/main/java/com/fengdu/gas/service/AdminMenuService.java
src/main/java/com/fengdu/gas/service/AdminPermissionService.java
src/main/java/com/fengdu/gas/service/AdminPowerService.java
src/main/java/com/fengdu/gas/service/AdminService.java
src/main/java/com/fengdu/gas/service/BaseService.java
src/main/java/com/fengdu/gas/service/NoticeService.java
src/main/java/com/fengdu/gas/service/SysDictDataService.java
src/main/java/com/fengdu/gas/service/SysDictTypeService.java
src/main/java/com/fengdu/gas/service/TestInfoService.java
src/main/java/com/fengdu/gas/service/convert/AdminMenuConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminMenusConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminPermissionConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminRoleConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminRoleMenuRelationConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminRolePermissionRelationConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminRoleRelationConvert.java
src/main/java/com/fengdu/gas/service/convert/AdminUserConvert.java
src/main/java/com/fengdu/gas/service/convert/NoticeConvert.java
src/main/java/com/fengdu/gas/service/convert/QuartzTaskErrorConvert.java
src/main/java/com/fengdu/gas/service/convert/QuartzTaskInfoConvert.java
src/main/java/com/fengdu/gas/service/convert/QuartzTaskRecordConvert.java
src/main/java/com/fengdu/gas/service/convert/SysDictDataConvert.java
src/main/java/com/fengdu/gas/service/convert/SysDictTypeConvert.java
src/main/java/com/fengdu/gas/service/convert/TestInfoConvert.java
src/main/java/com/fengdu/gas/service/dto/NoticeDetail.java
src/main/java/com/fengdu/gas/service/dto/ResAdminDetail.java
src/main/java/com/fengdu/gas/service/quartz/QuartzExecutor.java
src/main/java/com/fengdu/gas/service/quartz/QuartzMainJobFactory.java
src/main/java/com/fengdu/gas/service/quartz/QuartzService.java
src/main/java/com/lunhan/xxx/common/ConstantFactory.java (已删除)
src/main/java/com/lunhan/xxx/common/ExecutedResult.java (已删除)
src/main/java/com/lunhan/xxx/common/PagerResult.java (已删除)
src/main/java/com/lunhan/xxx/common/PagerResultMore.java (已删除)
src/main/java/com/lunhan/xxx/common/ToBigDecimalFunction.java (已删除)
src/main/java/com/lunhan/xxx/common/cache/CacheManagerConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/cache/RedisKeySerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/config/FileConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/config/JWTConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/config/JdbcSetConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/config/RedisConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/config/SysConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/config/TokenConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EContentType.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EHorizontalLocation.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EHttpContentType.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/ELogger.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/ERequestTokenFrom.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EResultCode.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EVerticalLocation.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EYesOrNo.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/EnumBasic.java (已删除)
src/main/java/com/lunhan/xxx/common/enums/IErrorCode.java (已删除)
src/main/java/com/lunhan/xxx/common/exceptions/BusinessException.java (已删除)
src/main/java/com/lunhan/xxx/common/extend/CollectorsPlus.java (已删除)
src/main/java/com/lunhan/xxx/common/jackson/BigNumberSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/jackson/JacksonConfig.java (已删除)
src/main/java/com/lunhan/xxx/common/jwt/JWTUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/jwt/LoginUserDTO.java (已删除)
src/main/java/com/lunhan/xxx/common/model/ExcelDiscernCell.java (已删除)
src/main/java/com/lunhan/xxx/common/model/ExcelDiscernRow.java (已删除)
src/main/java/com/lunhan/xxx/common/model/ResFileUpload.java (已删除)
src/main/java/com/lunhan/xxx/common/model/Tuple.java (已删除)
src/main/java/com/lunhan/xxx/common/security/Base64Util.java (已删除)
src/main/java/com/lunhan/xxx/common/security/Des3Util.java (已删除)
src/main/java/com/lunhan/xxx/common/security/MD5Util.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/CQCalendarSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/CQDateSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/CQLocalDateTimeSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/CQTimestampSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQCalendarDeSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQDateDeSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateDeSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQLocalDateTimeDeSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/serializer/deserializer/CQTimestampDeSerializer.java (已删除)
src/main/java/com/lunhan/xxx/common/util/CalendarUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/CopierUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/EncryptionUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/ExceptionUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/FileUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/HttpUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/IPUtils.java (已删除)
src/main/java/com/lunhan/xxx/common/util/ListUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/LocalDateTimeUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/LoggerUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/MailUtils.java (已删除)
src/main/java/com/lunhan/xxx/common/util/MoneyUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/NumericUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/OrderUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/ParameterUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/PinYinUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/RandVerifyCode.java (已删除)
src/main/java/com/lunhan/xxx/common/util/SM2Util.java (已删除)
src/main/java/com/lunhan/xxx/common/util/SM4Util.java (已删除)
src/main/java/com/lunhan/xxx/common/util/SerializeUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/SnowFlake.java (已删除)
src/main/java/com/lunhan/xxx/common/util/SnowFlakeUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/SpringUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/StringUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/util/ThreadPoolUtil.java (已删除)
src/main/java/com/lunhan/xxx/common/validator/EParameterValidateType.java (已删除)
src/main/java/com/lunhan/xxx/common/validator/ParameterRunnable.java (已删除)
src/main/java/com/lunhan/xxx/common/validator/ParameterValidateItem.java (已删除)
src/main/java/com/lunhan/xxx/common/validator/ParameterValidateResult.java (已删除)
src/main/java/com/lunhan/xxx/common/validator/ParameterValidator.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/KeyValueDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/NameSortDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/NameSortIdDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/NameValueDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/OrderByDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/PagerBasicDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/RequestDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/SearchBasicDTO.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/UploadResultVo.java (已删除)
src/main/java/com/lunhan/xxx/entity/dto/UserInfoDto.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EDataChangeType.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EExecuteType.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EHandleStatus.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/ELockValue.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EMenuType.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EOperation.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EOrderBy.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EParameterType.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/ESex.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/ESortOrderBy.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EState.java (已删除)
src/main/java/com/lunhan/xxx/entity/enums/EUserType.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/AdminSendMail.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqChangePassword.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqListId.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqListSetSort.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqListStatus.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqNeedCode.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqNeedId.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqOperate.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqSetSort.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/ReqUserLogin.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqCreateAdminMenu.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminmenu/ReqModifyAdminMenu.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqCreateAdminMenus.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminmenus/ReqModifyAdminMenus.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqCreateAdminPermission.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminpermission/ReqModifyAdminPermission.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqCreateAdminRole.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrole/ReqModifyAdminRole.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqCreateAdminRoleMenuRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqModifyAdminRoleMenuRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListMenu4Role.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolemenurelation/ReqSetListRole4Admin.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqCreateAdminRolePermissionRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolepermissionrelation/ReqModifyAdminRolePermissionRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqCreateAdminRoleRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminrolerelation/ReqModifyAdminRoleRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqAdminLogin.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqCreateAdminUser.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqModifyAdminUser.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/adminuser/ReqSetListRole4Admin.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/notice/ReqCreateNotice.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/notice/ReqModifyNotice.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqCreateQuartzTaskError.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskerror/ReqModifyQuartzTaskError.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqCreateQuartzTaskInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqModifyQuartzTaskInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskinfo/ReqRunTaskRightNow.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqCreateQuartzTaskRecord.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/quartztaskrecord/ReqModifyQuartzTaskRecord.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqCreateSysDictData.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/sysdictdata/ReqModifySysDictData.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqCreateSysDictType.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/sysdicttype/ReqModifySysDictType.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/test/ReqCreateTestInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/test/ReqModifyTestInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqCreateTestInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/request/testinfo/ReqModifyTestInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/response/ResNameValue.java (已删除)
src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminLogin.java (已删除)
src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTree.java (已删除)
src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminMenuTreeAndPermission.java (已删除)
src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPermission.java (已删除)
src/main/java/com/lunhan/xxx/entity/response/admin/ResAdminPower.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenu.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminMenus.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminPermission.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminRole.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleMenuRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminRolePermissionRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminRoleRelation.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchAdminUser.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchNotice.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskError.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskInfo.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchQuartzTaskRecord.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchSysDictData.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchSysDictType.java (已删除)
src/main/java/com/lunhan/xxx/entity/search/SearchTestInfo.java (已删除)
src/main/java/com/lunhan/xxx/host/ApplicationStarter.java (已删除)
src/main/java/com/lunhan/xxx/host/BasicController.java (已删除)
src/main/java/com/lunhan/xxx/host/api/ApiRequestLogDTO.java (已删除)
src/main/java/com/lunhan/xxx/host/api/CorsFilterConfig.java (已删除)
src/main/java/com/lunhan/xxx/host/api/GlobalExceptionHandler.java (已删除)
src/main/java/com/lunhan/xxx/host/api/HttpRequestLogPool.java (已删除)
src/main/java/com/lunhan/xxx/host/api/MustAdmin.java (已删除)
src/main/java/com/lunhan/xxx/host/api/MvcTokenInterceptors.java (已删除)
src/main/java/com/lunhan/xxx/host/api/MyBatisPlusConfig.java (已删除)
src/main/java/com/lunhan/xxx/host/api/NonLogin.java (已删除)
src/main/java/com/lunhan/xxx/host/api/TokenFilter.java (已删除)
src/main/java/com/lunhan/xxx/host/api/WebLogAspect.java (已删除)
src/main/java/com/lunhan/xxx/host/api/WebMvcConfig.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/TestInfoServiceController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/admin/AdminMenuController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/admin/AdminPermissionController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/admin/AdminRoleController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/admin/AdminUserController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/base/BaseController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/base/FileController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/base/NoticeController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/base/QuartzController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/base/SysDictDataController.java (已删除)
src/main/java/com/lunhan/xxx/host/controller/base/SysDictTypeController.java (已删除)
src/main/java/com/lunhan/xxx/repository/BasicMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/BasicMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/bo/AdminUserBO.java (已删除)
src/main/java/com/lunhan/xxx/repository/bo/NoticeBO.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminMenuMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminMenusMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminPermissionMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminRoleMenuRelationMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminRolePermissionRelationMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminRoleRelationMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/AdminUserMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/NoticeMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskErrorMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskInfoMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/QuartzTaskRecordMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/SysDictDataMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/SysDictTypeMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/impl/TestInfoMapperImpl.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminMenuMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminMenusMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminPermissionMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleMenuRelationMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminRolePermissionRelationMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminRoleRelationMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/AdminUserMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/NoticeMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskErrorMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskInfoMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/QuartzTaskRecordMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/SysDictDataMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/SysDictTypeMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/mapper/TestInfoMapper.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminMenuPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminMenusPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminPermissionPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminRoleMenuRelationPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminRolePO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminRolePermissionRelationPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminRoleRelationPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/AdminUserPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/NoticePO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/QuartzTaskErrorPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/QuartzTaskInfoPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/QuartzTaskRecordPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/SysDictDataPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/SysDictTypePO.java (已删除)
src/main/java/com/lunhan/xxx/repository/po/TestInfoPO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminMenuVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminMenusVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminPermissionVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminRoleMenuRelationVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminRolePermissionRelationVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminRoleRelationVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminRoleVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/AdminUserVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/BasicVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/NoticeVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskErrorVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskInfoVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/QuartzTaskRecordVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/SysDictDataVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/SysDictTypeVO.java (已删除)
src/main/java/com/lunhan/xxx/repository/vo/TestInfoVO.java (已删除)
src/main/java/com/lunhan/xxx/service/AdminMenuService.java (已删除)
src/main/java/com/lunhan/xxx/service/AdminPermissionService.java (已删除)
src/main/java/com/lunhan/xxx/service/AdminPowerService.java (已删除)
src/main/java/com/lunhan/xxx/service/AdminService.java (已删除)
src/main/java/com/lunhan/xxx/service/BaseService.java (已删除)
src/main/java/com/lunhan/xxx/service/NoticeService.java (已删除)
src/main/java/com/lunhan/xxx/service/SysDictDataService.java (已删除)
src/main/java/com/lunhan/xxx/service/SysDictTypeService.java (已删除)
src/main/java/com/lunhan/xxx/service/TestInfoService.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminMenuConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminMenusConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminPermissionConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminRoleConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminRoleMenuRelationConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminRolePermissionRelationConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminRoleRelationConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/AdminUserConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/NoticeConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/QuartzTaskErrorConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/QuartzTaskInfoConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/QuartzTaskRecordConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/SysDictDataConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/SysDictTypeConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/convert/TestInfoConvert.java (已删除)
src/main/java/com/lunhan/xxx/service/dto/NoticeDetail.java (已删除)
src/main/java/com/lunhan/xxx/service/dto/ResAdminDetail.java (已删除)
src/main/java/com/lunhan/xxx/service/quartz/QuartzExecutor.java (已删除)
src/main/java/com/lunhan/xxx/service/quartz/QuartzMainJobFactory.java (已删除)
src/main/java/com/lunhan/xxx/service/quartz/QuartzService.java (已删除)
src/main/resources/application-dev.yml
src/main/resources/application-prod.yml
src/main/resources/application-test.yml
src/main/resources/application.yml
src/main/resources/smart-doc.json
src/test/java/com/lunhan/xxx/BasicServiceApplicationTests.java
src/test/java/com/lunhan/xxx/DateTimeTest.java
src/test/java/com/lunhan/xxx/DemoTest.java
src/test/java/com/lunhan/xxx/Gauss2Gauss.java
src/test/java/com/lunhan/xxx/GaussExportTest.java
src/test/java/com/lunhan/xxx/GenCodeGauss.java
src/test/java/com/lunhan/xxx/GenCodeMysql.java
src/test/java/com/lunhan/xxx/JenkinsTest.java
src/test/java/com/lunhan/xxx/MySqlExportTest.java
src/test/java/com/lunhan/xxx/Mysql2Gauss.java
src/test/java/com/lunhan/xxx/SpringConfig.java
src/test/java/com/lunhan/xxx/StringUtilTest.java
src/test/java/com/lunhan/xxx/po/UserPO.java
src/test/java/com/lunhan/xxx/repository/mapper/UserMapper.java
src/test/java/com/lunhan/xxx/repository/test123.java
src/test/resources/application-dev.yml
src/test/resources/application.yml |