生成数据字典代码.
This commit is contained in:
@@ -9,7 +9,6 @@ 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.Strings;
|
||||
import com.orion.lang.utils.ansi.AnsiAppender;
|
||||
import com.orion.lang.utils.ansi.style.AnsiFont;
|
||||
import com.orion.lang.utils.ansi.style.color.AnsiForeground;
|
||||
@@ -26,6 +25,7 @@ import java.io.File;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -53,13 +53,29 @@ public class CodeGenerator {
|
||||
// .vue("user", "preference")
|
||||
// .enums("type")
|
||||
// .names("APP", "HOST")
|
||||
// .values("label", "应用", "主机")
|
||||
// // 同 .value(1, 2)
|
||||
// .values("value", 1, 2)
|
||||
// // 同 .label("应用", "主机")
|
||||
// .values("label", "应用", "主机")
|
||||
// .color("blue", "green")
|
||||
// .build(),
|
||||
Template.create("operator_log", "操作日志", "operator.log")
|
||||
.disableUnitTest()
|
||||
.build()
|
||||
Template.create("history_value", "历史归档", "history")
|
||||
.enableProviderApi()
|
||||
.vue("meta", "history-value")
|
||||
.build(),
|
||||
Template.create("dict_key", "字典配置项", "dict")
|
||||
.cache("dict:keys", "字典配置项")
|
||||
.expire(1, TimeUnit.HOURS)
|
||||
.vue("system", "dict-key")
|
||||
.enums("value_type")
|
||||
.names("STRING", "NUMBER", "BOOLEAN", "COLOR")
|
||||
.label("字符串", "数值", "布尔值", "颜色")
|
||||
.build(),
|
||||
Template.create("dict_value", "字典配置值", "dict")
|
||||
.cache("dict:value:{}", "字典配置值 ${key}")
|
||||
.expire(1, TimeUnit.HOURS)
|
||||
.vue("system", "dict-value")
|
||||
.build(),
|
||||
};
|
||||
// jdbc 配置 - 使用配置文件
|
||||
File yamlFile = new File("orion-ops-launch/src/main/resources/application-dev.yaml");
|
||||
@@ -124,7 +140,7 @@ public class CodeGenerator {
|
||||
ag.execute(engine);
|
||||
|
||||
// 打印提示信息
|
||||
printTips(module);
|
||||
printTips();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,13 +422,12 @@ public class CodeGenerator {
|
||||
/**
|
||||
* 打印提示信息
|
||||
*/
|
||||
private static void printTips(String module) {
|
||||
private static void printTips() {
|
||||
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), "- 后端代码修改完成后请先执行单元测试检测是否正常\n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- 需要在 " + Strings.firstUpper(module) + "OperatorTypeRunner 添加 xxxOperatorType.init() 来初始化操作日志类型 \n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- vue 代码需要注意同一模块的 router 需要自行合并\n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- vue 枚举需要自行更改数据类型\n")
|
||||
.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "- 菜单 sql 执行完成后 需要在菜单页面刷新缓存\n")
|
||||
|
||||
@@ -200,7 +200,7 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
|
||||
// 类型脊柱名称
|
||||
objectMap.put("typeHyphen", mappingHyphen.substring(0, mappingHyphen.length() - 3));
|
||||
// 类型常量
|
||||
objectMap.put("typeConst", VariableStyles.BIG_HUMP.toSpine(entityName).toUpperCase());
|
||||
objectMap.put("typeConst", VariableStyles.BIG_HUMP.toSerpentine(entityName).toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLe
|
||||
* @since ${date}
|
||||
*/
|
||||
@Module("${package.ModuleName}:${typeHyphen}")
|
||||
public class ${type}OperatorType {
|
||||
public class ${type}OperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String CREATE = "${typeHyphen}:create";
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
return ${typeLower}DAO.of(wrapper).list(${type}ProviderConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
#if($cacheMeta.enableCache)
|
||||
@Override
|
||||
public List<${type}DTO> get${type}ListByCache() {
|
||||
return ${typeLower}Service.get${type}ListByCache()
|
||||
@@ -114,6 +115,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
#end
|
||||
@Override
|
||||
public Long get${type}Count(${type}QueryDTO dto) {
|
||||
log.info("${type}Api.get${type}Count dto: {}", JSON.toJSONString(dto));
|
||||
|
||||
@@ -64,6 +64,7 @@ public interface ${type}Api {
|
||||
*/
|
||||
List<${type}DTO> get${type}List(${type}QueryDTO dto);
|
||||
|
||||
#if($cacheMeta.enableCache)
|
||||
/**
|
||||
* ${apiComment.queryListByCache}
|
||||
*
|
||||
@@ -71,6 +72,7 @@ public interface ${type}Api {
|
||||
*/
|
||||
List<${type}DTO> get${type}ListByCache();
|
||||
|
||||
#end
|
||||
/**
|
||||
* ${apiComment.queryCount}
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user