升级 orion-kit 到 v1.0.6.

This commit is contained in:
lijiahang
2023-07-04 12:17:17 +08:00
parent 1eeb950cf8
commit 27bf523001
22 changed files with 52 additions and 403 deletions

View File

@@ -16,7 +16,8 @@
<properties>
<revision>1.0.0</revision>
<spring.boot.version>2.7.11</spring.boot.version>
<orion.all.version>1.0.5</orion.all.version>
<orion.all.version>1.0.6</orion.all.version>
<aspectj.version>1.9.7</aspectj.version>
<lombok.version>1.18.26</lombok.version>
<springdoc.version>1.6.15</springdoc.version>
<knife4j.version>4.1.0</knife4j.version>
@@ -120,6 +121,13 @@
<version>${spring.boot.version}</version>
</dependency>
<!-- aspect -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>

View File

@@ -27,6 +27,11 @@
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<!-- mapstruct -->
<dependency>
<groupId>org.mapstruct</groupId>

View File

@@ -7,7 +7,7 @@ package com.orion.ops.framework.common.constant;
* @version 1.0.0
* @since 2023/6/23 18:49
*/
public class Const extends com.orion.lang.constant.Const {
public class Const implements com.orion.lang.constant.Const {
private Const() {
}

View File

@@ -1,265 +0,0 @@
package com.orion.ops.framework.common.utils;
/**
* ANSI 高亮颜色转义码
* <p>
* \u001B = \x1b = 27 = esc
* <p>
* 基本8色 基本高对比色 xterm 256 色
* 30 ~ 37 90 ~ 97 0 ~ 256
* <p>
* \033[0m 关闭所有属性
* \033[1m 设置高亮度
* \033[4m 下划线
* \033[5m 闪烁
* \033[7m 反显
* \033[8m 消隐
* \033[30m 至 \33[37m 设置前景色
* \033[40m 至 \33[47m 设置背景色
* \033[nA 光标上移n行
* \033[nB 光标下移n行
* \033[nC 光标右移n行
* \033[nD 光标左移n行
* \033[y;xH 设置光标位置
* \033[2J 清屏
* \033[K 清除从光标到行尾的内容
* \033[s 保存光标位置
* \033[u 恢复光标位置
* \033[?25l 隐藏光标
* \033[?25h 显示光标
* <p>
* FIXME KIT
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/6/20 10:51
*/
public enum AnsiCode {
/**
* 黑色
*/
BLACK(30),
/**
* 红色
*/
RED(31),
/**
* 绿色
*/
GREEN(32),
/**
* 黄色
*/
YELLOW(33),
/**
* 蓝色
*/
BLUE(34),
/**
* 紫色
*/
PURPLE(35),
/**
* 青色
*/
CYAN(36),
/**
* 白色
*/
WHITE(37),
// -------------------- 背景色 --------------------
/**
* 黑色 背景色
*/
BG_BLACK(40),
/**
* 红色 背景色
*/
BG_RED(41),
/**
* 绿色 背景色
*/
BG_GREEN(42),
/**
* 黄色 背景色
*/
BG_YELLOW(43),
/**
* 蓝色 背景色
*/
BG_BLUE(44),
/**
* 紫色 背景色
*/
BG_PURPLE(45),
/**
* 青色 背景色
*/
BG_CYAN(46),
/**
* 白色 背景色
*/
BG_WHITE(47),
// -------------------- 亮色 --------------------
/**
* 亮黑色 (灰)
*/
GLOSS_BLACK(90),
/**
* 亮红色
*/
GLOSS_RED(91),
/**
* 亮绿色
*/
GLOSS_GREEN(92),
/**
* 亮黄色
*/
GLOSS_YELLOW(93),
/**
* 亮蓝色
*/
GLOSS_BLUE(94),
/**
* 亮紫色
*/
GLOSS_PURPLE(95),
/**
* 亮青色
*/
GLOSS_CYAN(96),
/**
* 亮白色
*/
GLOSS_WHITE(97),
// -------------------- 亮背景色 --------------------
/**
* 亮黑色 (灰) 背景色
*/
BG_GLOSS_BLACK(100),
/**
* 亮红色 背景色
*/
BG_GLOSS_RED(101),
/**
* 亮绿色 背景色
*/
BG_GLOSS_GREEN(102),
/**
* 亮黄色 背景色
*/
BG_GLOSS_YELLOW(103),
/**
* 亮蓝色 背景色
*/
BG_GLOSS_BLUE(104),
/**
* 亮紫色 背景色
*/
BG_GLOSS_PURPLE(105),
/**
* 亮青色 背景色
*/
BG_GLOSS_CYAN(106),
/**
* 亮白色 背景色
*/
BG_GLOSS_WHITE(107),
;
/**
* 颜色码
*/
public final int code;
/**
* 前缀
*/
public final String prefix;
/**
* 后缀
* \x1b[0m
*/
public static final String SUFFIX = (char) 27 + "[0m";
AnsiCode(int code) {
this.code = code;
this.prefix = getPrefix(code);
}
/**
* 文字着色
*
* @param s s
* @return s
*/
public String stain(String s) {
return prefix + s + SUFFIX;
}
/**
* 获取颜色前缀
* .e.g \x1b[31m
*
* @param code code
* @return 前缀
*/
public static String getPrefix(int code) {
return (char) 27 + "[" + code + "m";
}
/**
* 文字着色
*
* @param s s
* @param code code
* @return s
*/
public static String getStain(String s, int code) {
return getPrefix(code) + s + SUFFIX;
}
@Override
public String toString() {
return prefix;
}
}

View File

@@ -1,84 +0,0 @@
package com.orion.ops.framework.common.utils;
import com.orion.lang.utils.Strings;
/**
* 脱敏工具类
* <p>
* // FIXME KIT
*
* @author Jiahang Li
* @version 1.0.0
* @since 2019/9/10 9:45
*/
public class Desensitizes {
public static final String REPLACER = "*";
public static final char REPLACER_CHAR = '*';
private Desensitizes() {
}
public static String mix(String s, int keepStart, int keepEnd) {
return mix(s, keepStart, keepEnd, REPLACER_CHAR);
}
/**
* 字符串脱敏
* 脱敏后的长度和原先的长度一样
*
* @param s 原字符
* @param keepStart 开始保留长度
* @param keepEnd 结束保留长度
* @param replacer 脱敏字符
* @return 脱敏字符串
*/
public static String mix(String s, int keepStart, int keepEnd, char replacer) {
int length = Strings.length(s);
if (length == 0) {
return Strings.EMPTY;
}
return mix(s, keepStart, keepEnd, Strings.repeat(replacer, length - keepStart - keepEnd), 1);
}
public static String mix(String s, int keepStart, int keepEnd, String replacer) {
return mix(s, keepStart, keepEnd, replacer, 1);
}
/**
* 字符串脱敏
*
* @param s 原字符
* @param keepStart 开始保留长度
* @param keepEnd 结束保留长度
* @param replacer 脱敏字符串
* @param repeat 脱敏字符串重复次数
* @return 脱敏字符串
*/
public static String mix(String s, int keepStart, int keepEnd, String replacer, int repeat) {
int length = Strings.length(s);
if (length == 0) {
return Strings.EMPTY;
}
if (keepStart < 0) {
keepStart = 0;
}
if (keepEnd < 0) {
keepEnd = 0;
}
// 保留的长度大于等于文本的长度则不脱敏
if (keepStart + keepEnd >= length) {
return s;
}
char[] chars = s.toCharArray();
char[] replacerArr = Strings.repeat(replacer, repeat).toCharArray();
char[] res = new char[keepStart + keepEnd + replacerArr.length];
System.arraycopy(chars, 0, res, 0, keepStart);
System.arraycopy(replacerArr, 0, res, keepStart, replacerArr.length);
System.arraycopy(chars, chars.length - keepEnd, res, keepStart + replacerArr.length, keepEnd);
return new String(res);
}
}

View File

@@ -1,6 +1,6 @@
package com.orion.ops.framework.banner.core;
import com.orion.ops.framework.common.utils.AnsiCode;
import com.orion.lang.utils.ansi.AnsiCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;

View File

@@ -2,6 +2,7 @@ package com.orion.ops.framework.desensitize.core.filter;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.orion.lang.utils.Desensitizes;
import com.orion.lang.utils.Objects1;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.collect.Maps;
@@ -9,7 +10,6 @@ import com.orion.lang.utils.reflect.Annotations;
import com.orion.lang.utils.reflect.Fields;
import com.orion.ops.framework.common.annotation.Desensitize;
import com.orion.ops.framework.common.annotation.DesensitizeObject;
import com.orion.ops.framework.common.utils.Desensitizes;
import java.lang.reflect.Field;
import java.util.HashMap;

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.orion.lang.utils.Desensitizes;
import com.orion.lang.utils.Objects1;
import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.collect.Maps;
@@ -13,7 +14,6 @@ import com.orion.lang.utils.reflect.Classes;
import com.orion.ops.framework.common.annotation.IgnoreLog;
import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.common.meta.TraceIdHolder;
import com.orion.ops.framework.common.utils.Desensitizes;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import io.swagger.v3.oas.annotations.Operation;
import org.aopalliance.intercept.MethodInvocation;
@@ -270,10 +270,8 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
continue;
}
// 是否为代理对象 (bean)
if (arg != null) {
if (Classes.isJdkProxy(arg) || Classes.isCglibProxy(arg)) {
ignored[i] = true;
}
if (Classes.isJdkProxy(arg) || Classes.isCglibProxy(arg)) {
ignored[i] = true;
}
}
return ignored;

View File

@@ -51,7 +51,7 @@ public class PrettyLogPrinterInterceptor extends AbstractLogPrinterInterceptor {
if (!Strings.isEmpty(summary)) {
requestLog.append("\tsummary: ").append(summary).append('\n');
}
// TODO 登陆用户
// FIXME 登陆用户
// http
if (request != null) {
// remoteAddr

View File

@@ -55,7 +55,7 @@ public class RowLogPrinterInterceptor extends AbstractLogPrinterInterceptor impl
if (!Strings.isEmpty(summary)) {
fields.put(SUMMARY, summary);
}
// TODO 登陆用户
// FIXME 登陆用户
// http
if (request != null) {
// remoteAddr

View File

@@ -1,5 +1,7 @@
package com.orion.ops.framework.log.core.utils;
import com.orion.lang.constant.Const;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@@ -34,8 +36,7 @@ public class Utils {
return Optional.ofNullable(list)
.map(List::stream)
.orElseGet(Stream::empty)
// FIXME kit
.map(s -> s.split(","))
.map(s -> s.split(Const.COMMA))
.flatMap(Arrays::stream)
.map(String::trim)
.map(mapper)

View File

@@ -27,6 +27,12 @@
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- datasource -->
<dependency>
<groupId>com.orion.ops</groupId>

View File

@@ -24,7 +24,7 @@ public class RowCacheClearFilter extends OncePerRequestFilter {
filterChain.doFilter(request, response);
} finally {
// 清理缓存
// TODO test
// TODO TEST
RowCacheHolder.remove();
}
}

View File

@@ -31,7 +31,7 @@ public class FieldFillHandler implements MetaObjectHandler {
baseDO.setUpdateTime(now);
}
// TODO 当前用户
// FIXME 当前用户
Long userId = null;
// 创建人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
@@ -54,7 +54,7 @@ public class FieldFillHandler implements MetaObjectHandler {
// 更新人
Object updater = getFieldValByName("updater", metaObject);
// TODO 当前用户
// FIXME 当前用户
Long userId = null;
if (Objects.nonNull(userId) && Objects.isNull(updater)) {
setFieldValByName("updater", userId.toString(), metaObject);

View File

@@ -66,7 +66,7 @@ public class CacheQuery<T> {
@SuppressWarnings("unchecked")
public <R> R get(Class<R> c) {
T row = this.get();
// TODO mapstruct
// FIXME mapstruct
return (R) row;
}

View File

@@ -53,7 +53,7 @@ public class DataQuery<T> {
return Optional.ofNullable(dao.selectOne(wrapper));
}
// TODO mapstruct
// FIXME mapstruct
public <R> Optional<R> get(Class<R> c) {
return Optional.ofNullable(dao.selectOne(wrapper))
.map(s -> Converts.to(s, c));
@@ -63,7 +63,7 @@ public class DataQuery<T> {
return dao.selectList(wrapper).stream();
}
// TODO mapstruct
// FIXME mapstruct
public <R> List<R> list(Class<R> c) {
return Converts.toList(dao.selectList(wrapper), c);
}
@@ -80,7 +80,7 @@ public class DataQuery<T> {
return this.dataGrid(Function.identity());
}
// TODO mapstruct
// FIXME mapstruct
public <R> DataGrid<R> dataGrid(Class<R> c) {
return this.dataGrid(t -> Converts.to(t, c));
}

View File

@@ -2,8 +2,6 @@ package com.orion.ops.framework.mybatis.type;
import org.apache.ibatis.type.TypeHandler;
import java.util.List;
/**
* mybatis 类型转换
*
@@ -13,9 +11,6 @@ import java.util.List;
*/
public interface ITypeHandler<P, R> extends TypeHandler<R> {
// FIXME KIT
String COMMA = ",";
/**
* 数据类型转换
*
@@ -24,25 +19,4 @@ public interface ITypeHandler<P, R> extends TypeHandler<R> {
*/
R getResult(P param);
/**
* // FIXME kit
* 用 , 连接
*
* @param list list
* @return res
*/
default String join(List<?> list) {
if (list == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0, size = list.size(); i < size; i++) {
sb.append(list.get(i));
if (i != size - 1) {
sb.append(COMMA);
}
}
return sb.toString();
}
}

View File

@@ -1,6 +1,8 @@
package com.orion.ops.framework.mybatis.type;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.collect.Lists;
import com.orion.ops.framework.common.constant.Const;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@@ -28,7 +30,7 @@ public class IntegerListTypeHandler implements ITypeHandler<String, List<Integer
@Override
public void setParameter(PreparedStatement ps, int i, List<Integer> res, JdbcType jdbcType) throws SQLException {
// 设置占位符
ps.setString(i, this.join(res));
ps.setString(i, Lists.join(res));
}
@Override
@@ -51,7 +53,7 @@ public class IntegerListTypeHandler implements ITypeHandler<String, List<Integer
if (value == null) {
return null;
}
return Arrays.stream(value.split(COMMA))
return Arrays.stream(value.split(Const.COMMA))
.filter(Strings::isNumber)
.map(Integer::valueOf)
.collect(Collectors.toList());

View File

@@ -1,6 +1,8 @@
package com.orion.ops.framework.mybatis.type;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.collect.Lists;
import com.orion.ops.framework.common.constant.Const;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@@ -28,7 +30,7 @@ public class LongListTypeHandler implements ITypeHandler<String, List<Long>> {
@Override
public void setParameter(PreparedStatement ps, int i, List<Long> res, JdbcType jdbcType) throws SQLException {
// 设置占位符
ps.setString(i, this.join(res));
ps.setString(i, Lists.join(res));
}
@Override
@@ -51,7 +53,7 @@ public class LongListTypeHandler implements ITypeHandler<String, List<Long>> {
if (value == null) {
return null;
}
return Arrays.stream(value.split(COMMA))
return Arrays.stream(value.split(Const.COMMA))
.filter(Strings::isNumber)
.map(Long::valueOf)
.collect(Collectors.toList());

View File

@@ -1,6 +1,7 @@
package com.orion.ops.framework.mybatis.type;
import com.orion.lang.utils.collect.Lists;
import com.orion.ops.framework.common.constant.Const;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@@ -26,7 +27,7 @@ public class StringListTypeHandler implements ITypeHandler<String, List<String>>
@Override
public void setParameter(PreparedStatement ps, int i, List<String> res, JdbcType jdbcType) throws SQLException {
// 设置占位符
ps.setString(i, this.join(res));
ps.setString(i, Lists.join(res));
}
@Override
@@ -49,7 +50,7 @@ public class StringListTypeHandler implements ITypeHandler<String, List<String>>
if (value == null) {
return null;
}
return Lists.of(value.split(COMMA));
return Lists.of(value.split(Const.COMMA));
}
}

View File

@@ -48,7 +48,8 @@ public class WrapperResultHandler implements ResponseBodyAdvice<Object> {
wrapper = new HttpWrapper<>().data(body);
}
if (response instanceof ServletServerHttpResponse) {
((ServletServerHttpResponse) response).getServletResponse().setContentType(StandardContentType.APPLICATION_JSON);
((ServletServerHttpResponse) response).getServletResponse()
.setContentType(StandardContentType.APPLICATION_JSON_UTF8);
}
return wrapper;
}

View File

@@ -19,7 +19,7 @@ public class UserHandshakeInterceptor implements HandshakeInterceptor {
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) {
// TODO 获取当前用户
// FIXME 获取当前用户
attributes.put(WsAttr.USER, 1);
// if (user == null){
// return false;