调整代码生成模板.
This commit is contained in:
@@ -25,7 +25,6 @@ import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
|
||||
import com.orion.lang.define.collect.MultiLinkedHashMap;
|
||||
import com.orion.lang.utils.Enums;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.VariableStyles;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.lang.utils.reflect.BeanMap;
|
||||
import com.orion.lang.utils.reflect.Fields;
|
||||
@@ -278,36 +277,6 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 sql 文件
|
||||
*
|
||||
* @param customFiles customFiles
|
||||
* @param tableInfo tableInfo
|
||||
* @param objectMap objectMap
|
||||
*/
|
||||
private void generatorSqlFile(@NotNull List<CustomFile> customFiles, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) {
|
||||
String outPath = getConfigBuilder().getGlobalConfig().getOutputDir();
|
||||
GenTable table = tables.get(tableInfo.getName());
|
||||
BeanMap beanMap = BeanMap.create(table, "enums");
|
||||
// 模块名称首字母大写
|
||||
beanMap.put("moduleFirstUpper", Strings.firstUpper(table.getModule()));
|
||||
// 功能名称首字母大写
|
||||
beanMap.put("featureFirstUpper", Strings.firstUpper(table.getFeature()));
|
||||
// 功能名称全大写
|
||||
beanMap.put("featureAllUpper", table.getFeature().toUpperCase());
|
||||
objectMap.put("vue", beanMap);
|
||||
|
||||
// 生成文件
|
||||
customFiles.forEach(file -> {
|
||||
// 文件路径
|
||||
String filePath = outPath
|
||||
+ "/" + Strings.format(file.getPackageName(), beanMap)
|
||||
+ "/" + Strings.format(file.getFileName(), beanMap);
|
||||
// 输出文件
|
||||
this.outputFile(Files1.newFile(filePath), objectMap, file.getTemplatePath(), file.isFileOverride());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为后端文件
|
||||
*
|
||||
@@ -349,10 +318,8 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
|
||||
List<Class<? extends Enum<?>>> enums = table.getEnums();
|
||||
Map<String, MultiLinkedHashMap<String, String, Object>> enumMap = new LinkedHashMap<>();
|
||||
for (Class<? extends Enum<?>> e : enums) {
|
||||
// 大驼峰文件名称转为蛇形大写
|
||||
String enumTypeName = VariableStyles.BIG_HUMP.toSerpentine(e.getSimpleName()).toUpperCase();
|
||||
MultiLinkedHashMap<String, String, Object> fieldValueMap = Enums.getFieldValueMap(e);
|
||||
enumMap.put(enumTypeName, fieldValueMap);
|
||||
enumMap.put(e.getSimpleName(), fieldValueMap);
|
||||
}
|
||||
return enumMap;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
-- 执行完成后 需要在菜单页面刷新缓存
|
||||
|
||||
-- 设置临时子菜单id
|
||||
-- 父菜单
|
||||
INSERT INTO system_menu
|
||||
(parent_id, name, type, sort, visible, status, cache)
|
||||
VALUES
|
||||
(0, '${vue.comment}管理', 1, 10, 1, 1, 1);
|
||||
|
||||
-- 设置临时父菜单id
|
||||
SELECT @TMP_PARENT_ID:=LAST_INSERT_ID();
|
||||
|
||||
-- 父菜单
|
||||
INSERT INTO system_menu (parent_id, name, type, sort, visible, status, cache)
|
||||
VALUES (0, '${vue.comment}管理', 1, 10, 1, 1, 1);
|
||||
|
||||
-- 子菜单
|
||||
INSERT INTO system_menu (parent_id, name, type, sort, visible, status, cache, component)
|
||||
VALUES (@TMP_PARENT_ID, '$vue.comment', 2, 10, 1, 1, 1, '$vue.module$vue.featureFirstUpper');
|
||||
INSERT INTO system_menu
|
||||
(parent_id, name, type, sort, visible, status, cache, component)
|
||||
VALUES
|
||||
(@TMP_PARENT_ID, '$vue.comment', 2, 10, 1, 1, 1, '$vue.module$vue.featureFirstUpper');
|
||||
|
||||
-- 设置临时子菜单id
|
||||
SELECT @TMP_SUB_ID:=LAST_INSERT_ID();
|
||||
|
||||
-- 功能
|
||||
INSERT INTO system_menu (parent_id, name, permission, type, sort)
|
||||
VALUES (@TMP_SUB_ID, '创建$vue.comment', '${package.ModuleName}:${typeHyphen}:create', 3, 10);
|
||||
INSERT INTO system_menu (parent_id, name, permission, type, sort)
|
||||
VALUES (@TMP_SUB_ID, '修改$vue.comment', '${package.ModuleName}:${typeHyphen}:update', 3, 20);
|
||||
INSERT INTO system_menu (parent_id, name, permission, type, sort)
|
||||
VALUES (@TMP_SUB_ID, '查询$vue.comment', '${package.ModuleName}:${typeHyphen}:query', 3, 30);
|
||||
INSERT INTO system_menu (parent_id, name, permission, type, sort)
|
||||
VALUES (@TMP_SUB_ID, '删除$vue.comment', '${package.ModuleName}:${typeHyphen}:delete', 3, 40);
|
||||
INSERT INTO system_menu
|
||||
(parent_id, name, permission, type, sort)
|
||||
VALUES
|
||||
(@TMP_SUB_ID, '查询$vue.comment', '${package.ModuleName}:${typeHyphen}:query', 3, 10),
|
||||
(@TMP_SUB_ID, '创建$vue.comment', '${package.ModuleName}:${typeHyphen}:create', 3, 20),
|
||||
(@TMP_SUB_ID, '修改$vue.comment', '${package.ModuleName}:${typeHyphen}:update', 3, 30),
|
||||
(@TMP_SUB_ID, '删除$vue.comment', '${package.ModuleName}:${typeHyphen}:delete', 3, 40);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
body-class="modal-form"
|
||||
title-align="start"
|
||||
:title="title"
|
||||
:top="120"
|
||||
:top="80"
|
||||
:align-center="false"
|
||||
:draggable="true"
|
||||
:mask-closable="false"
|
||||
@@ -55,6 +55,8 @@
|
||||
import formRules from '../types/form.rules';
|
||||
import { create${vue.featureFirstUpper}, update${vue.featureFirstUpper} } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { } from '../types/enum.types';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
|
||||
@@ -115,6 +115,8 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { defaultPagination, defaultRowSelection } from '@/types/table';
|
||||
import { } from '../types/enum.types';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
|
||||
const tableRenderData = ref<${vue.featureFirstUpper}QueryResponse[]>();
|
||||
const { loading, setLoading } = useLoading();
|
||||
|
||||
@@ -18,6 +18,7 @@ const columns = [
|
||||
ellipsis: true,
|
||||
tooltip: true,
|
||||
#elseif(${field.propertyType} == 'Date')
|
||||
width: 180,
|
||||
render: ({ record }) => {
|
||||
return record.${field.propertyName} && dateFormat(new Date(record.${field.propertyName}));
|
||||
},
|
||||
@@ -27,6 +28,7 @@ const columns = [
|
||||
dataIndex: 'createTime',
|
||||
slotName: 'createTime',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
render: ({ record }) => {
|
||||
return dateFormat(new Date(record.createTime));
|
||||
},
|
||||
@@ -35,6 +37,7 @@ const columns = [
|
||||
dataIndex: 'updateTime',
|
||||
slotName: 'updateTime',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
render: ({ record }) => {
|
||||
return dateFormat(new Date(record.updateTime));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user