init commit.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.orion.ops.framework.common.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 不执行统一日志打印
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2022/4/20 10:33
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface IgnoreLog {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.orion.ops.framework.common.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 无需包装返回
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2021/4/2 10:36
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface IgnoreWrapper {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.orion.ops.framework.common.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 统一返回包装
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2021/4/2 12:34
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RestWrapper {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.orion.ops.framework.common.enums;
|
||||
|
||||
/**
|
||||
* 消息常量
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2021/6/4 18:26
|
||||
*/
|
||||
public interface ExceptionMessageConst {
|
||||
|
||||
String INVALID_PARAM = "非法参数";
|
||||
|
||||
String OPERATOR_ERROR = "操作失败";
|
||||
|
||||
String HTTP_API = "api 调用异常";
|
||||
|
||||
String NETWORK_FLUCTUATION = "当前环境网路波动";
|
||||
|
||||
String OPEN_TEMPLATE_ERROR = "模板解析失败 请检查模板和密码";
|
||||
|
||||
String PARSE_TEMPLATE_DATA_ERROR = "模板解析失败 请检查模板数据";
|
||||
|
||||
String REPOSITORY_OPERATOR_ERROR = "应用版本仓库操作执行失败";
|
||||
|
||||
String TASK_ERROR = "任务执行异常";
|
||||
|
||||
String CONNECT_ERROR = "建立连接失败";
|
||||
|
||||
String TIMEOUT_ERROR = "处理超时";
|
||||
|
||||
String INTERRUPT_ERROR = "操作中断";
|
||||
|
||||
String UNSAFE_OPERATOR = "不安全的操作";
|
||||
|
||||
String ENCRYPT_ERROR = "数据加密异常";
|
||||
|
||||
String DECRYPT_ERROR = "数据解密异常";
|
||||
|
||||
String EXCEPTION_MESSAGE = "系统异常";
|
||||
|
||||
String IO_EXCEPTION_MESSAGE = "网络异常";
|
||||
|
||||
String SQL_EXCEPTION_MESSAGE = "数据异常";
|
||||
|
||||
String FILE_TOO_LARGE = "文件过大";
|
||||
|
||||
String ERROR_EXPRESSION = "表达式错误";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.orion.ops.framework.common.enums;
|
||||
|
||||
/**
|
||||
* 过滤器排序常量
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/6/16 17:04
|
||||
*/
|
||||
public interface FilterOrderConst {
|
||||
|
||||
int CORS_FILTER = Integer.MIN_VALUE;
|
||||
|
||||
int TRICE_ID_FILTER = Integer.MIN_VALUE + 10;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.orion.ops.framework.common.enums;
|
||||
|
||||
/**
|
||||
* 拦截器排序常量
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/6/16 18:15
|
||||
*/
|
||||
public interface InterceptorOrderConst {
|
||||
|
||||
int LOG_FILTER = Integer.MIN_VALUE;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.orion.ops.framework.common.enums;
|
||||
|
||||
/**
|
||||
* 项目常量
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/6/19 18:56
|
||||
*/
|
||||
public interface OrionOpsProConst {
|
||||
|
||||
String GITHUB = "https://github.com/lijiahangmax/orion-ops-pro";
|
||||
|
||||
String GITEE = "https://gitee.com/lijiahangmax/orion-ops-pro";
|
||||
|
||||
String ISSUES = "https://gitee.com/lijiahangmax/orion-ops-pro/issues";
|
||||
|
||||
String VERSION = "1.0.0";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orion.ops.framework.common.meta;
|
||||
|
||||
/**
|
||||
* traceId 持有者
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/6/16 17:35
|
||||
*/
|
||||
public class TraceIdHolder {
|
||||
|
||||
private TraceIdHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求序列
|
||||
*/
|
||||
private static final ThreadLocal<String> HOLDER = new ThreadLocal<>();
|
||||
;
|
||||
|
||||
public static String get() {
|
||||
return HOLDER.get();
|
||||
}
|
||||
|
||||
public static void set(String traceId) {
|
||||
HOLDER.set(traceId);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
HOLDER.remove();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
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>
|
||||
* TODO 后续直接使用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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user