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