Revert "feat: 更新了一下注释"

This reverts commit 8cc7ff7511.
This commit is contained in:
yangjiyu
2022-11-18 09:22:32 +08:00
parent 8cc7ff7511
commit 3320163963
67 changed files with 231 additions and 1785 deletions
@@ -9,17 +9,9 @@ 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 {
@@ -27,15 +19,12 @@ public class AosBeanUtils extends BeanUtils {
/**
* list拷贝
*
* @param <S> parameter
* @param <T> parameter
* @param sources 源列表
* @param target 拷贝到的目标列表类
* @return java.util.List<T> list
* @Date 2021 /8/16 0:11
* @return java.util.List<T>
* @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);
@@ -44,16 +33,13 @@ public class AosBeanUtils extends BeanUtils {
/**
* list拷贝 可处理数据
*
* @param <S> parameter
* @param <T> parameter
* @param sources 源列表
* @param target 拷贝到的目标列表类
* @param callBack 数据处理方式
* @return java.util.List<T> list
* @Date 2021 /8/16 0:11
* @return java.util.List<T>
* @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());
@@ -71,14 +57,11 @@ public class AosBeanUtils extends BeanUtils {
/**
* 对象拷贝
*
* @param <S> parameter
* @param <T> parameter
* @param sources sources
* @param target target
* @return T t
* @Date 2022 /11/6
* @param sources
* @param target
* @return 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();
@@ -89,15 +72,11 @@ public class AosBeanUtils extends BeanUtils {
/**
* 对象拷贝
*
* @param <S> parameter
* @param <T> parameter
* @param sources sources
* @param target target
* @param callBack call back
* @return T t
* @Date 2022 /11/6
* @param sources
* @param target
* @return 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();
@@ -111,15 +90,11 @@ public class AosBeanUtils extends BeanUtils {
/**
* 分页对象拷贝
*
* @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
* @param sources
* @param target
* @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<T>
* @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();
@@ -130,16 +105,6 @@ 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,27 +1,18 @@
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 value
* @Date 2022 /11/16
* @return java.lang.Integer
* @Date 2022/11/16
* @Author wangyl
* @since 1.0
*/
Integer getValue();
@@ -29,10 +20,9 @@ public interface AosBaseEnum {
* 获取枚举描述
*
* @param
* @return java.lang.String desc
* @Date 2022 /11/16
* @return java.lang.String
* @Date 2022/11/16
* @Author wangyl
* @since 1.0
*/
String getDesc();
}
@@ -5,34 +5,25 @@ 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
* @since 1.0
* @Date: 2022/1/6 16:26
*/
public interface ResultCodeInterface {
/**
* Gets code *
*
* @return java.lang.String code
* @return java.lang.String
* @Description 获取错误码
* @Date 2020 /11/8 15:37
* @Date 2020/11/8 15:37
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
String getCode();
/**
* Gets msg *
*
* @return java.lang.String msg
* @return java.lang.String
* @Description 获取错误信息
* @Date 2020 /11/8 15:38
* @Date 2020/11/8 15:38
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
String getMsg();
}
@@ -21,26 +21,15 @@ 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();
@@ -48,9 +37,6 @@ public class CurrentUserContextHolder {
/**
* 删除
*
* @return the context
* @since 1.0
*/
public static SecurityUserInfo getContext() {
SecurityUserInfo securityUserInfo = userHolder.get();
@@ -62,9 +48,6 @@ public class CurrentUserContextHolder {
/**
* 设置
*
* @param context context
* @since 1.0
*/
public static void setContext(SecurityUserInfo context) {
userHolder.set(context);
@@ -3,17 +3,11 @@ 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
* @since 1.0
* @Date: 2019/12/17 21:24
*/
@Data
public class SecurityUserInfo {
@@ -8,16 +8,12 @@ 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
* @since 1.0
* @Date: 2020/4/12 20:13
*/
@Data
public class AosBaseBizException extends RuntimeException {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
/**
@@ -25,79 +21,34 @@ 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,57 +3,29 @@ 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,143 +3,51 @@ 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,18 +5,11 @@ 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
* @since 1.0
* @Date: 2020/3/27 10:49
*/
@Getter
@Setter
@@ -34,57 +27,24 @@ 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,74 +14,34 @@ 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();
@@ -96,14 +56,6 @@ 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 {
@@ -122,14 +74,6 @@ 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,10 +13,6 @@ 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 {
@@ -29,8 +25,7 @@ public class AosThreadUtil {
* </pre>
*
* @param corePoolSize 同时执行的线程数大小
* @return ExecutorService executor service
* @since 1.0
* @return ExecutorService
*/
public static ExecutorService newExecutor(int corePoolSize) {
ExecutorBuilder builder = ExecutorBuilder.create();
@@ -49,8 +44,7 @@ public class AosThreadUtil {
* 4. 任务直接提交给线程而不保持它们
* </pre>
*
* @return ExecutorService executor service
* @since 1.0
* @return ExecutorService
*/
public static ExecutorService newExecutor() {
return TtlExecutors.getTtlExecutorService(ExecutorBuilder.create().useSynchronousQueue().build());
@@ -65,8 +59,7 @@ public class AosThreadUtil {
* 4. 同时只允许一个线程工作,剩余放入队列等待,等待数超过1024报错
* </pre>
*
* @return ExecutorService executor service
* @since 1.0
* @return ExecutorService
*/
public static ExecutorService newSingleExecutor() {
return TtlExecutors.getTtlExecutorService(ExecutorBuilder.create()//
@@ -83,7 +76,6 @@ public class AosThreadUtil {
* @param corePoolSize 初始线程池大小
* @param maximumPoolSize 最大线程池大小
* @return {@link ThreadPoolExecutor}
* @since 1.0
*/
public static ThreadPoolExecutor newExecutor(int corePoolSize, int maximumPoolSize) {
return ExecutorBuilder.create()
@@ -116,8 +108,7 @@ 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}
@@ -144,7 +135,7 @@ public class AosThreadUtil {
* @param nThreads 线程池大小
* @param threadNamePrefix 线程名称前缀
* @param isBlocked 是否使用{@link BlockPolicy}策略
* @return ExecutorService executor service
* @return ExecutorService
* @author luozongle
* @since 5.8.0
*/
@@ -164,7 +155,7 @@ public class AosThreadUtil {
* @param maximumQueueSize 队列大小
* @param threadNamePrefix 线程名称前缀
* @param isBlocked 是否使用{@link BlockPolicy}策略
* @return ExecutorService executor service
* @return ExecutorService
* @author luozongle
* @since 5.8.0
*/
@@ -184,7 +175,7 @@ public class AosThreadUtil {
* @param maximumQueueSize 队列大小
* @param threadNamePrefix 线程名称前缀
* @param handler 拒绝策略
* @return ExecutorService executor service
* @return ExecutorService
* @author luozongle
* @since 5.8.0
*/
@@ -204,7 +195,6 @@ public class AosThreadUtil {
* 直接在公共线程池中执行线程
*
* @param runnable 可运行对象
* @since 1.0
*/
public static void execute(Runnable runnable) {
GlobalThreadPool.execute(TtlRunnable.get(runnable));
@@ -215,8 +205,7 @@ public class AosThreadUtil {
*
* @param runnable 需要执行的方法体
* @param isDaemon 是否守护线程。守护线程会在主线程结束后自动结束
* @return 执行的方法体 runnable
* @since 1.0
* @return 执行的方法体
*/
public static Runnable execAsync(Runnable runnable, boolean isDaemon) {
Thread thread = new Thread(TtlRunnable.get(runnable));
@@ -231,8 +220,7 @@ public class AosThreadUtil {
*
* @param <T> 回调对象类型
* @param task {@link Callable}
* @return Future future
* @since 1.0
* @return Future
*/
public static <T> Future<T> execAsync(Callable<T> task) {
return GlobalThreadPool.submit(TtlCallable.get(task));
@@ -255,8 +243,7 @@ public class AosThreadUtil {
* 若未完成,则会阻塞
*
* @param <T> 回调对象类型
* @return CompletionService completion service
* @since 1.0
* @return CompletionService
*/
public static <T> CompletionService<T> newCompletionService() {
return new ExecutorCompletionService<>(GlobalThreadPool.getExecutor());
@@ -268,8 +255,7 @@ public class AosThreadUtil {
*
* @param <T> 回调对象类型
* @param executor 执行器 {@link ExecutorService}
* @return CompletionService completion service
* @since 1.0
* @return CompletionService
*/
public static <T> CompletionService<T> newCompletionService(ExecutorService executor) {
return new ExecutorCompletionService<>(executor);
@@ -279,8 +265,7 @@ public class AosThreadUtil {
* 新建一个CountDownLatch,一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待。
*
* @param threadCount 线程数量
* @return CountDownLatch count down latch
* @since 1.0
* @return CountDownLatch
*/
public static CountDownLatch newCountDownLatch(int threadCount) {
return new CountDownLatch(threadCount);
@@ -322,8 +307,7 @@ public class AosThreadUtil {
*
* @param timeout 挂起的时长
* @param timeUnit 时长单位
* @return 被中断返回false ,否则true
* @since 1.0
* @return 被中断返回false,否则true
*/
public static boolean sleep(Number timeout, TimeUnit timeUnit) {
try {
@@ -338,8 +322,7 @@ public class AosThreadUtil {
* 挂起当前线程
*
* @param millis 挂起的毫秒数
* @return 被中断返回false ,否则true
* @since 1.0
* @return 被中断返回false,否则true
*/
public static boolean sleep(Number millis) {
if (millis == null) {
@@ -352,7 +335,7 @@ public class AosThreadUtil {
* 挂起当前线程
*
* @param millis 挂起的毫秒数
* @return 被中断返回false ,否则true
* @return 被中断返回false,否则true
* @since 5.3.2
*/
public static boolean sleep(long millis) {
@@ -370,9 +353,8 @@ 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) {
@@ -386,7 +368,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
*/
@@ -410,10 +392,7 @@ public class AosThreadUtil {
}
/**
* Get stack trace
*
* @return 获得堆栈列表 stack trace element [ ]
* @since 1.0
* @return 获得堆栈列表
*/
public static StackTraceElement[] getStackTrace() {
return Thread.currentThread().getStackTrace();
@@ -423,8 +402,7 @@ public class AosThreadUtil {
* 获得堆栈项
*
* @param i 第几个堆栈项
* @return 堆栈项 stack trace element
* @since 1.0
* @return 堆栈项
*/
public static StackTraceElement getStackTraceElement(int i) {
StackTraceElement[] stackTrace = getStackTrace();
@@ -439,8 +417,7 @@ public class AosThreadUtil {
*
* @param <T> 持有对象类型
* @param isInheritable 是否为子线程提供从父线程那里继承的值
* @return 本地线程 thread local
* @since 1.0
* @return 本地线程
*/
public static <T> ThreadLocal<T> createThreadLocal(boolean isInheritable) {
if (isInheritable) {
@@ -455,7 +432,7 @@ public class AosThreadUtil {
*
* @param <T> 持有对象类型
* @param supplier 初始化线程对象函数
* @return 本地线程 thread local
* @return 本地线程
* @see ThreadLocal#withInitial(Supplier)
* @since 5.6.7
*/
@@ -466,7 +443,7 @@ public class AosThreadUtil {
/**
* 创建ThreadFactoryBuilder
*
* @return ThreadFactoryBuilder thread factory builder
* @return ThreadFactoryBuilder
* @see ThreadFactoryBuilder#build()
* @since 4.1.13
*/
@@ -491,7 +468,6 @@ public class AosThreadUtil {
*
* @param thread 线程
* @param isJoin 是否等待结束
* @since 1.0
*/
public static void interrupt(Thread thread, boolean isJoin) {
if (null != thread && false == thread.isInterrupted()) {
@@ -504,8 +480,6 @@ public class AosThreadUtil {
/**
* 等待当前线程结束. 调用 {@link Thread#join()} 并忽略 {@link InterruptedException}
*
* @since 1.0
*/
public static void waitForDie() {
waitForDie(Thread.currentThread());
@@ -515,7 +489,6 @@ public class AosThreadUtil {
* 等待线程结束. 调用 {@link Thread#join()} 并忽略 {@link InterruptedException}
*
* @param thread 线程
* @since 1.0
*/
public static void waitForDie(Thread thread) {
if (null == thread) {
@@ -536,8 +509,7 @@ public class AosThreadUtil {
/**
* 获取JVM中与当前线程同组的所有线程<br>
*
* @return 线程对象数组 thread [ ]
* @since 1.0
* @return 线程对象数组
*/
public static Thread[] getThreads() {
return getThreads(Thread.currentThread().getThreadGroup().getParent());
@@ -549,8 +521,7 @@ public class AosThreadUtil {
* from Voovan
*
* @param group 线程组
* @return 线程对象数组 thread [ ]
* @since 1.0
* @return 线程对象数组
*/
public static Thread[] getThreads(ThreadGroup group) {
final Thread[] slackList = new Thread[group.activeCount() * 2];
@@ -564,8 +535,7 @@ public class AosThreadUtil {
* 获取进程的主线程<br>
* from Voovan
*
* @return 进程的主线程 main thread
* @since 1.0
* @return 进程的主线程
*/
public static Thread getMainThread() {
for (Thread thread : getThreads()) {
@@ -579,7 +549,7 @@ public class AosThreadUtil {
/**
* 获取当前线程的线程组
*
* @return 线程组 thread group
* @return 线程组
* @since 3.1.2
*/
public static ThreadGroup currentThreadGroup() {
@@ -17,17 +17,11 @@ 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
* @since 1.0
* @Date: 2019/12/17 0:36
*/
public class TokenUtilBase {
@@ -36,12 +30,10 @@ public class TokenUtilBase {
*
* @param claims 需要存储的信息
* @param expireTime 设置token的超时时间
* @param jwtSecret jwt secret
* @return java.lang.String string
* @Date 2019 /12/17 1:02
* @return java.lang.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);
@@ -55,11 +47,10 @@ public class TokenUtilBase {
/**
* 使用默认的密钥,默认超时时间 生成token
*
* @param claims claims
* @return java.lang.String string
* @Date 2022 /11/3
* @param claims
* @return java.lang.String
* @Date 2022/11/3
* @Author wangyl
* @since 1.0
*/
public static String generateToken(Map<String, Object> claims) {
return generateToken(claims, null, null);
@@ -68,12 +59,11 @@ public class TokenUtilBase {
/**
* 使用默认的密钥,指定超时时间 生成token
*
* @param claims claims
* @param expireTime expire time
* @return java.lang.String string
* @Date 2022 /11/3
* @param claims
* @param expireTime
* @return java.lang.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);
@@ -82,13 +72,11 @@ public class TokenUtilBase {
/**
* 使用默认的超时时间,指定密钥 生成token
*
* @param claims 需要存储的信息
* @param jwtSecret jwt secret
* @return java.lang.String string
* @Date 2019 /12/17 20:38
* @param claims 需要存储的信息
* @return java.lang.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);
@@ -98,13 +86,11 @@ public class TokenUtilBase {
/**
* 从Token中获取Claims信息
*
* @param token token
* @param jwtSecret jwt secret
* @return io.jsonwebtoken.Claims claims from token
* @Date 2019 /12/17 13:24
* @param token
* @return io.jsonwebtoken.Claims
* @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()
@@ -117,28 +103,23 @@ public class TokenUtilBase {
/**
* 从Token中获取Claims信息
*
* @param token token
* @return io.jsonwebtoken.Claims claims from token
* @Date 2019 /12/17 13:24
* @param token
* @return io.jsonwebtoken.Claims
* @Date 2019/12/17 13:24
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
public static Claims getClaimsFromToken(String token) {
return getClaimsFromToken(token, null);
}
/**
* Token expired
*
* @param token token
* @param jwtSecret jwt secret
* @return java.lang.Boolean boolean
* @param token
* @return java.lang.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);
@@ -150,27 +131,23 @@ public class TokenUtilBase {
/**
* 判断Token是否时效
*
* @param token token
* @return java.lang.Boolean boolean
* @Date 2019 /12/17 13:41
* @param token
* @return java.lang.Boolean
* @Date 2019/12/17 13:41
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
public Boolean tokenExpired(String token) {
return tokenExpired(token, null);
}
/**
* General key
*
* @param jwtSecret jwt secret
* @return javax.crypto.SecretKey secret key
* @param
* @return javax.crypto.SecretKey
* @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)) {
@@ -184,11 +161,10 @@ public class TokenUtilBase {
/**
* 生成超时时间
*
* @param expireTime expire time
* @return java.util.Date date
* @Date 2022 /11/3
* @param expireTime
* @return java.util.Date
* @Date 2022/11/3
* @Author wangyl
* @since 1.0
*/
private static Date generalExpirationDate(Long expireTime) {
if (Objects.isNull(expireTime) || Objects.equals(expireTime, 0L)) {
@@ -199,16 +175,6 @@ 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,51 +6,26 @@ 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
* @since 1.0
* @Date: 2019/9/24 14:29
*/
@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,34 +6,21 @@ 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
* @since 1.0
* @Date: 2019/9/24 14:28
*/
@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>();
@@ -55,18 +42,12 @@ 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>();
@@ -79,18 +60,12 @@ 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) {
@@ -105,17 +80,13 @@ public class TreeUtil<T extends TreeNode> {
}
/**
* Gets tree children ids *
*
* @param <T> parameter
* @param treeNodes 树
* @Description 获取树的所有节点的值
* @param treeNodes 树
* @param resultIdList 返回所有节点的id列表
* @return void
* @Description 获取树的所有节点的值
* @Date 2020 /3/30 16:23
* @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,99 +8,42 @@ 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,26 +10,12 @@ 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,19 +1,10 @@
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,31 +11,13 @@ 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,32 +8,19 @@ 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<>();
@@ -42,47 +29,20 @@ 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) {
@@ -97,13 +57,6 @@ 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) {
@@ -121,12 +74,6 @@ public class AosLogLogbackTTLMdcAdapter implements MDCAdapter {
}
}
/**
* Remove
*
* @param key key
* @since 1.0
*/
@Override
public void remove(String key) {
if (key == null) {
@@ -149,24 +96,12 @@ 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();
@@ -177,24 +112,12 @@ 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);
@@ -206,12 +129,6 @@ 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,26 +5,10 @@ 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,36 +10,33 @@ 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,17 +5,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author wyl
* @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
* @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,16 +4,9 @@ import com.aos.test.mybatis.domain.TestTable;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author wyl
* @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
* @description 针对表【test】的数据库操作Service
* @createDate 2022-11-11 23:39:29
*/
public interface TestService extends IService<TestTable> {
@@ -7,16 +7,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author wyl
* @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
* @description 针对表【test】的数据库操作Service实现
* @createDate 2022-11-11 23:39:29
*/
@Service
public class TestServiceImpl extends ServiceImpl<TestMapper, TestTable>
@@ -13,29 +13,13 @@ 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() {
@@ -46,36 +30,18 @@ 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,31 +7,11 @@ 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,26 +10,10 @@ 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();
@@ -37,21 +21,11 @@ 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);
@@ -60,11 +34,6 @@ public class MybatisPlusTest extends BaseTest {
System.out.println(list);
}
/**
* Gets page *
*
* @since 1.0
*/
@Test
public void getPage() {
List<TestTable> list = testService.list();
@@ -1,14 +1,4 @@
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,12 +10,6 @@ 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 {
@@ -23,11 +17,10 @@ public class Decrypt {
/**
* 解密
*
* @param <T> parameter
* @param result resultType的实例
* @return t
* @throws IllegalAccessException illegal access exception
* @since 1.0
* @param <T>
* @return
* @throws IllegalAccessException
*/
public <T> T decrypt(T result) throws IllegalAccessException {
//取出resultType的类
@@ -9,29 +9,9 @@ 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注解的字段
@@ -2,16 +2,6 @@ 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,12 +4,6 @@ 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,16 +2,6 @@ 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,17 +15,9 @@ 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配置
* @since 1.0
* @date: 2022/7/26
* @description: mybatis-plus配置
*/
@Configuration
@ComponentScan(basePackages = "com.aos.mybatis.plus")
@@ -34,11 +26,10 @@ public class MybatisPlusConf {
/**
* mybatis的SQL格式化和耗时打印
*
* @return com.aos.common.interceptor.MybatisSqlCompletePrintInterceptor mybatis sql complete print interceptor
* @Date 2022 /1/12 23:44
* @return com.aos.common.interceptor.MybatisSqlCompletePrintInterceptor
* @Date 2022/1/12 23:44
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
@Bean
MybatisSqlCompletePrintInterceptor mybatisSqlCompletePrintInterceptor() {
@@ -48,11 +39,10 @@ public class MybatisPlusConf {
/**
* mybatis plus 分页插件加载 mysql
*
* @return com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor mybatis plus interceptor
* @Date 2022 /1/12 23:44
* @return com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
* @Date 2022/1/12 23:44
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
@Bean
@ConditionalOnMissingBean(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.class)
@@ -76,11 +66,10 @@ public class MybatisPlusConf {
/**
* mybatis plus 逻辑删除配置
*
* @return com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer mybatis plus properties customizer
* @Date 2022 /1/12 23:45
* @return com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer
* @Date 2022/1/12 23:45
* @Author wangyl
* @Version V1.0
* @since 1.0
*/
@Bean
@ConditionalOnClass(com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer.class)
@@ -97,10 +86,9 @@ public class MybatisPlusConf {
* aos默认字段填充
*
* @param
* @return com.aos.mybatis.plus.handle.AosMetaObjectHandler aos meta object handler
* @Date 2022 /11/12
* @return com.aos.mybatis.plus.handle.AosMetaObjectHandler
* @Date 2022/11/12
* @Author wangyl
* @since 1.0
*/
@Bean
@ConditionalOnMissingBean({AosMetaObjectHandler.class})
@@ -108,22 +96,9 @@ 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()";
}
}
@@ -10,29 +10,18 @@ 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 meta object
* @param fieldName field name
* @param fieldVal field val
* @return com.baomidou.mybatisplus.core.handlers.MetaObjectHandler meta object handler
* @Date 2022 /11/12
* @param metaObject
* @param fieldName
* @param fieldVal
* @return com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
* @Date 2022/11/12
* @Author wangyl
* @since 1.0
*/
@Override
public MetaObjectHandler strictFillStrategy(MetaObject metaObject, String fieldName, Supplier<?> fieldVal) {
@@ -43,12 +32,6 @@ 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();
@@ -74,12 +57,6 @@ public class AosMetaObjectHandler implements MetaObjectHandler {
}
/**
* Update fill
*
* @param metaObject meta object
* @since 1.0
*/
@Override
public void updateFill(MetaObject metaObject) {
SecurityUserInfo securityUserInfo = CurrentUserContextHolder.getContext();
@@ -99,28 +76,12 @@ 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";
}
}
@@ -22,21 +22,10 @@ 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;
/**
@@ -44,14 +33,6 @@ 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();
@@ -72,10 +53,9 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
/**
* 获取sql
*
* @param target target
* @return sql
* @param target
* @return
* @throws IllegalAccessException
* @since 1.0
*/
private String getSql(Object target) {
try {
@@ -95,24 +75,11 @@ 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) {
@@ -121,10 +88,8 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
/**
* 获取完整的sql实体的信息
*
* @param boundSql bound sql
* @param configuration configuration
* @return string
* @since 1.0
* @param boundSql
* @return
*/
private String formatSql(BoundSql boundSql, Configuration configuration) {
String sql = boundSql.getSql();
@@ -179,10 +144,6 @@ 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 ]+", " ");
@@ -190,12 +151,6 @@ public class MybatisSqlCompletePrintInterceptor implements Interceptor, Ordered
}
/**
* Gets order *
*
* @return the order
* @since 1.0
*/
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
@@ -17,12 +17,6 @@ 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
@@ -32,18 +26,9 @@ 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
@@ -67,24 +52,11 @@ 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) {
@@ -18,12 +18,7 @@ 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
* @Date: 2022 /10/24
* @since 1.0
* @Date: 2022/10/24
*/
@Slf4j
@Component
@@ -32,18 +27,9 @@ 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 {
//取出查询的结果
@@ -70,13 +56,6 @@ 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);
@@ -84,24 +63,11 @@ 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,17 +10,9 @@ 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,17 +4,9 @@ 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,59 +14,25 @@ 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,21 +16,10 @@ 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;
@@ -40,9 +29,8 @@ 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) {
@@ -63,14 +51,13 @@ public class WxRobot extends AbstractRobot {
/**
* 普通信息
*
* @param robotName robot name
* @param messageTypeEnum message type enum
* @param message message
* @param value value
* @param robotName
* @param messageTypeEnum
* @param message
* @param 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) {
@@ -80,14 +67,13 @@ public class WxRobot extends AbstractRobot {
/**
* 告警信息
*
* @param robotName robot name
* @param messageTypeEnum message type enum
* @param message message
* @param value value
* @param robotName
* @param messageTypeEnum
* @param message
* @param 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) {
@@ -97,27 +83,19 @@ public class WxRobot extends AbstractRobot {
/**
* 错误信息
*
* @param robotName robot name
* @param messageTypeEnum message type enum
* @param message message
* @param error error
* @param robotName
* @param messageTypeEnum
* @param message
* @param 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);
@@ -129,13 +107,6 @@ 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,26 +11,10 @@ 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());
@@ -40,8 +24,7 @@ public class AutoRobotConfig {
/**
* 使用OkHttpClient作为底层客户端
*
* @return client http request factory
* @since 1.0
* @return
*/
private ClientHttpRequestFactory getClientHttpRequestFactory() {
OkHttpClient okHttpClient = new OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS)
@@ -51,12 +34,6 @@ 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,18 +6,7 @@ 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,17 +5,9 @@ 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 {
@@ -32,12 +24,6 @@ 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,27 +8,19 @@ 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,17 +7,9 @@ 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
@@ -31,7 +23,6 @@ public enum RobotTypeEnum {
*/
DingDing(1, "DingDing", ""),
;
/** RobotTypeMAP */
private static final Map<Integer, RobotTypeEnum> RobotTypeMAP = new HashMap<>();
static {
@@ -2,16 +2,6 @@ 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,40 +1,14 @@
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,58 +6,21 @@ 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,17 +4,9 @@ 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 {
@@ -31,10 +23,9 @@ public class WxRobotRes implements RobotRes {
* 判断是否成功
*
* @param
* @return java.lang.Boolean boolean
* @Date 2022 /8/5
* @return java.lang.Boolean
* @Date 2022/8/5
* @Author wangyl
* @since 1.0
*/
@Override
public Boolean succeed() {
@@ -12,30 +12,18 @@ 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 robot name
* @return com.aos.robot.conf.RobotInfo robot info
* @Date 2022 /11/10
* @param robotName
* @return com.aos.robot.conf.RobotInfo
* @Date 2022/11/10
* @Author wangyl
* @since 1.0
*/
protected RobotInfo getRobotInfo(String robotName) {
RobotInfo robotInfo = robotConfig.getRobots().get(robotName);
@@ -48,11 +36,10 @@ public abstract class AbstractRobot implements Robot {
/**
* 组装错误堆栈信息
*
* @param error error
* @return java.lang.String stack trace
* @Date 2022 /11/11
* @param error
* @return java.lang.String
* @Date 2022/11/11
* @Author wangyl
* @since 1.0
*/
protected String getStackTrace(Throwable error) {
String stackTrace = ExceptionUtils.getStackTrace(error);
@@ -64,23 +51,15 @@ public abstract class AbstractRobot implements Robot {
/**
* 发送消息
*
* @param robotName robot name
* @param robotParam robot param
* @param robotName
* @param robotParam
* @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);
@@ -92,13 +71,6 @@ 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,57 +3,44 @@ 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 robot name
* @param messageTypeEnum message type enum
* @param message message
* @param value value
* @param robotName
* @param messageTypeEnum
* @param message
* @param 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 robot name
* @param messageTypeEnum message type enum
* @param message message
* @param value value
* @param robotName
* @param messageTypeEnum
* @param message
* @param 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 robot name
* @param messageTypeEnum message type enum
* @param message message
* @param error error
* @param robotName
* @param messageTypeEnum
* @param message
* @param 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,28 +15,13 @@ 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) {
/**
@@ -59,12 +44,11 @@ public class SwaggerConfig implements ImportBeanDefinitionRegistrar {
/**
* 审查个好难过swagger对象
*
* @param applicationName application name
* @param packagePath package path
* @return springfox.documentation.spring.web.plugins.Docket docket
* @Date 2022 /11/6
* @param applicationName
* @param packagePath
* @return springfox.documentation.spring.web.plugins.Docket
* @Date 2022/11/6
* @Author wangyl
* @since 1.0
*/
private Docket createRestApi(String applicationName, String packagePath) {
return new Docket(DocumentationType.SWAGGER_2)
@@ -79,11 +63,10 @@ public class SwaggerConfig implements ImportBeanDefinitionRegistrar {
/**
* api描述西信息
*
* @param applicationName application name
* @return springfox.documentation.service.ApiInfo api info
* @Date 2022 /11/6
* @param applicationName
* @return springfox.documentation.service.ApiInfo
* @Date 2022/11/6
* @Author wangyl
* @since 1.0
*/
private ApiInfo apiInfo(String applicationName) {
return new ApiInfoBuilder()
@@ -10,17 +10,9 @@ 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)
@@ -28,17 +20,11 @@ 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,29 +9,14 @@ 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,32 +20,18 @@ 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) {
@@ -67,18 +53,6 @@ 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,17 +6,9 @@ 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,30 +12,15 @@ 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();
@@ -46,23 +31,11 @@ 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,76 +3,27 @@ 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,26 +5,18 @@ 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,27 +7,13 @@ 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包装器 ,解决流只能被消费一次问题
* @since 1.0
* @date: 2022/11/7
* @description: http包装器,解决流只能被消费一次问题
*/
@Slf4j
public class BodyRepeatReaderHttpServletFilter implements Filter {
/**
* Init
*
* @param filterConfig filter config
* @since 1.0
*/
@Override
public void init(FilterConfig filterConfig) {
if (log.isDebugEnabled()) {
@@ -35,16 +21,6 @@ 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) {
@@ -15,34 +15,17 @@ import java.util.List;
* BodyReaderHttpServletRequestWrapper
*
* @author luoyongchun
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2019 /07/02
* @since 1.0
* @date 2019/07/02
*/
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());
@@ -68,12 +51,6 @@ public class BodyRepeatReaderHttpServletRequestWrapper extends HttpServletReques
};
}
/**
* Gets reader *
*
* @return the reader
* @since 1.0
*/
@Override
public BufferedReader getReader() {
return new BufferedReader(new InputStreamReader(this.getInputStream()));
@@ -82,10 +59,8 @@ public class BodyRepeatReaderHttpServletRequestWrapper extends HttpServletReques
/**
* 获取body
*
* @param httpServletRequest http servlet request
* @return body
* @throws IOException io exception
* @since 1.0
* @param httpServletRequest
* @return
*/
public static String getBody(HttpServletRequest httpServletRequest) throws IOException {
List<String> lines = new ArrayList<>();
@@ -12,32 +12,22 @@ 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 registry
* @param registry
* @return void
* @Date 2022 /11/6
* @Date 2022/11/6
* @Author wangyl
* @since 1.0
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
@@ -45,15 +35,6 @@ 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);
@@ -64,15 +45,6 @@ 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,22 +27,11 @@ 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) {
@@ -92,7 +81,6 @@ public class AosJacksonBuilderCustomizer implements Jackson2ObjectMapperBuilderC
* @return the order value
* @see #HIGHEST_PRECEDENCE
* @see #LOWEST_PRECEDENCE
* @since 1.0
*/
@Override
public int getOrder() {
@@ -8,29 +8,12 @@ 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,28 +7,11 @@ 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);