修改 ANSI 日志.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.orion.ops.framework.banner.core;
|
||||
|
||||
import com.orion.lang.utils.Threads;
|
||||
import com.orion.lang.utils.ansi.AnsiColor;
|
||||
import com.orion.lang.utils.ansi.AnsiAppender;
|
||||
import com.orion.lang.utils.ansi.style.color.AnsiForeground;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
@@ -37,19 +38,19 @@ public class BannerApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
String line = AnsiColor.GLOSS_GREEN.color(":: orion-ops-launch v" + version + " 服务已启动(" + env + ") ::\n") +
|
||||
AnsiColor.GLOSS_GREEN.color(":: swagger 文档 ") +
|
||||
AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + "/doc.html\n") +
|
||||
AnsiColor.GLOSS_GREEN.color(":: druid console ") +
|
||||
AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + "/druid/index.html\n") +
|
||||
AnsiColor.GLOSS_GREEN.color(":: actuator endpoint ") +
|
||||
AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + managementEndpoints + "\n") +
|
||||
AnsiColor.GLOSS_GREEN.color(":: admin console ") +
|
||||
AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + adminSeverContextPath + "\n") +
|
||||
AnsiColor.GLOSS_GREEN.color(":: server 健康检测 ") +
|
||||
AnsiColor.GLOSS_BLUE +
|
||||
"curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\"" +
|
||||
AnsiColor.SUFFIX;
|
||||
String line = AnsiAppender.create()
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: orion-ops-launch v" + version + " 服务已启动(" + env + ") ::\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/doc.html\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: druid console ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/druid/index.html\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: actuator endpoint ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + managementEndpoints + "\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: admin console ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + adminSeverContextPath + "\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: server 健康检测 ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\"")
|
||||
.toString();
|
||||
Threads.start(() -> {
|
||||
Threads.sleep(1000L);
|
||||
System.out.println(line);
|
||||
|
||||
@@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import com.orion.lang.constant.Const;
|
||||
import com.orion.lang.utils.ansi.AnsiColor;
|
||||
import com.orion.lang.utils.ansi.AnsiAppender;
|
||||
import com.orion.lang.utils.ansi.style.AnsiFont;
|
||||
import com.orion.lang.utils.ansi.style.color.AnsiForeground;
|
||||
import com.orion.lang.utils.ext.yml.YmlExt;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
|
||||
@@ -373,11 +375,12 @@ public class CodeGenerator {
|
||||
* 打印提示信息
|
||||
*/
|
||||
private static void printTips() {
|
||||
String line = AnsiColor.GLOSS_GREEN.color(":: 代码生成完毕 ::\n") +
|
||||
AnsiColor.GLOSS_BLUE.color("- 后端代码复制后请先 clean 模块父工程\n") +
|
||||
AnsiColor.GLOSS_BLUE.color("- 后端代码复制后请先执行单元测试检测是否正常\n") +
|
||||
AnsiColor.GLOSS_BLUE.color("- vue 代码需要注意同一模块的 router 需要自行合并\n") +
|
||||
AnsiColor.SUFFIX;
|
||||
String line = AnsiAppender.create()
|
||||
.append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "\n:: 代码生成完毕 ^_^ ::\n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- 后端代码复制后请先 clean 模块父工程\n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- 后端代码复制后请先执行单元测试检测是否正常\n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- vue 代码需要注意同一模块的 router 需要自行合并\n")
|
||||
.toString();
|
||||
System.out.print(line);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.orion.ops.launch.generator;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.orion.lang.define.collect.MultiLinkedHashMap;
|
||||
import com.orion.lang.utils.Enums;
|
||||
import com.orion.lang.utils.ansi.AnsiAppender;
|
||||
import com.orion.lang.utils.ansi.style.AnsiFont;
|
||||
import com.orion.lang.utils.ansi.style.color.AnsiForeground;
|
||||
import com.orion.lang.utils.awt.Clipboards;
|
||||
import com.orion.lang.utils.reflect.Fields;
|
||||
import com.orion.ops.module.infra.enums.UserStatusEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 前端枚举生成器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/8/25 14:55
|
||||
*/
|
||||
public class EnumGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 生成前端枚举配置
|
||||
String gen = gen(UserStatusEnum.class,
|
||||
UserStatusEnum::getStatus,
|
||||
UserStatusEnum::name);
|
||||
System.out.println(gen);
|
||||
}
|
||||
|
||||
public static <E extends Enum<?>> String gen(Class<E> clazz,
|
||||
Function<E, Object> valueFunction) {
|
||||
return gen(clazz, valueFunction, Enum::name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E extends Enum<?>> String gen(Class<E> clazz,
|
||||
Function<E, Object> valueFunction,
|
||||
Function<E, Object> labelFunction) {
|
||||
// 获取枚举
|
||||
Enum<?>[] constants = clazz.getEnumConstants();
|
||||
// 获取字段
|
||||
List<String> fields = Enums.getFields(clazz);
|
||||
MultiLinkedHashMap<String, String, Object> result = MultiLinkedHashMap.create();
|
||||
for (Enum<?> e : constants) {
|
||||
String name = e.name();
|
||||
result.put(name, "value", valueFunction.apply((E) e));
|
||||
result.put(name, "label", labelFunction.apply((E) e));
|
||||
for (String field : fields) {
|
||||
result.put(name, field, Fields.getFieldValue(e, field));
|
||||
}
|
||||
}
|
||||
// ts 代码
|
||||
String tsCode = "/**\n *\n */\nexport const " + clazz.getSimpleName() + " = " + JSON.toJSONString(result, SerializerFeature.PrettyFormat);
|
||||
// 复制到剪切板
|
||||
Clipboards.setString(tsCode);
|
||||
// 提示
|
||||
String tips = AnsiAppender.create()
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "代码生成完成 - 已复制到剪切板 ^_^")
|
||||
.toString();
|
||||
return "\n" + tsCode + "\n\n" + tips;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user