feat: 更新了一下注释
更新了一下注释更新了一下注释
This commit is contained in:
@@ -9,9 +9,17 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/6
|
||||
* @date: 2022 /11/6
|
||||
* @description: 拷贝
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AosBeanUtils extends BeanUtils {
|
||||
@@ -19,12 +27,15 @@ public class AosBeanUtils extends BeanUtils {
|
||||
/**
|
||||
* list拷贝
|
||||
*
|
||||
* @param <S> parameter
|
||||
* @param <T> parameter
|
||||
* @param sources 源列表
|
||||
* @param target 拷贝到的目标列表类
|
||||
* @return java.util.List<T>
|
||||
* @Date 2021/8/16 0:11
|
||||
* @return java.util.List<T> list
|
||||
* @Date 2021 /8/16 0:11
|
||||
* @Author hz21056617
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <S, T> List<T> copyListProperties(List<S> sources, Supplier<T> target) {
|
||||
return copyListProperties(sources, target, null);
|
||||
@@ -33,13 +44,16 @@ public class AosBeanUtils extends BeanUtils {
|
||||
/**
|
||||
* list拷贝 可处理数据
|
||||
*
|
||||
* @param <S> parameter
|
||||
* @param <T> parameter
|
||||
* @param sources 源列表
|
||||
* @param target 拷贝到的目标列表类
|
||||
* @param callBack 数据处理方式
|
||||
* @return java.util.List<T>
|
||||
* @Date 2021/8/16 0:11
|
||||
* @return java.util.List<T> list
|
||||
* @Date 2021 /8/16 0:11
|
||||
* @Author hz21056617
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <S, T> List<T> copyListProperties(List<S> sources, Supplier<T> target, BiConsumer<S, T> callBack) {
|
||||
List<T> list = new ArrayList<>(sources.size());
|
||||
@@ -57,11 +71,14 @@ public class AosBeanUtils extends BeanUtils {
|
||||
/**
|
||||
* 对象拷贝
|
||||
*
|
||||
* @param sources
|
||||
* @param target
|
||||
* @return T
|
||||
* @Date 2022/11/6
|
||||
* @param <S> parameter
|
||||
* @param <T> parameter
|
||||
* @param sources sources
|
||||
* @param target target
|
||||
* @return T t
|
||||
* @Date 2022 /11/6
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <S, T> T copyProperties(S sources, Supplier<T> target) {
|
||||
T t = target.get();
|
||||
@@ -72,11 +89,15 @@ public class AosBeanUtils extends BeanUtils {
|
||||
/**
|
||||
* 对象拷贝
|
||||
*
|
||||
* @param sources
|
||||
* @param target
|
||||
* @return T
|
||||
* @Date 2022/11/6
|
||||
* @param <S> parameter
|
||||
* @param <T> parameter
|
||||
* @param sources sources
|
||||
* @param target target
|
||||
* @param callBack call back
|
||||
* @return T t
|
||||
* @Date 2022 /11/6
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <S, T> T copyProperties(S sources, Supplier<T> target, BiConsumer<S, T> callBack) {
|
||||
T t = target.get();
|
||||
@@ -90,11 +111,15 @@ public class AosBeanUtils extends BeanUtils {
|
||||
/**
|
||||
* 分页对象拷贝
|
||||
*
|
||||
* @param sources
|
||||
* @param target
|
||||
* @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<T>
|
||||
* @Date 2022/11/12
|
||||
* @param <S> parameter
|
||||
* @param <T> parameter
|
||||
* @param sources sources
|
||||
* @param target target
|
||||
* @param callBack call back
|
||||
* @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> page
|
||||
* @Date 2022 /11/12
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <S, T> Page<T> copyPageProperties(Page<S> sources, Supplier<T> target, BiConsumer<S, T> callBack) {
|
||||
Page<T> resultPage = new Page();
|
||||
@@ -105,6 +130,16 @@ public class AosBeanUtils extends BeanUtils {
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy page properties
|
||||
*
|
||||
* @param <S> parameter
|
||||
* @param <T> parameter
|
||||
* @param sources sources
|
||||
* @param target target
|
||||
* @return the page
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <S, T> Page<T> copyPageProperties(Page<S> sources, Supplier<T> target) {
|
||||
return copyPageProperties(sources, target, null);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
package com.aos.common.model;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/16
|
||||
* @date: 2022 /11/16
|
||||
* @description: 枚举基础接口
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface AosBaseEnum {
|
||||
/**
|
||||
* 获取枚举值
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.Integer
|
||||
* @Date 2022/11/16
|
||||
* @return java.lang.Integer value
|
||||
* @Date 2022 /11/16
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
Integer getValue();
|
||||
|
||||
@@ -20,9 +29,10 @@ public interface AosBaseEnum {
|
||||
* 获取枚举描述
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @Date 2022/11/16
|
||||
* @return java.lang.String desc
|
||||
* @Date 2022 /11/16
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
String getDesc();
|
||||
}
|
||||
|
||||
@@ -5,25 +5,34 @@ package com.aos.common.model;
|
||||
*
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: ResultCodeInterface
|
||||
* @Date: 2022/1/6 16:26
|
||||
* @Date: 2022 /1/6 16:26
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface ResultCodeInterface {
|
||||
/**
|
||||
* @return java.lang.String
|
||||
* Gets code *
|
||||
*
|
||||
* @return java.lang.String code
|
||||
* @Description 获取错误码
|
||||
* @Date 2020/11/8 15:37
|
||||
* @Date 2020 /11/8 15:37
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
String getCode();
|
||||
|
||||
/**
|
||||
* @return java.lang.String
|
||||
* Gets msg *
|
||||
*
|
||||
* @return java.lang.String msg
|
||||
* @Description 获取错误信息
|
||||
* @Date 2020/11/8 15:38
|
||||
* @Date 2020 /11/8 15:38
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
String getMsg();
|
||||
}
|
||||
|
||||
+18
-1
@@ -21,15 +21,26 @@ import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/3
|
||||
* @date: 2022 /11/3
|
||||
* @description: 用户信息上下文
|
||||
* @since 1.0
|
||||
*/
|
||||
public class CurrentUserContextHolder {
|
||||
/** userHolder */
|
||||
private static ThreadLocal<SecurityUserInfo> userHolder = new TransmittableThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void clearContext() {
|
||||
userHolder.remove();
|
||||
@@ -37,6 +48,9 @@ public class CurrentUserContextHolder {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @return the context
|
||||
* @since 1.0
|
||||
*/
|
||||
public static SecurityUserInfo getContext() {
|
||||
SecurityUserInfo securityUserInfo = userHolder.get();
|
||||
@@ -48,6 +62,9 @@ public class CurrentUserContextHolder {
|
||||
|
||||
/**
|
||||
* 设置
|
||||
*
|
||||
* @param context context
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void setContext(SecurityUserInfo context) {
|
||||
userHolder.set(context);
|
||||
|
||||
@@ -3,11 +3,17 @@ package com.aos.common.model.context;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: SecurityUserInfo
|
||||
* @Function: 认证的用户信息
|
||||
* @Date: 2019/12/17 21:24
|
||||
* @Date: 2019 /12/17 21:24
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class SecurityUserInfo {
|
||||
|
||||
@@ -8,12 +8,16 @@ import lombok.Data;
|
||||
*
|
||||
* @author wyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: BizException
|
||||
* @Date: 2020/4/12 20:13
|
||||
* @Date: 2020 /4/12 20:13
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class AosBaseBizException extends RuntimeException {
|
||||
|
||||
/** serialVersionUID */
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -21,34 +25,79 @@ public class AosBaseBizException extends RuntimeException {
|
||||
*/
|
||||
protected String errorCode;
|
||||
|
||||
/**
|
||||
* Aos base biz exception
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosBaseBizException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos base biz exception
|
||||
*
|
||||
* @param resultCode result code
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosBaseBizException(ResultCodeInterface resultCode) {
|
||||
super(resultCode.getMsg());
|
||||
this.errorCode = resultCode.getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos base biz exception
|
||||
*
|
||||
* @param resultCode result code
|
||||
* @param cause cause
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosBaseBizException(ResultCodeInterface resultCode, Throwable cause) {
|
||||
super(resultCode.getMsg(), cause);
|
||||
this.errorCode = resultCode.getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos base biz exception
|
||||
*
|
||||
* @param errorMsg error msg
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosBaseBizException(String errorMsg) {
|
||||
super(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos base biz exception
|
||||
*
|
||||
* @param errorCode error code
|
||||
* @param errorMsg error msg
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosBaseBizException(String errorCode, String errorMsg) {
|
||||
super(errorMsg);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos base biz exception
|
||||
*
|
||||
* @param errorCode error code
|
||||
* @param errorMsg error msg
|
||||
* @param cause cause
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosBaseBizException(String errorCode, String errorMsg, Throwable cause) {
|
||||
super(errorMsg, cause);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in stack trace
|
||||
*
|
||||
* @return the throwable
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
|
||||
@@ -3,29 +3,57 @@ package com.aos.common.model.result;
|
||||
import com.aos.common.model.ResultCodeInterface;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:07
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/13
|
||||
* @date: 2022 /11/13
|
||||
* @description: 基础返回结果
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum ResultCode implements ResultCodeInterface {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Succeed result code */
|
||||
SUCCEED("000000", "成功"),
|
||||
/** Failed result code */
|
||||
FAILED("000001", "系统异常");
|
||||
/** Code */
|
||||
private String code;
|
||||
/** Msg */
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* Result code
|
||||
*
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @since 1.0
|
||||
*/
|
||||
ResultCode(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets code *
|
||||
*
|
||||
* @return the code
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets msg *
|
||||
*
|
||||
* @return the msg
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
|
||||
@@ -3,50 +3,142 @@ package com.aos.common.model.result;
|
||||
import com.aos.common.model.ResultCodeInterface;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@SuppressWarnings("unchecked")
|
||||
public enum WebResponse {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Web response web response */
|
||||
WebResponse;
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult ok() {
|
||||
return new WebResult(ResultCode.SUCCEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param resultCode result code
|
||||
* @param data data
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult ok(ResultCodeInterface resultCode, T data) {
|
||||
return new WebResult(resultCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param data data
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult ok(T data) {
|
||||
return new WebResult(ResultCode.SUCCEED, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult error() {
|
||||
return new WebResult(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param data data
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult error(T data) {
|
||||
return new WebResult(ResultCode.FAILED, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param resultCode result code
|
||||
* @param data data
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult error(ResultCodeInterface resultCode, T data) {
|
||||
return new WebResult(resultCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param resultCode result code
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult error(ResultCodeInterface resultCode) {
|
||||
return new WebResult(resultCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> WebResult error(String code, String msg) {
|
||||
return new WebResult(code, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Web response
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @param data data
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
private <T> WebResult WebResponse(String code, String msg, T data) {
|
||||
return new WebResult(code, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Web response
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
private <T> WebResult WebResponse(String code, String msg) {
|
||||
return new WebResult(code, msg);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,18 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: WebResult
|
||||
* @Function: 返回对象
|
||||
* @Date: 2020/3/27 10:49
|
||||
* @Date: 2020 /3/27 10:49
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -27,24 +34,57 @@ public class WebResult<T> {
|
||||
*/
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* Web result
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public WebResult() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Web result
|
||||
*
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @param data data
|
||||
* @since 1.0
|
||||
*/
|
||||
public WebResult(String code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Web result
|
||||
*
|
||||
* @param resultCode result code
|
||||
* @since 1.0
|
||||
*/
|
||||
public WebResult(ResultCodeInterface resultCode) {
|
||||
this(resultCode, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Web result
|
||||
*
|
||||
* @param resultCode result code
|
||||
* @param data data
|
||||
* @since 1.0
|
||||
*/
|
||||
public WebResult(ResultCodeInterface resultCode, T data) {
|
||||
this(resultCode.getCode(), resultCode.getMsg(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Web result
|
||||
*
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @since 1.0
|
||||
*/
|
||||
public WebResult(String code, String msg) {
|
||||
this(code, msg, null);
|
||||
}
|
||||
|
||||
@@ -14,34 +14,74 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/12
|
||||
* @date: 2022 /11/12
|
||||
* @description: 请求工具类
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class RequestUtils {
|
||||
/**
|
||||
* Gets request *
|
||||
*
|
||||
* @return the request
|
||||
* @since 1.0
|
||||
*/
|
||||
public static HttpServletRequest getRequest() {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets response *
|
||||
*
|
||||
* @return the response
|
||||
* @since 1.0
|
||||
*/
|
||||
public static HttpServletResponse getResponse() {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
HttpServletResponse response = ((ServletRequestAttributes) requestAttributes).getResponse();
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value from request *
|
||||
*
|
||||
* @param key key
|
||||
* @return the value from request
|
||||
* @since 1.0
|
||||
*/
|
||||
public static String getValueFromRequest(String key) {
|
||||
HttpServletRequest request = getRequest();
|
||||
String value = getValue(request, key);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets cookie *
|
||||
*
|
||||
* @param key key
|
||||
* @return the cookie
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Cookie getCookie(String key) {
|
||||
return getCookie(getRequest(), key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean cookie
|
||||
*
|
||||
* @param key key
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void cleanCookie(String key) {
|
||||
HttpServletResponse response = getResponse();
|
||||
HttpServletRequest request = getRequest();
|
||||
@@ -56,6 +96,14 @@ public class RequestUtils {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value *
|
||||
*
|
||||
* @param request request
|
||||
* @param key key
|
||||
* @return the value
|
||||
* @since 1.0
|
||||
*/
|
||||
private static String getValue(HttpServletRequest request, String key) {
|
||||
String value = null;
|
||||
try {
|
||||
@@ -74,6 +122,14 @@ public class RequestUtils {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets cookie *
|
||||
*
|
||||
* @param request request
|
||||
* @param key key
|
||||
* @return the cookie
|
||||
* @since 1.0
|
||||
*/
|
||||
private static Cookie getCookie(HttpServletRequest request, String key) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (!Objects.isNull(cookies)) {
|
||||
|
||||
@@ -13,6 +13,10 @@ import java.util.function.Supplier;
|
||||
* 线程池工具
|
||||
*
|
||||
* @author luxiaolei
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AosThreadUtil {
|
||||
|
||||
@@ -25,7 +29,8 @@ public class AosThreadUtil {
|
||||
* </pre>
|
||||
*
|
||||
* @param corePoolSize 同时执行的线程数大小
|
||||
* @return ExecutorService
|
||||
* @return ExecutorService executor service
|
||||
* @since 1.0
|
||||
*/
|
||||
public static ExecutorService newExecutor(int corePoolSize) {
|
||||
ExecutorBuilder builder = ExecutorBuilder.create();
|
||||
@@ -44,7 +49,8 @@ public class AosThreadUtil {
|
||||
* 4. 任务直接提交给线程而不保持它们
|
||||
* </pre>
|
||||
*
|
||||
* @return ExecutorService
|
||||
* @return ExecutorService executor service
|
||||
* @since 1.0
|
||||
*/
|
||||
public static ExecutorService newExecutor() {
|
||||
return TtlExecutors.getTtlExecutorService(ExecutorBuilder.create().useSynchronousQueue().build());
|
||||
@@ -59,7 +65,8 @@ public class AosThreadUtil {
|
||||
* 4. 同时只允许一个线程工作,剩余放入队列等待,等待数超过1024报错
|
||||
* </pre>
|
||||
*
|
||||
* @return ExecutorService
|
||||
* @return ExecutorService executor service
|
||||
* @since 1.0
|
||||
*/
|
||||
public static ExecutorService newSingleExecutor() {
|
||||
return TtlExecutors.getTtlExecutorService(ExecutorBuilder.create()//
|
||||
@@ -76,6 +83,7 @@ public class AosThreadUtil {
|
||||
* @param corePoolSize 初始线程池大小
|
||||
* @param maximumPoolSize 最大线程池大小
|
||||
* @return {@link ThreadPoolExecutor}
|
||||
* @since 1.0
|
||||
*/
|
||||
public static ThreadPoolExecutor newExecutor(int corePoolSize, int maximumPoolSize) {
|
||||
return ExecutorBuilder.create()
|
||||
@@ -108,7 +116,8 @@ public class AosThreadUtil {
|
||||
* Blocking Coefficient(阻塞系数) = 阻塞时间/(阻塞时间+使用CPU的时间)<br>
|
||||
* 计算密集型任务的阻塞系数为0,而IO密集型任务的阻塞系数则接近于1。
|
||||
* <p>
|
||||
* see: <a href="http://blog.csdn.net/partner4java/article/details/9417663">http://blog.csdn.net/partner4java/article/details/9417663</a>
|
||||
* see:
|
||||
* <a href="http://blog.csdn.net/partner4java/article/details/9417663">http://blog.csdn.net/partner4java/article/details/9417663</a>
|
||||
*
|
||||
* @param blockingCoefficient 阻塞系数,阻塞因子介于0~1之间的数,阻塞因子越大,线程池中的线程数越多。
|
||||
* @return {@link ThreadPoolExecutor}
|
||||
@@ -135,7 +144,7 @@ public class AosThreadUtil {
|
||||
* @param nThreads 线程池大小
|
||||
* @param threadNamePrefix 线程名称前缀
|
||||
* @param isBlocked 是否使用{@link BlockPolicy}策略
|
||||
* @return ExecutorService
|
||||
* @return ExecutorService executor service
|
||||
* @author luozongle
|
||||
* @since 5.8.0
|
||||
*/
|
||||
@@ -155,7 +164,7 @@ public class AosThreadUtil {
|
||||
* @param maximumQueueSize 队列大小
|
||||
* @param threadNamePrefix 线程名称前缀
|
||||
* @param isBlocked 是否使用{@link BlockPolicy}策略
|
||||
* @return ExecutorService
|
||||
* @return ExecutorService executor service
|
||||
* @author luozongle
|
||||
* @since 5.8.0
|
||||
*/
|
||||
@@ -175,7 +184,7 @@ public class AosThreadUtil {
|
||||
* @param maximumQueueSize 队列大小
|
||||
* @param threadNamePrefix 线程名称前缀
|
||||
* @param handler 拒绝策略
|
||||
* @return ExecutorService
|
||||
* @return ExecutorService executor service
|
||||
* @author luozongle
|
||||
* @since 5.8.0
|
||||
*/
|
||||
@@ -195,6 +204,7 @@ public class AosThreadUtil {
|
||||
* 直接在公共线程池中执行线程
|
||||
*
|
||||
* @param runnable 可运行对象
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void execute(Runnable runnable) {
|
||||
GlobalThreadPool.execute(TtlRunnable.get(runnable));
|
||||
@@ -205,7 +215,8 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param runnable 需要执行的方法体
|
||||
* @param isDaemon 是否守护线程。守护线程会在主线程结束后自动结束
|
||||
* @return 执行的方法体
|
||||
* @return 执行的方法体 runnable
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Runnable execAsync(Runnable runnable, boolean isDaemon) {
|
||||
Thread thread = new Thread(TtlRunnable.get(runnable));
|
||||
@@ -220,7 +231,8 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param <T> 回调对象类型
|
||||
* @param task {@link Callable}
|
||||
* @return Future
|
||||
* @return Future future
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T> Future<T> execAsync(Callable<T> task) {
|
||||
return GlobalThreadPool.submit(TtlCallable.get(task));
|
||||
@@ -243,7 +255,8 @@ public class AosThreadUtil {
|
||||
* 若未完成,则会阻塞
|
||||
*
|
||||
* @param <T> 回调对象类型
|
||||
* @return CompletionService
|
||||
* @return CompletionService completion service
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T> CompletionService<T> newCompletionService() {
|
||||
return new ExecutorCompletionService<>(GlobalThreadPool.getExecutor());
|
||||
@@ -255,7 +268,8 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param <T> 回调对象类型
|
||||
* @param executor 执行器 {@link ExecutorService}
|
||||
* @return CompletionService
|
||||
* @return CompletionService completion service
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T> CompletionService<T> newCompletionService(ExecutorService executor) {
|
||||
return new ExecutorCompletionService<>(executor);
|
||||
@@ -265,7 +279,8 @@ public class AosThreadUtil {
|
||||
* 新建一个CountDownLatch,一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待。
|
||||
*
|
||||
* @param threadCount 线程数量
|
||||
* @return CountDownLatch
|
||||
* @return CountDownLatch count down latch
|
||||
* @since 1.0
|
||||
*/
|
||||
public static CountDownLatch newCountDownLatch(int threadCount) {
|
||||
return new CountDownLatch(threadCount);
|
||||
@@ -307,7 +322,8 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param timeout 挂起的时长
|
||||
* @param timeUnit 时长单位
|
||||
* @return 被中断返回false,否则true
|
||||
* @return 被中断返回false ,否则true
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean sleep(Number timeout, TimeUnit timeUnit) {
|
||||
try {
|
||||
@@ -322,7 +338,8 @@ public class AosThreadUtil {
|
||||
* 挂起当前线程
|
||||
*
|
||||
* @param millis 挂起的毫秒数
|
||||
* @return 被中断返回false,否则true
|
||||
* @return 被中断返回false ,否则true
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean sleep(Number millis) {
|
||||
if (millis == null) {
|
||||
@@ -335,7 +352,7 @@ public class AosThreadUtil {
|
||||
* 挂起当前线程
|
||||
*
|
||||
* @param millis 挂起的毫秒数
|
||||
* @return 被中断返回false,否则true
|
||||
* @return 被中断返回false ,否则true
|
||||
* @since 5.3.2
|
||||
*/
|
||||
public static boolean sleep(long millis) {
|
||||
@@ -353,8 +370,9 @@ public class AosThreadUtil {
|
||||
* 考虑{@link Thread#sleep(long)}方法有可能时间不足给定毫秒数,此方法保证sleep时间不小于给定的毫秒数
|
||||
*
|
||||
* @param millis 给定的sleep时间
|
||||
* @return 被中断返回false,否则true
|
||||
* @return 被中断返回false ,否则true
|
||||
* @see cn.hutool.core.thread.ThreadUtil#sleep(Number)
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean safeSleep(Number millis) {
|
||||
if (millis == null) {
|
||||
@@ -368,7 +386,7 @@ public class AosThreadUtil {
|
||||
* 考虑{@link Thread#sleep(long)}方法有可能时间不足给定毫秒数,此方法保证sleep时间不小于给定的毫秒数
|
||||
*
|
||||
* @param millis 给定的sleep时间
|
||||
* @return 被中断返回false,否则true
|
||||
* @return 被中断返回false ,否则true
|
||||
* @see cn.hutool.core.thread.ThreadUtil#sleep(Number)
|
||||
* @since 5.3.2
|
||||
*/
|
||||
@@ -392,7 +410,10 @@ public class AosThreadUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 获得堆栈列表
|
||||
* Get stack trace
|
||||
*
|
||||
* @return 获得堆栈列表 stack trace element [ ]
|
||||
* @since 1.0
|
||||
*/
|
||||
public static StackTraceElement[] getStackTrace() {
|
||||
return Thread.currentThread().getStackTrace();
|
||||
@@ -402,7 +423,8 @@ public class AosThreadUtil {
|
||||
* 获得堆栈项
|
||||
*
|
||||
* @param i 第几个堆栈项
|
||||
* @return 堆栈项
|
||||
* @return 堆栈项 stack trace element
|
||||
* @since 1.0
|
||||
*/
|
||||
public static StackTraceElement getStackTraceElement(int i) {
|
||||
StackTraceElement[] stackTrace = getStackTrace();
|
||||
@@ -417,7 +439,8 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param <T> 持有对象类型
|
||||
* @param isInheritable 是否为子线程提供从父线程那里继承的值
|
||||
* @return 本地线程
|
||||
* @return 本地线程 thread local
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T> ThreadLocal<T> createThreadLocal(boolean isInheritable) {
|
||||
if (isInheritable) {
|
||||
@@ -432,7 +455,7 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param <T> 持有对象类型
|
||||
* @param supplier 初始化线程对象函数
|
||||
* @return 本地线程
|
||||
* @return 本地线程 thread local
|
||||
* @see ThreadLocal#withInitial(Supplier)
|
||||
* @since 5.6.7
|
||||
*/
|
||||
@@ -443,7 +466,7 @@ public class AosThreadUtil {
|
||||
/**
|
||||
* 创建ThreadFactoryBuilder
|
||||
*
|
||||
* @return ThreadFactoryBuilder
|
||||
* @return ThreadFactoryBuilder thread factory builder
|
||||
* @see ThreadFactoryBuilder#build()
|
||||
* @since 4.1.13
|
||||
*/
|
||||
@@ -468,6 +491,7 @@ public class AosThreadUtil {
|
||||
*
|
||||
* @param thread 线程
|
||||
* @param isJoin 是否等待结束
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void interrupt(Thread thread, boolean isJoin) {
|
||||
if (null != thread && false == thread.isInterrupted()) {
|
||||
@@ -480,6 +504,8 @@ public class AosThreadUtil {
|
||||
|
||||
/**
|
||||
* 等待当前线程结束. 调用 {@link Thread#join()} 并忽略 {@link InterruptedException}
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void waitForDie() {
|
||||
waitForDie(Thread.currentThread());
|
||||
@@ -489,6 +515,7 @@ public class AosThreadUtil {
|
||||
* 等待线程结束. 调用 {@link Thread#join()} 并忽略 {@link InterruptedException}
|
||||
*
|
||||
* @param thread 线程
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void waitForDie(Thread thread) {
|
||||
if (null == thread) {
|
||||
@@ -509,7 +536,8 @@ public class AosThreadUtil {
|
||||
/**
|
||||
* 获取JVM中与当前线程同组的所有线程<br>
|
||||
*
|
||||
* @return 线程对象数组
|
||||
* @return 线程对象数组 thread [ ]
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Thread[] getThreads() {
|
||||
return getThreads(Thread.currentThread().getThreadGroup().getParent());
|
||||
@@ -521,7 +549,8 @@ public class AosThreadUtil {
|
||||
* from Voovan
|
||||
*
|
||||
* @param group 线程组
|
||||
* @return 线程对象数组
|
||||
* @return 线程对象数组 thread [ ]
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Thread[] getThreads(ThreadGroup group) {
|
||||
final Thread[] slackList = new Thread[group.activeCount() * 2];
|
||||
@@ -535,7 +564,8 @@ public class AosThreadUtil {
|
||||
* 获取进程的主线程<br>
|
||||
* from Voovan
|
||||
*
|
||||
* @return 进程的主线程
|
||||
* @return 进程的主线程 main thread
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Thread getMainThread() {
|
||||
for (Thread thread : getThreads()) {
|
||||
@@ -549,7 +579,7 @@ public class AosThreadUtil {
|
||||
/**
|
||||
* 获取当前线程的线程组
|
||||
*
|
||||
* @return 线程组
|
||||
* @return 线程组 thread group
|
||||
* @since 3.1.2
|
||||
*/
|
||||
public static ThreadGroup currentThreadGroup() {
|
||||
|
||||
@@ -17,11 +17,17 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author wyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: TokenUtilBase
|
||||
* @Function: 提供部分jwt 基础接口
|
||||
* @Date: 2019/12/17 0:36
|
||||
* @Date: 2019 /12/17 0:36
|
||||
* @since 1.0
|
||||
*/
|
||||
public class TokenUtilBase {
|
||||
|
||||
@@ -30,10 +36,12 @@ public class TokenUtilBase {
|
||||
*
|
||||
* @param claims 需要存储的信息
|
||||
* @param expireTime 设置token的超时时间
|
||||
* @return java.lang.String
|
||||
* @Date 2019/12/17 1:02
|
||||
* @param jwtSecret jwt secret
|
||||
* @return java.lang.String string
|
||||
* @Date 2019 /12/17 1:02
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static String generateToken(Map<String, Object> claims, Long expireTime, String jwtSecret) {
|
||||
Date expirationDate = generalExpirationDate(expireTime);
|
||||
@@ -47,10 +55,11 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 使用默认的密钥,默认超时时间 生成token
|
||||
*
|
||||
* @param claims
|
||||
* @return java.lang.String
|
||||
* @Date 2022/11/3
|
||||
* @param claims claims
|
||||
* @return java.lang.String string
|
||||
* @Date 2022 /11/3
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
public static String generateToken(Map<String, Object> claims) {
|
||||
return generateToken(claims, null, null);
|
||||
@@ -59,11 +68,12 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 使用默认的密钥,指定超时时间 生成token
|
||||
*
|
||||
* @param claims
|
||||
* @param expireTime
|
||||
* @return java.lang.String
|
||||
* @Date 2022/11/3
|
||||
* @param claims claims
|
||||
* @param expireTime expire time
|
||||
* @return java.lang.String string
|
||||
* @Date 2022 /11/3
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
public static String generateToken(Map<String, Object> claims, Long expireTime) {
|
||||
return generateToken(claims, expireTime, null);
|
||||
@@ -72,11 +82,13 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 使用默认的超时时间,指定密钥 生成token
|
||||
*
|
||||
* @param claims 需要存储的信息
|
||||
* @return java.lang.String
|
||||
* @Date 2019/12/17 20:38
|
||||
* @param claims 需要存储的信息
|
||||
* @param jwtSecret jwt secret
|
||||
* @return java.lang.String string
|
||||
* @Date 2019 /12/17 20:38
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static String generateToken(Map<String, Object> claims, String jwtSecret) {
|
||||
return generateToken(claims, null, jwtSecret);
|
||||
@@ -86,11 +98,13 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 从Token中获取Claims信息
|
||||
*
|
||||
* @param token
|
||||
* @return io.jsonwebtoken.Claims
|
||||
* @Date 2019/12/17 13:24
|
||||
* @param token token
|
||||
* @param jwtSecret jwt secret
|
||||
* @return io.jsonwebtoken.Claims claims from token
|
||||
* @Date 2019 /12/17 13:24
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Claims getClaimsFromToken(String token, String jwtSecret) {
|
||||
Claims claims = Jwts.parser()
|
||||
@@ -103,23 +117,28 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 从Token中获取Claims信息
|
||||
*
|
||||
* @param token
|
||||
* @return io.jsonwebtoken.Claims
|
||||
* @Date 2019/12/17 13:24
|
||||
* @param token token
|
||||
* @return io.jsonwebtoken.Claims claims from token
|
||||
* @Date 2019 /12/17 13:24
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static Claims getClaimsFromToken(String token) {
|
||||
return getClaimsFromToken(token, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param token
|
||||
* @return java.lang.Boolean
|
||||
* Token expired
|
||||
*
|
||||
* @param token token
|
||||
* @param jwtSecret jwt secret
|
||||
* @return java.lang.Boolean boolean
|
||||
* @Description 判断Token是否时效
|
||||
* @Date 2019/12/17 13:41
|
||||
* @Date 2019 /12/17 13:41
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public Boolean tokenExpired(String token, String jwtSecret) {
|
||||
Claims claims = getClaimsFromToken(token, jwtSecret);
|
||||
@@ -131,23 +150,27 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 判断Token是否时效
|
||||
*
|
||||
* @param token
|
||||
* @return java.lang.Boolean
|
||||
* @Date 2019/12/17 13:41
|
||||
* @param token token
|
||||
* @return java.lang.Boolean boolean
|
||||
* @Date 2019 /12/17 13:41
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public Boolean tokenExpired(String token) {
|
||||
return tokenExpired(token, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param
|
||||
* @return javax.crypto.SecretKey
|
||||
* General key
|
||||
*
|
||||
* @param jwtSecret jwt secret
|
||||
* @return javax.crypto.SecretKey secret key
|
||||
* @Description 通过Base64加密生成秘钥
|
||||
* @Date 2019/12/17 0:56
|
||||
* @Date 2019 /12/17 0:56
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
private static SecretKey generalKey(String jwtSecret) {
|
||||
if (Strings.isNullOrEmpty(jwtSecret)) {
|
||||
@@ -161,10 +184,11 @@ public class TokenUtilBase {
|
||||
/**
|
||||
* 生成超时时间
|
||||
*
|
||||
* @param expireTime
|
||||
* @return java.util.Date
|
||||
* @Date 2022/11/3
|
||||
* @param expireTime expire time
|
||||
* @return java.util.Date date
|
||||
* @Date 2022 /11/3
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
private static Date generalExpirationDate(Long expireTime) {
|
||||
if (Objects.isNull(expireTime) || Objects.equals(expireTime, 0L)) {
|
||||
@@ -175,6 +199,16 @@ public class TokenUtilBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
class TokenConstant {
|
||||
/**
|
||||
* 密钥
|
||||
|
||||
@@ -6,26 +6,51 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: TreeNode
|
||||
* @Function: 树节点
|
||||
* @Date: 2019/9/24 14:29
|
||||
* @Date: 2019 /9/24 14:29
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class TreeNode<T> {
|
||||
/** Id */
|
||||
protected Object id;
|
||||
/** Name */
|
||||
protected String name;
|
||||
/** Parent id */
|
||||
protected Object parentId;
|
||||
/** Children count */
|
||||
protected Integer childrenCount = 0;
|
||||
|
||||
/**
|
||||
* Tree node
|
||||
*
|
||||
* @param id id
|
||||
* @param parentId parent id
|
||||
* @since 1.0
|
||||
*/
|
||||
public TreeNode(Object id, Object parentId) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
/** Children */
|
||||
List<T> children = new ArrayList<T>();
|
||||
|
||||
/**
|
||||
* Add
|
||||
*
|
||||
* @param node node
|
||||
* @since 1.0
|
||||
*/
|
||||
public void add(T node) {
|
||||
children.add(node);
|
||||
this.childrenCount = this.childrenCount + 1;
|
||||
|
||||
@@ -6,21 +6,34 @@ import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @ClassName: TreeUtil
|
||||
* @Function: 建立树型结构
|
||||
* @Date: 2019/9/24 14:28
|
||||
* @Date: 2019 /9/24 14:28
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class TreeUtil<T extends TreeNode> {
|
||||
/**
|
||||
* Bulid
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param treeNodes tree nodes
|
||||
* @param root root
|
||||
* @return list
|
||||
* @Description 建立树
|
||||
* @Date 2019/9/24 14:33
|
||||
* @Date 2019 /9/24 14:33
|
||||
* @Param
|
||||
* @return
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T extends TreeNode> List<T> bulid(List<T> treeNodes, Object root) {
|
||||
List<T> trees = new ArrayList<T>();
|
||||
@@ -42,12 +55,18 @@ public class TreeUtil<T extends TreeNode> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build by recursive
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param treeNodes tree nodes
|
||||
* @param root root
|
||||
* @return list
|
||||
* @Description 递归建树
|
||||
* @Date 2019/9/24 14:34
|
||||
* @Date 2019 /9/24 14:34
|
||||
* @Param
|
||||
* @return
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T extends TreeNode> List<T> buildByRecursive(List<T> treeNodes, Object root) {
|
||||
List<T> trees = new ArrayList<T>();
|
||||
@@ -60,12 +79,18 @@ public class TreeUtil<T extends TreeNode> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find children
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param treeNode tree node
|
||||
* @param treeNodes tree nodes
|
||||
* @return t
|
||||
* @Description 递归查找子节点
|
||||
* @Date 2019/9/24 14:34
|
||||
* @Date 2019 /9/24 14:34
|
||||
* @Param
|
||||
* @return
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T extends TreeNode> T findChildren(T treeNode, List<T> treeNodes) {
|
||||
for (T it : treeNodes) {
|
||||
@@ -80,13 +105,17 @@ public class TreeUtil<T extends TreeNode> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 获取树的所有节点的值
|
||||
* @param treeNodes 树
|
||||
* Gets tree children ids *
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param treeNodes 树
|
||||
* @param resultIdList 返回所有节点的id列表
|
||||
* @return void
|
||||
* @Date 2020/3/30 16:23
|
||||
* @Description 获取树的所有节点的值
|
||||
* @Date 2020 /3/30 16:23
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public static <T extends TreeNode> void getTreeChildrenIds(List<T> treeNodes, List<Object> resultIdList) {
|
||||
for (T it : treeNodes){
|
||||
|
||||
@@ -8,42 +8,99 @@ import ch.qos.logback.core.spi.ContextAwareBase;
|
||||
import ch.qos.logback.core.spi.LifeCycle;
|
||||
import org.slf4j.AosLogLogbackTTLMdcAdapter;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AosLogbackTTLMdcListener extends ContextAwareBase implements LoggerContextListener, LifeCycle {
|
||||
/**
|
||||
* Start
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void start() {
|
||||
AosLogLogbackTTLMdcAdapter.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is started
|
||||
*
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is reset resistant
|
||||
*
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public boolean isResetResistant() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* On start
|
||||
*
|
||||
* @param loggerContext logger context
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void onStart(LoggerContext loggerContext) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* On reset
|
||||
*
|
||||
* @param loggerContext logger context
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void onReset(LoggerContext loggerContext) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* On stop
|
||||
*
|
||||
* @param loggerContext logger context
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void onStop(LoggerContext loggerContext) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* On level change
|
||||
*
|
||||
* @param logger logger
|
||||
* @param level level
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void onLevelChange(Logger logger, Level level) {
|
||||
|
||||
|
||||
@@ -10,12 +10,26 @@ import javax.servlet.ServletRequest;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/14
|
||||
* @date: 2022 /11/14
|
||||
* @description: log自动加载
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class AosLogAutoConfig {
|
||||
/**
|
||||
* Registry base filter
|
||||
*
|
||||
* @return the filter registration bean
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnClass(value = {FilterRegistrationBean.class, ServletRequest.class})
|
||||
public FilterRegistrationBean<AosRequestLogFilter> registryBaseFilter() {
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
package com.aos.log.constant;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/14
|
||||
* @date: 2022 /11/14
|
||||
* @description: 日志常量
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface LogConstant {
|
||||
/** TRACE_ID */
|
||||
String TRACE_ID = "traceId";
|
||||
}
|
||||
|
||||
@@ -11,13 +11,31 @@ import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/14
|
||||
* @date: 2022 /11/14
|
||||
* @description: Servlet日志拦截器, 添加traceId信息
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class AosRequestLogFilter implements Filter {
|
||||
|
||||
/**
|
||||
* Do filter
|
||||
*
|
||||
* @param request request
|
||||
* @param response response
|
||||
* @param chain chain
|
||||
* @throws ServletException servlet exception
|
||||
* @throws IOException io exception
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
|
||||
try {
|
||||
|
||||
@@ -8,19 +8,32 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/14
|
||||
* @date: 2022 /11/14
|
||||
* @description: 处理MDC 无法再多线种传递问题
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
|
||||
/** Copy on inherit thread local */
|
||||
final ThreadLocal<Map<String, String>> copyOnInheritThreadLocal = new TransmittableThreadLocal<>();
|
||||
|
||||
/** WRITE_OPERATION */
|
||||
private static final int WRITE_OPERATION = 1;
|
||||
/** READ_OPERATION */
|
||||
private static final int READ_OPERATION = 2;
|
||||
|
||||
/** mdcMDCAdapter */
|
||||
private static AosLogLogbackTTLMdcAdapter mdcMDCAdapter;
|
||||
|
||||
/** Last operation */
|
||||
// keeps track of the last operation performed
|
||||
final ThreadLocal<Integer> lastOperation = new ThreadLocal<>();
|
||||
|
||||
@@ -29,20 +42,47 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
MDC.mdcAdapter = mdcMDCAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets instance *
|
||||
*
|
||||
* @return the instance
|
||||
* @since 1.0
|
||||
*/
|
||||
public static MDCAdapter getInstance() {
|
||||
return mdcMDCAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets and set last operation *
|
||||
*
|
||||
* @param op op
|
||||
* @return the and set last operation
|
||||
* @since 1.0
|
||||
*/
|
||||
private Integer getAndSetLastOperation(int op) {
|
||||
Integer lastOp = lastOperation.get();
|
||||
lastOperation.set(op);
|
||||
return lastOp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Was last op read or null
|
||||
*
|
||||
* @param lastOp last op
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
private static boolean wasLastOpReadOrNull(Integer lastOp) {
|
||||
return lastOp == null || lastOp == READ_OPERATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate and insert new map
|
||||
*
|
||||
* @param oldMap old map
|
||||
* @return the map
|
||||
* @since 1.0
|
||||
*/
|
||||
private Map<String, String> duplicateAndInsertNewMap(Map<String, String> oldMap) {
|
||||
Map<String, String> newMap = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
if (oldMap != null) {
|
||||
@@ -57,6 +97,13 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
return newMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put
|
||||
*
|
||||
* @param key key
|
||||
* @param val val
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void put(String key, String val) {
|
||||
if (key == null) {
|
||||
@@ -74,6 +121,12 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove
|
||||
*
|
||||
* @param key key
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void remove(String key) {
|
||||
if (key == null) {
|
||||
@@ -96,12 +149,24 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
lastOperation.set(WRITE_OPERATION);
|
||||
copyOnInheritThreadLocal.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
*
|
||||
* @param key key
|
||||
* @return the string
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public String get(String key) {
|
||||
Map<String, String> map = getPropertyMap();
|
||||
@@ -112,12 +177,24 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets property map *
|
||||
*
|
||||
* @return the property map
|
||||
* @since 1.0
|
||||
*/
|
||||
public Map<String, String> getPropertyMap() {
|
||||
lastOperation.set(READ_OPERATION);
|
||||
return copyOnInheritThreadLocal.get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets copy of context map *
|
||||
*
|
||||
* @return the copy of context map
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Map getCopyOfContextMap() {
|
||||
lastOperation.set(READ_OPERATION);
|
||||
@@ -129,6 +206,12 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets context map *
|
||||
*
|
||||
* @param contextMap context map
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setContextMap(Map<String, String> contextMap) {
|
||||
|
||||
@@ -5,10 +5,26 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableSwagger(applicationName = "test", scanPackagesPath = "com.aos.test.web")
|
||||
@EnableConfigurationProperties
|
||||
public class Application {
|
||||
/**
|
||||
* Main
|
||||
*
|
||||
* @param args args
|
||||
* @since 1.0
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@@ -10,33 +10,36 @@ import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @TableName test
|
||||
* @since 1.0
|
||||
*/
|
||||
@TableName(value = "test_table")
|
||||
@Data
|
||||
@SensitiveData
|
||||
public class TestTable implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Id */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Delete time */
|
||||
@TableField(value = "delete_time")
|
||||
@TableLogic
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Text */
|
||||
@TableField(value = "text")
|
||||
@DecryptTransaction
|
||||
@EncryptTransaction
|
||||
private String text;
|
||||
|
||||
/** serialVersionUID */
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -5,10 +5,17 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author wyl
|
||||
* @description 针对表【test】的数据库操作Mapper
|
||||
* @createDate 2022-11-11 23:39:29
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @description 针对表 【test】的数据库操作Mapper
|
||||
* @createDate 2022 -11-11 23:39:29
|
||||
* @Entity mybatis.domain.Test
|
||||
* @since 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface TestMapper extends BaseMapper<TestTable> {
|
||||
|
||||
@@ -4,9 +4,16 @@ import com.aos.test.mybatis.domain.TestTable;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author wyl
|
||||
* @description 针对表【test】的数据库操作Service
|
||||
* @createDate 2022-11-11 23:39:29
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @description 针对表 【test】的数据库操作Service
|
||||
* @createDate 2022 -11-11 23:39:29
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface TestService extends IService<TestTable> {
|
||||
|
||||
|
||||
@@ -7,9 +7,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author wyl
|
||||
* @description 针对表【test】的数据库操作Service实现
|
||||
* @createDate 2022-11-11 23:39:29
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @description 针对表 【test】的数据库操作Service实现
|
||||
* @createDate 2022 -11-11 23:39:29
|
||||
* @since 1.0
|
||||
*/
|
||||
@Service
|
||||
public class TestServiceImpl extends ServiceImpl<TestMapper, TestTable>
|
||||
|
||||
@@ -13,13 +13,29 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
@Api(tags = "测试接口")
|
||||
@Slf4j
|
||||
public class TestController {
|
||||
/** Executor service */
|
||||
static ExecutorService executorService = ThreadUtil.newExecutor(3);
|
||||
|
||||
/**
|
||||
* Test 1
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@PostMapping("/test1")
|
||||
@ApiOperation(value = "test1")
|
||||
public void test1() {
|
||||
@@ -30,18 +46,36 @@ public class TestController {
|
||||
log.info("12");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 2
|
||||
*
|
||||
* @return the string
|
||||
* @since 1.0
|
||||
*/
|
||||
@PostMapping("/test2")
|
||||
@ApiOperation(value = "test2")
|
||||
public String test2() {
|
||||
return "2";
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 3
|
||||
*
|
||||
* @return the list
|
||||
* @since 1.0
|
||||
*/
|
||||
@PostMapping("/test3")
|
||||
@ApiOperation(value = "test3")
|
||||
public List<Long> test3() {
|
||||
return Arrays.asList(1L, 2L, 3L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 4
|
||||
*
|
||||
* @throws Exception exception
|
||||
* @since 1.0
|
||||
*/
|
||||
@PostMapping("/test4")
|
||||
@ApiOperation(value = "test4")
|
||||
public void test4() throws Exception {
|
||||
|
||||
@@ -7,11 +7,31 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(args = "--eureka.client.register-with-eureka=false", webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseTest.Application.class)
|
||||
public class BaseTest {
|
||||
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@ComponentScan(basePackages = {"com.aos.test"})
|
||||
@MapperScan(basePackages = {"com.aos.test.mybatis.mapper"})
|
||||
public static class Application {
|
||||
|
||||
@@ -10,10 +10,26 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class MybatisPlusTest extends BaseTest {
|
||||
/** Test service */
|
||||
@Autowired
|
||||
TestService testService;
|
||||
|
||||
/**
|
||||
* Add
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Test
|
||||
public void add() {
|
||||
TestTable test = new TestTable();
|
||||
@@ -21,11 +37,21 @@ public class MybatisPlusTest extends BaseTest {
|
||||
testService.save(test);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Test
|
||||
public void delete() {
|
||||
testService.removeById(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Test
|
||||
public void get() {
|
||||
LambdaUpdateWrapper<TestTable> testTableLambdaUpdateWrapper = Wrappers.lambdaUpdate(TestTable.class);
|
||||
@@ -34,6 +60,11 @@ public class MybatisPlusTest extends BaseTest {
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets page *
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
@Test
|
||||
public void getPage() {
|
||||
List<TestTable> list = testService.list();
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
package com.aos.mybatis.plus;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AESUtil {
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* com.oak.mybatisplus.interceptor -> 解密字段
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Component
|
||||
public class Decrypt {
|
||||
@@ -17,10 +23,11 @@ public class Decrypt {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param result resultType的实例
|
||||
* @param <T>
|
||||
* @return
|
||||
* @throws IllegalAccessException
|
||||
* @return t
|
||||
* @throws IllegalAccessException illegal access exception
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> T decrypt(T result) throws IllegalAccessException {
|
||||
//取出resultType的类
|
||||
|
||||
@@ -9,9 +9,29 @@ import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Component
|
||||
public class Encrypt {
|
||||
|
||||
/**
|
||||
* Encrypt
|
||||
*
|
||||
* @param <T> parameter
|
||||
* @param declaredFields declared fields
|
||||
* @param paramsObject params object
|
||||
* @return the t
|
||||
* @throws IllegalAccessException illegal access exception
|
||||
* @since 1.0
|
||||
*/
|
||||
public <T> T encrypt(Field[] declaredFields, T paramsObject) throws IllegalAccessException {
|
||||
for (Field field : declaredFields) {
|
||||
//取出所有被EncryptTransaction注解的字段
|
||||
|
||||
+10
@@ -2,6 +2,16 @@ package com.aos.mybatis.plus.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Documented
|
||||
@Inherited
|
||||
@Target({ElementType.FIELD})
|
||||
|
||||
@@ -4,6 +4,12 @@ import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Documented
|
||||
@Inherited
|
||||
|
||||
@@ -2,6 +2,16 @@ package com.aos.mybatis.plus.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Inherited
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -15,9 +15,17 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/7/26
|
||||
* @description: mybatis-plus配置
|
||||
* @date: 2022 /7/26
|
||||
* @description: mybatis -plus配置
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = "com.aos.mybatis.plus")
|
||||
@@ -26,10 +34,11 @@ public class MybatisPlusConf {
|
||||
/**
|
||||
* mybatis的SQL格式化和耗时打印
|
||||
*
|
||||
* @return com.aos.common.interceptor.MybatisSqlCompletePrintInterceptor
|
||||
* @Date 2022/1/12 23:44
|
||||
* @return com.aos.common.interceptor.MybatisSqlCompletePrintInterceptor mybatis sql complete print interceptor
|
||||
* @Date 2022 /1/12 23:44
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
MybatisSqlCompletePrintInterceptor mybatisSqlCompletePrintInterceptor() {
|
||||
@@ -39,10 +48,11 @@ public class MybatisPlusConf {
|
||||
/**
|
||||
* mybatis plus 分页插件加载 mysql
|
||||
*
|
||||
* @return com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
|
||||
* @Date 2022/1/12 23:44
|
||||
* @return com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor mybatis plus interceptor
|
||||
* @Date 2022 /1/12 23:44
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.class)
|
||||
@@ -66,10 +76,11 @@ public class MybatisPlusConf {
|
||||
/**
|
||||
* mybatis plus 逻辑删除配置
|
||||
*
|
||||
* @return com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer
|
||||
* @Date 2022/1/12 23:45
|
||||
* @return com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer mybatis plus properties customizer
|
||||
* @Date 2022 /1/12 23:45
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnClass(com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer.class)
|
||||
@@ -86,9 +97,10 @@ public class MybatisPlusConf {
|
||||
* aos默认字段填充
|
||||
*
|
||||
* @param
|
||||
* @return com.aos.mybatis.plus.handle.AosMetaObjectHandler
|
||||
* @Date 2022/11/12
|
||||
* @return com.aos.mybatis.plus.handle.AosMetaObjectHandler aos meta object handler
|
||||
* @Date 2022 /11/12
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean({AosMetaObjectHandler.class})
|
||||
@@ -96,9 +108,22 @@ public class MybatisPlusConf {
|
||||
return new AosMetaObjectHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class MybatisPlusConstant {
|
||||
/** DELETE */
|
||||
final static String DELETE = "delete_time";
|
||||
/** FALSE */
|
||||
final static String FALSE = "null";
|
||||
/** TRUE */
|
||||
final static String TRUE = "now()";
|
||||
}
|
||||
}
|
||||
|
||||
+44
-5
@@ -10,18 +10,29 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Component
|
||||
public class AosMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
/**
|
||||
* 有值也覆盖
|
||||
*
|
||||
* @param metaObject
|
||||
* @param fieldName
|
||||
* @param fieldVal
|
||||
* @return com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
|
||||
* @Date 2022/11/12
|
||||
* @param metaObject meta object
|
||||
* @param fieldName field name
|
||||
* @param fieldVal field val
|
||||
* @return com.baomidou.mybatisplus.core.handlers.MetaObjectHandler meta object handler
|
||||
* @Date 2022 /11/12
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public MetaObjectHandler strictFillStrategy(MetaObject metaObject, String fieldName, Supplier<?> fieldVal) {
|
||||
@@ -32,6 +43,12 @@ public class AosMetaObjectHandler implements MetaObjectHandler {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert fill
|
||||
*
|
||||
* @param metaObject meta object
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
SecurityUserInfo securityUserInfo = CurrentUserContextHolder.getContext();
|
||||
@@ -57,6 +74,12 @@ public class AosMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update fill
|
||||
*
|
||||
* @param metaObject meta object
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
SecurityUserInfo securityUserInfo = CurrentUserContextHolder.getContext();
|
||||
@@ -76,12 +99,28 @@ public class AosMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class MybatisPlusConstant {
|
||||
/** CREATE_USER_BY */
|
||||
public static final String CREATE_USER_BY = "createdBy";
|
||||
/** CREATE_USER_NAME */
|
||||
public static final String CREATE_USER_NAME = "createdName";
|
||||
/** CREATE_AT */
|
||||
public static final String CREATE_AT = "createdAt";
|
||||
/** UPDATE_USER_BY */
|
||||
public static final String UPDATE_USER_BY = "updatedBy";
|
||||
/** UPDATE_USER_NAME */
|
||||
public static final String UPDATE_USER_NAME = "updatedName";
|
||||
/** UPDATE_AT */
|
||||
public static final String UPDATE_AT = "updatedAt";
|
||||
}
|
||||
}
|
||||
|
||||
+49
-4
@@ -22,10 +22,21 @@ import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Intercepts({@Signature(type = StatementHandler.class, method = "query", args = {Statement.class, ResultHandler.class}), @Signature(type = StatementHandler.class, method = "update", args = {Statement.class}), @Signature(type = StatementHandler.class, method = "batch", args = {Statement.class})})
|
||||
@Slf4j
|
||||
public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered {
|
||||
|
||||
/** Configuration */
|
||||
private Configuration configuration = null;
|
||||
|
||||
/**
|
||||
@@ -33,6 +44,14 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
|
||||
*/
|
||||
private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT_THREAD_LOCAL = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
|
||||
/**
|
||||
* Intercept
|
||||
*
|
||||
* @param invocation invocation
|
||||
* @return the object
|
||||
* @throws Throwable throwable
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -53,9 +72,10 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
|
||||
/**
|
||||
* 获取sql
|
||||
*
|
||||
* @param target
|
||||
* @return
|
||||
* @param target target
|
||||
* @return sql
|
||||
* @throws IllegalAccessException
|
||||
* @since 1.0
|
||||
*/
|
||||
private String getSql(Object target) {
|
||||
try {
|
||||
@@ -75,11 +95,24 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin
|
||||
*
|
||||
* @param target target
|
||||
* @return the object
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets properties *
|
||||
*
|
||||
* @param properties properties
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
|
||||
@@ -88,8 +121,10 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
|
||||
/**
|
||||
* 获取完整的sql实体的信息
|
||||
*
|
||||
* @param boundSql
|
||||
* @return
|
||||
* @param boundSql bound sql
|
||||
* @param configuration configuration
|
||||
* @return string
|
||||
* @since 1.0
|
||||
*/
|
||||
private String formatSql(BoundSql boundSql, Configuration configuration) {
|
||||
String sql = boundSql.getSql();
|
||||
@@ -144,6 +179,10 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
|
||||
|
||||
/**
|
||||
* 美化Sql
|
||||
*
|
||||
* @param sql sql
|
||||
* @return the string
|
||||
* @since 1.0
|
||||
*/
|
||||
private String beautifySql(String sql) {
|
||||
sql = sql.replaceAll("[\\s\n ]+", " ");
|
||||
@@ -151,6 +190,12 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets order *
|
||||
*
|
||||
* @return the order
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
|
||||
+28
@@ -17,6 +17,12 @@ import java.util.Properties;
|
||||
|
||||
/**
|
||||
* com.oak.mybatisplus.interceptor -> sql查询参数加密
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -26,9 +32,18 @@ import java.util.Properties;
|
||||
public class ParameterInterceptor implements Interceptor {
|
||||
|
||||
|
||||
/** Encrypt */
|
||||
@Autowired
|
||||
Encrypt encrypt;
|
||||
|
||||
/**
|
||||
* Intercept
|
||||
*
|
||||
* @param invocation invocation
|
||||
* @return the object
|
||||
* @throws Throwable throwable
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
//@Signature 指定了 type= parameterHandler 后,这里的 invocation.getTarget() 便是parameterHandler
|
||||
@@ -52,11 +67,24 @@ public class ParameterInterceptor implements Interceptor {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin
|
||||
*
|
||||
* @param target target
|
||||
* @return the object
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets properties *
|
||||
*
|
||||
* @param properties properties
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
|
||||
|
||||
+35
-1
@@ -18,7 +18,12 @@ import java.util.Properties;
|
||||
/**
|
||||
* com.oak.mybatisplus.interceptor -> sql返回结果解密
|
||||
*
|
||||
* @Date: 2022/10/24
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @Date: 2022 /10/24
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -27,9 +32,18 @@ import java.util.Properties;
|
||||
})
|
||||
public class ResultSetInterceptor implements Interceptor {
|
||||
|
||||
/** Decrypt */
|
||||
@Autowired
|
||||
Decrypt decrypt;
|
||||
|
||||
/**
|
||||
* Intercept
|
||||
*
|
||||
* @param invocation invocation
|
||||
* @return the object
|
||||
* @throws Throwable throwable
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
//取出查询的结果
|
||||
@@ -56,6 +70,13 @@ public class ResultSetInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Need to decrypt
|
||||
*
|
||||
* @param object object
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
private boolean needToDecrypt(Object object) {
|
||||
Class<?> objectClass = object.getClass();
|
||||
SensitiveData sensitiveData = AnnotationUtils.findAnnotation(objectClass, SensitiveData.class);
|
||||
@@ -63,11 +84,24 @@ public class ResultSetInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plugin
|
||||
*
|
||||
* @param target target
|
||||
* @return the object
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets properties *
|
||||
*
|
||||
* @param properties properties
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
|
||||
|
||||
@@ -10,9 +10,17 @@ import lombok.Setter;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/10/31
|
||||
* @date: 2022 /10/31
|
||||
* @description: 数据表基础类
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
@@ -4,9 +4,17 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/7/26
|
||||
* @date: 2022 /7/26
|
||||
* @description: nacos配置
|
||||
* @since 1.0
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@Configuration
|
||||
|
||||
@@ -14,25 +14,59 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/6/25
|
||||
* @date: 2022 /6/25
|
||||
* @description:
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RobotAlarm {
|
||||
|
||||
/** Env */
|
||||
@Value("${spring.profiles.active}")
|
||||
private String env;
|
||||
/** Robot map */
|
||||
@Autowired
|
||||
Map<String, Robot> robotMap;
|
||||
|
||||
/**
|
||||
* Alarm
|
||||
*
|
||||
* @param robootName roboot name
|
||||
* @param message message
|
||||
* @param error error
|
||||
* @since 1.0
|
||||
*/
|
||||
public void alarm(String robootName, String message, Throwable error) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Alarm
|
||||
*
|
||||
* @param robootName roboot name
|
||||
* @param message message
|
||||
* @param value value
|
||||
* @since 1.0
|
||||
*/
|
||||
public void alarm(String robootName, String message, Object... value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Markdown
|
||||
*
|
||||
* @param robotName robot name
|
||||
* @param message message
|
||||
* @param value value
|
||||
* @since 1.0
|
||||
*/
|
||||
public void markdown(String robotName, String message, Object... value) {
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,21 @@ import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WxRobot extends AbstractRobot {
|
||||
|
||||
/** Rest template */
|
||||
@Resource(name = "robotRestTemplate")
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@@ -29,8 +40,9 @@ public class WxRobot extends AbstractRobot {
|
||||
* @param robotName 机器人名称
|
||||
* @param robotParam 机器人参数
|
||||
* @return void
|
||||
* @Date 2022/8/5
|
||||
* @Date 2022 /8/5
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
protected void sendMessage(String robotName, RobotPatam robotParam) {
|
||||
@@ -51,13 +63,14 @@ public class WxRobot extends AbstractRobot {
|
||||
/**
|
||||
* 普通信息
|
||||
*
|
||||
* @param robotName
|
||||
* @param messageTypeEnum
|
||||
* @param message
|
||||
* @param value
|
||||
* @param robotName robot name
|
||||
* @param messageTypeEnum message type enum
|
||||
* @param message message
|
||||
* @param value value
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void info(String robotName, MegTypeEnum messageTypeEnum, String message, Object... value) {
|
||||
@@ -67,13 +80,14 @@ public class WxRobot extends AbstractRobot {
|
||||
/**
|
||||
* 告警信息
|
||||
*
|
||||
* @param robotName
|
||||
* @param messageTypeEnum
|
||||
* @param message
|
||||
* @param value
|
||||
* @param robotName robot name
|
||||
* @param messageTypeEnum message type enum
|
||||
* @param message message
|
||||
* @param value value
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void warning(String robotName, MegTypeEnum messageTypeEnum, String message, Object... value) {
|
||||
@@ -83,19 +97,27 @@ public class WxRobot extends AbstractRobot {
|
||||
/**
|
||||
* 错误信息
|
||||
*
|
||||
* @param robotName
|
||||
* @param messageTypeEnum
|
||||
* @param message
|
||||
* @param error
|
||||
* @param robotName robot name
|
||||
* @param messageTypeEnum message type enum
|
||||
* @param message message
|
||||
* @param error error
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void error(String robotName, MegTypeEnum messageTypeEnum, String message, Throwable error) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make markdown message
|
||||
*
|
||||
* @param robotName robot name
|
||||
* @param message message
|
||||
* @since 1.0
|
||||
*/
|
||||
private void makeMarkdownMessage(String robotName, String message) {
|
||||
WxRobotParam robotParam = new WxRobotParam();
|
||||
robotParam.setMsgtype(MegTypeEnum.MARKDOWN);
|
||||
@@ -107,6 +129,13 @@ public class WxRobot extends AbstractRobot {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make text message
|
||||
*
|
||||
* @param robotName robot name
|
||||
* @param message message
|
||||
* @since 1.0
|
||||
*/
|
||||
private void makeTextMessage(String robotName, String message) {
|
||||
// message = "当前环境:" + env + "\n" + "当前时间:" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "\n" + message;
|
||||
WxRobotParam robotParam = new WxRobotParam();
|
||||
|
||||
@@ -11,10 +11,26 @@ import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {"com.aos.robot"})
|
||||
public class AutoRobotConfig {
|
||||
|
||||
/**
|
||||
* Rest template
|
||||
*
|
||||
* @return the rest template
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean("robotRestTemplate")
|
||||
public RestTemplate restTemplate() {
|
||||
RestTemplate restTemplate = new RestTemplate(getClientHttpRequestFactory());
|
||||
@@ -24,7 +40,8 @@ public class AutoRobotConfig {
|
||||
/**
|
||||
* 使用OkHttpClient作为底层客户端
|
||||
*
|
||||
* @return
|
||||
* @return client http request factory
|
||||
* @since 1.0
|
||||
*/
|
||||
private ClientHttpRequestFactory getClientHttpRequestFactory() {
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS)
|
||||
@@ -34,6 +51,12 @@ public class AutoRobotConfig {
|
||||
return new OkHttp3ClientHttpRequestFactory(okHttpClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read druid data source
|
||||
*
|
||||
* @return the robot config
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "aos")
|
||||
public RobotConfig readDruidDataSource() {
|
||||
|
||||
@@ -6,7 +6,18 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class RobotConfig {
|
||||
/** Robots */
|
||||
private Map<String, RobotInfo> robots = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -5,9 +5,17 @@ import lombok.Data;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/11
|
||||
* @date: 2022 /11/11
|
||||
* @description: 机器人基础配置
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class RobotInfo {
|
||||
@@ -24,6 +32,12 @@ public class RobotInfo {
|
||||
*/
|
||||
private RobotTypeEnum robotTypeEnum;
|
||||
|
||||
/**
|
||||
* Gets url *
|
||||
*
|
||||
* @return the url
|
||||
* @since 1.0
|
||||
*/
|
||||
public String getUrl() {
|
||||
if (StringUtils.isEmpty(url)) {
|
||||
return robotTypeEnum.getDefaultUrl();
|
||||
|
||||
@@ -8,19 +8,27 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: zouyang
|
||||
* @date: 2022/6/1
|
||||
* @date: 2022 /6/1
|
||||
* @description: 活动需求状态
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MegTypeEnum {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Text meg type enum */
|
||||
TEXT(0, "text"),
|
||||
/** Markdown meg type enum */
|
||||
MARKDOWN(1, "markdown"),
|
||||
;
|
||||
/** megTypeMAP */
|
||||
private static final Map<Integer, MegTypeEnum> megTypeMAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
|
||||
@@ -7,9 +7,17 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: zouyang
|
||||
* @date: 2022/6/1
|
||||
* @date: 2022 /6/1
|
||||
* @description: 活动需求状态
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@@ -23,6 +31,7 @@ public enum RobotTypeEnum {
|
||||
*/
|
||||
DingDing(1, "DingDing", ""),
|
||||
;
|
||||
/** RobotTypeMAP */
|
||||
private static final Map<Integer, RobotTypeEnum> RobotTypeMAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
|
||||
@@ -2,6 +2,16 @@ package com.aos.robot.model.base;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class RobotPatam {
|
||||
}
|
||||
|
||||
@@ -1,14 +1,40 @@
|
||||
package com.aos.robot.model.base;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/8/5
|
||||
* @date: 2022 /8/5
|
||||
* @description: 企业微信机器人返回信息
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface RobotRes {
|
||||
/**
|
||||
* Gets errcode *
|
||||
*
|
||||
* @return the errcode
|
||||
* @since 1.0
|
||||
*/
|
||||
String getErrcode();
|
||||
|
||||
/**
|
||||
* Gets errmsg *
|
||||
*
|
||||
* @return the errmsg
|
||||
* @since 1.0
|
||||
*/
|
||||
String getErrmsg();
|
||||
|
||||
/**
|
||||
* Succeed
|
||||
*
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
Boolean succeed();
|
||||
}
|
||||
|
||||
@@ -6,21 +6,58 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class WxRobotParam extends RobotPatam {
|
||||
/** Msgtype */
|
||||
MegTypeEnum msgtype = MegTypeEnum.TEXT;
|
||||
/** Text */
|
||||
Text text;
|
||||
/** Markdown */
|
||||
Markdown markdown;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public static class Text {
|
||||
/** Content */
|
||||
String content;
|
||||
/** Mentioned list */
|
||||
List<String> mentioned_list;
|
||||
/** Mentioned mobile list */
|
||||
List<String> mentioned_mobile_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public static class Markdown {
|
||||
/** Content */
|
||||
String content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,17 @@ import com.aos.robot.model.base.RobotRes;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/8/5
|
||||
* @date: 2022 /8/5
|
||||
* @description: 企业微信机器人返回信息
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class WxRobotRes implements RobotRes {
|
||||
@@ -23,9 +31,10 @@ public class WxRobotRes implements RobotRes {
|
||||
* 判断是否成功
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.Boolean
|
||||
* @Date 2022/8/5
|
||||
* @return java.lang.Boolean boolean
|
||||
* @Date 2022 /8/5
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Boolean succeed() {
|
||||
|
||||
@@ -12,18 +12,30 @@ import org.springframework.util.StringUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class AbstractRobot implements Robot {
|
||||
|
||||
/** Robot config */
|
||||
@Autowired
|
||||
protected RobotConfig robotConfig;
|
||||
|
||||
/**
|
||||
* 通过机器人名字 获取机器人配置
|
||||
*
|
||||
* @param robotName
|
||||
* @return com.aos.robot.conf.RobotInfo
|
||||
* @Date 2022/11/10
|
||||
* @param robotName robot name
|
||||
* @return com.aos.robot.conf.RobotInfo robot info
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
protected RobotInfo getRobotInfo(String robotName) {
|
||||
RobotInfo robotInfo = robotConfig.getRobots().get(robotName);
|
||||
@@ -36,10 +48,11 @@ public abstract class AbstractRobot implements Robot {
|
||||
/**
|
||||
* 组装错误堆栈信息
|
||||
*
|
||||
* @param error
|
||||
* @return java.lang.String
|
||||
* @Date 2022/11/11
|
||||
* @param error error
|
||||
* @return java.lang.String stack trace
|
||||
* @Date 2022 /11/11
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
protected String getStackTrace(Throwable error) {
|
||||
String stackTrace = ExceptionUtils.getStackTrace(error);
|
||||
@@ -51,15 +64,23 @@ public abstract class AbstractRobot implements Robot {
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param robotName
|
||||
* @param robotParam
|
||||
* @param robotName robot name
|
||||
* @param robotParam robot param
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
abstract protected void sendMessage(String robotName, RobotPatam robotParam);
|
||||
|
||||
|
||||
/**
|
||||
* Make markdown message
|
||||
*
|
||||
* @param robotName robot name
|
||||
* @param message message
|
||||
* @since 1.0
|
||||
*/
|
||||
private void makeMarkdownMessage(String robotName, String message) {
|
||||
WxRobotParam robotParam = new WxRobotParam();
|
||||
robotParam.setMsgtype(MegTypeEnum.MARKDOWN);
|
||||
@@ -71,6 +92,13 @@ public abstract class AbstractRobot implements Robot {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make text message
|
||||
*
|
||||
* @param robotName robot name
|
||||
* @param message message
|
||||
* @since 1.0
|
||||
*/
|
||||
private void makeTextMessage(String robotName, String message) {
|
||||
// message = "当前环境:" + env + "\n" + "当前时间:" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "\n" + message;
|
||||
WxRobotParam robotParam = new WxRobotParam();
|
||||
|
||||
@@ -3,44 +3,57 @@ package com.aos.robot.service;
|
||||
import com.aos.robot.model.MegTypeEnum;
|
||||
import com.aos.robot.model.base.RobotPatam;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Robot {
|
||||
|
||||
/**
|
||||
* 普通信息
|
||||
*
|
||||
* @param robotName
|
||||
* @param messageTypeEnum
|
||||
* @param message
|
||||
* @param value
|
||||
* @param robotName robot name
|
||||
* @param messageTypeEnum message type enum
|
||||
* @param message message
|
||||
* @param value value
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
void info(String robotName, MegTypeEnum messageTypeEnum, String message, Object... value);
|
||||
|
||||
/**
|
||||
* 告警信息
|
||||
*
|
||||
* @param robotName
|
||||
* @param messageTypeEnum
|
||||
* @param message
|
||||
* @param value
|
||||
* @param robotName robot name
|
||||
* @param messageTypeEnum message type enum
|
||||
* @param message message
|
||||
* @param value value
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
void warning(String robotName, MegTypeEnum messageTypeEnum, String message, Object... value);
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*
|
||||
* @param robotName
|
||||
* @param messageTypeEnum
|
||||
* @param message
|
||||
* @param error
|
||||
* @param robotName robot name
|
||||
* @param messageTypeEnum message type enum
|
||||
* @param message message
|
||||
* @param error error
|
||||
* @return void
|
||||
* @Date 2022/11/10
|
||||
* @Date 2022 /11/10
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
void error(String robotName, MegTypeEnum messageTypeEnum, String message, Throwable error);
|
||||
}
|
||||
|
||||
@@ -15,13 +15,28 @@ import springfox.documentation.spring.web.plugins.Docket;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: zeng li liang
|
||||
* @date: 2022/4/21
|
||||
* @date: 2022 /4/21
|
||||
* @description:
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SwaggerConfig implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
|
||||
/**
|
||||
* Register bean definitions
|
||||
*
|
||||
* @param annotationMetadata annotation metadata
|
||||
* @param beanDefinitionRegistry bean definition registry
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
|
||||
/**
|
||||
@@ -44,11 +59,12 @@ public class SwaggerConfig implements ImportBeanDefinitionRegistrar {
|
||||
/**
|
||||
* 审查个好难过swagger对象
|
||||
*
|
||||
* @param applicationName
|
||||
* @param packagePath
|
||||
* @return springfox.documentation.spring.web.plugins.Docket
|
||||
* @Date 2022/11/6
|
||||
* @param applicationName application name
|
||||
* @param packagePath package path
|
||||
* @return springfox.documentation.spring.web.plugins.Docket docket
|
||||
* @Date 2022 /11/6
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
private Docket createRestApi(String applicationName, String packagePath) {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
@@ -63,10 +79,11 @@ public class SwaggerConfig implements ImportBeanDefinitionRegistrar {
|
||||
/**
|
||||
* api描述西信息
|
||||
*
|
||||
* @param applicationName
|
||||
* @return springfox.documentation.service.ApiInfo
|
||||
* @Date 2022/11/6
|
||||
* @param applicationName application name
|
||||
* @return springfox.documentation.service.ApiInfo api info
|
||||
* @Date 2022 /11/6
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
private ApiInfo apiInfo(String applicationName) {
|
||||
return new ApiInfoBuilder()
|
||||
|
||||
@@ -10,9 +10,17 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/4
|
||||
* @date: 2022 /11/4
|
||||
* @description: 启动swagger的注解
|
||||
* @since 1.0
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -20,11 +28,17 @@ import java.lang.annotation.Target;
|
||||
public @interface EnableSwagger {
|
||||
/**
|
||||
* swagger显示的名称
|
||||
*
|
||||
* @return the string
|
||||
* @since 1.0
|
||||
*/
|
||||
String applicationName();
|
||||
|
||||
/**
|
||||
* 包扫描路径
|
||||
*
|
||||
* @return the string
|
||||
* @since 1.0
|
||||
*/
|
||||
String scanPackagesPath();
|
||||
}
|
||||
|
||||
@@ -9,14 +9,29 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/14
|
||||
* @date: 2022 /11/14
|
||||
* @description: 统一返回处理器
|
||||
* @since 1.0
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class ControllerErrorResponseAdvice {
|
||||
|
||||
/**
|
||||
* Handle exception
|
||||
*
|
||||
* @param ex ex
|
||||
* @return the web result
|
||||
* @since 1.0
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public WebResult<?> handleException(Exception ex) {
|
||||
|
||||
@@ -20,18 +20,32 @@ import springfox.documentation.swagger.web.ApiResourceController;
|
||||
import springfox.documentation.swagger2.web.Swagger2Controller;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/14
|
||||
* @date: 2022 /11/14
|
||||
* @description: 统一返回处理器
|
||||
* @since 1.0
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class ControllerResponseAdvice implements ResponseBodyAdvice<Object> {
|
||||
/** Object mapper */
|
||||
@Autowired
|
||||
ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* 返回true 才执行beforeBodyWrite
|
||||
*
|
||||
* @param methodParameter method parameter
|
||||
* @param converterType converter type
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
@@ -53,6 +67,18 @@ public class ControllerResponseAdvice implements ResponseBodyAdvice<Object> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Before body write
|
||||
*
|
||||
* @param data data
|
||||
* @param returnType return type
|
||||
* @param selectedContentType selected content type
|
||||
* @param selectedConverterType selected converter type
|
||||
* @param request request
|
||||
* @param response response
|
||||
* @return the object
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object data, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (returnType.getGenericParameterType().equals(String.class)) {
|
||||
|
||||
@@ -6,9 +6,17 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/13
|
||||
* @date: 2022 /11/13
|
||||
* @description: 标记不需要包装返回结果的方法
|
||||
* @since 1.0
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -12,15 +12,30 @@ import org.springframework.context.annotation.Configuration;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/7/26
|
||||
* @date: 2022 /7/26
|
||||
* @description: web自动加载
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(value = {FilterRegistrationBean.class, ServletRequest.class})
|
||||
@ComponentScan(basePackages = "com.aos.web")
|
||||
public class AosWebAutoConf {
|
||||
|
||||
/**
|
||||
* Register login check filter
|
||||
*
|
||||
* @param requireLoginFilter require login filter
|
||||
* @return the filter registration bean
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
public FilterRegistrationBean<BodyRepeatReaderHttpServletFilter> registerLoginCheckFilter(BodyRepeatReaderHttpServletFilter requireLoginFilter) {
|
||||
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
||||
@@ -31,11 +46,23 @@ public class AosWebAutoConf {
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Body repeat reader http servlet filter
|
||||
*
|
||||
* @return the body repeat reader http servlet filter
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean
|
||||
public BodyRepeatReaderHttpServletFilter bodyRepeatReaderHttpServletFilter() {
|
||||
return new BodyRepeatReaderHttpServletFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Customizer
|
||||
*
|
||||
* @return the jackson 2 object mapper builder customizer
|
||||
* @since 1.0
|
||||
*/
|
||||
@Bean("jackson2ObjectMapperBuilderCustomizer")
|
||||
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
||||
return new AosJacksonBuilderCustomizer();
|
||||
|
||||
@@ -3,27 +3,76 @@ package com.aos.web.exception;
|
||||
import com.aos.common.model.ResultCodeInterface;
|
||||
import com.aos.common.model.exception.AosBaseBizException;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AosWebBizException extends AosBaseBizException {
|
||||
/**
|
||||
* Aos web biz exception
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosWebBizException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos web biz exception
|
||||
*
|
||||
* @param resultCode result code
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosWebBizException(ResultCodeInterface resultCode) {
|
||||
super(resultCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos web biz exception
|
||||
*
|
||||
* @param resultCode result code
|
||||
* @param cause cause
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosWebBizException(ResultCodeInterface resultCode, Throwable cause) {
|
||||
super(resultCode, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos web biz exception
|
||||
*
|
||||
* @param errorMsg error msg
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosWebBizException(String errorMsg) {
|
||||
super(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos web biz exception
|
||||
*
|
||||
* @param errorCode error code
|
||||
* @param errorMsg error msg
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosWebBizException(String errorCode, String errorMsg) {
|
||||
super(errorCode, errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aos web biz exception
|
||||
*
|
||||
* @param errorCode error code
|
||||
* @param errorMsg error msg
|
||||
* @param cause cause
|
||||
* @since 1.0
|
||||
*/
|
||||
public AosWebBizException(String errorCode, String errorMsg, Throwable cause) {
|
||||
super(errorCode, errorMsg, cause);
|
||||
}
|
||||
|
||||
@@ -5,18 +5,26 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/13
|
||||
* @date: 2022 /11/13
|
||||
* @description: 基础返回结果
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WebResultCode implements ResultCodeInterface {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** Web conversion error web result code */
|
||||
WEB_CONVERSION_ERROR("010000", "String类型参数转化失败"),
|
||||
;
|
||||
/** Code */
|
||||
private String code;
|
||||
/** Msg */
|
||||
private String msg;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,27 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/7
|
||||
* @description: http包装器,解决流只能被消费一次问题
|
||||
* @date: 2022 /11/7
|
||||
* @description: http包装器 ,解决流只能被消费一次问题
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class BodyRepeatReaderHttpServletFilter implements Filter {
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @param filterConfig filter config
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {
|
||||
if (log.isDebugEnabled()) {
|
||||
@@ -21,6 +35,16 @@ public class BodyRepeatReaderHttpServletFilter implements Filter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do filter
|
||||
*
|
||||
* @param request request
|
||||
* @param response response
|
||||
* @param chain chain
|
||||
* @throws IOException io exception
|
||||
* @throws ServletException servlet exception
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
if (request instanceof HttpServletRequest) {
|
||||
|
||||
+28
-3
@@ -15,17 +15,34 @@ import java.util.List;
|
||||
* BodyReaderHttpServletRequestWrapper
|
||||
*
|
||||
* @author luoyongchun
|
||||
* @date 2019/07/02
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2019 /07/02
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BodyRepeatReaderHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
/** Body */
|
||||
protected String body;
|
||||
|
||||
/**
|
||||
* Body repeat reader http servlet request wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @throws IOException io exception
|
||||
* @since 1.0
|
||||
*/
|
||||
public BodyRepeatReaderHttpServletRequestWrapper(HttpServletRequest request) throws IOException {
|
||||
super(request);
|
||||
body = getBody(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets input stream *
|
||||
*
|
||||
* @return the input stream
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
||||
@@ -51,6 +68,12 @@ public class BodyRepeatReaderHttpServletRequestWrapper extends HttpServletReques
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets reader *
|
||||
*
|
||||
* @return the reader
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
return new BufferedReader(new InputStreamReader(this.getInputStream()));
|
||||
@@ -59,8 +82,10 @@ public class BodyRepeatReaderHttpServletRequestWrapper extends HttpServletReques
|
||||
/**
|
||||
* 获取body
|
||||
*
|
||||
* @param httpServletRequest
|
||||
* @return
|
||||
* @param httpServletRequest http servlet request
|
||||
* @return body
|
||||
* @throws IOException io exception
|
||||
* @since 1.0
|
||||
*/
|
||||
public static String getBody(HttpServletRequest httpServletRequest) throws IOException {
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
@@ -12,22 +12,32 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/6
|
||||
* @date: 2022 /11/6
|
||||
* @description: 请求参数打印拦截器
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class RequestInterceptor implements HandlerInterceptor, WebMvcConfigurer {
|
||||
|
||||
/** TRACE_ID */
|
||||
private final static String TRACE_ID = "trace.id";
|
||||
|
||||
/**
|
||||
* 放入拦截器
|
||||
*
|
||||
* @param registry
|
||||
* @param registry registry
|
||||
* @return void
|
||||
* @Date 2022/11/6
|
||||
* @Date 2022 /11/6
|
||||
* @Author wangyl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
@@ -35,6 +45,15 @@ public class RequestInterceptor implements HandlerInterceptor, WebMvcConfigurer
|
||||
WebMvcConfigurer.super.addInterceptors(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre handle
|
||||
*
|
||||
* @param httpServletRequest http servlet request
|
||||
* @param httpServletResponse http servlet response
|
||||
* @param o o
|
||||
* @return the boolean
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) {
|
||||
String tracId = httpServletRequest.getHeader(TRACE_ID);
|
||||
@@ -45,6 +64,15 @@ public class RequestInterceptor implements HandlerInterceptor, WebMvcConfigurer
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post handle
|
||||
*
|
||||
* @param httpServletRequest http servlet request
|
||||
* @param httpServletResponse http servlet response
|
||||
* @param o o
|
||||
* @param modelAndView model and view
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) {
|
||||
}
|
||||
|
||||
@@ -27,11 +27,22 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AosJacksonBuilderCustomizer implements Jackson2ObjectMapperBuilderCustomizer, Ordered {
|
||||
/**
|
||||
* Customize the JacksonObjectMapperBuilder.
|
||||
*
|
||||
* @param jacksonObjectMapperBuilder the JacksonObjectMapperBuilder to customize
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
|
||||
@@ -81,6 +92,7 @@ public class AosJacksonBuilderCustomizer implements Jackson2ObjectMapperBuilderC
|
||||
* @return the order value
|
||||
* @see #HIGHEST_PRECEDENCE
|
||||
* @see #LOWEST_PRECEDENCE
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public int getOrder() {
|
||||
|
||||
@@ -8,12 +8,29 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/16
|
||||
* @date: 2022 /11/16
|
||||
* @description: BigDecimal修改为String, 去除多余的0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BigDecimalSerializer extends JsonSerializer<BigDecimal> {
|
||||
|
||||
/**
|
||||
* Serialize
|
||||
*
|
||||
* @param bigDecimal big decimal
|
||||
* @param jsonGenerator json generator
|
||||
* @param serializerProvider serializer provider
|
||||
* @throws IOException io exception
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void serialize(BigDecimal bigDecimal, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
|
||||
jsonGenerator.writeString(bigDecimal.stripTrailingZeros().toPlainString());
|
||||
|
||||
@@ -7,11 +7,28 @@ import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>Company: 成都返空汇网络技术有限公司 </p>
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* @author yangjiyu
|
||||
* @version 1.0.0
|
||||
* @email "mailto:yangjiyu@fkhwl.com"
|
||||
* @date 2022.11.17 17:08
|
||||
* @author: wangyl
|
||||
* @date: 2022/11/16
|
||||
* @date: 2022 /11/16
|
||||
* @description: String去除多余的空格
|
||||
* @since 1.0
|
||||
*/
|
||||
public class StringSerializer extends StringDeserializer {
|
||||
/**
|
||||
* Deserialize
|
||||
*
|
||||
* @param p p
|
||||
* @param ctxt ctxt
|
||||
* @return the string
|
||||
* @throws IOException io exception
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||
String value = super.deserialize(p, ctxt);
|
||||
|
||||
Reference in New Issue
Block a user