Commit a57f79cf90e8fc70f646c1dd91fac79b0df6ce73
1 parent
9983590f
fix: vue2代码生成模板
Showing
10 changed files
with
42 additions
and
46 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
| ... | ... | @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 15 | 15 | #end |
| 16 | 16 | ## 字段模板 |
| 17 | 17 | #macro(columnTpl $prefix $prefixStr) |
| 18 | -#if (${column.javaType} == "Date")## 时间类型 | |
| 19 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 20 | -#end | |
| 21 | 18 | @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) |
| 22 | 19 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; |
| 23 | 20 | #end |
| ... | ... | @@ -27,12 +24,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 27 | 24 | public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { |
| 28 | 25 | |
| 29 | 26 | #foreach ($column in $columns) |
| 30 | -#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | |
| 31 | 27 | #if (${column.listOperation})##查询操作 |
| 32 | 28 | #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 |
| 33 | - #columnTpl('begin', '开始') | |
| 34 | - | |
| 35 | - #columnTpl('end', '结束') | |
| 29 | + @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | |
| 30 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 31 | + private ${column.javaType}[] ${column.javaField}; | |
| 36 | 32 | #else##情况二,非 Between 的时间 |
| 37 | 33 | #columnTpl('', '') |
| 38 | 34 | #end | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
| ... | ... | @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 15 | 15 | #end |
| 16 | 16 | ## 字段模板 |
| 17 | 17 | #macro(columnTpl $prefix $prefixStr) |
| 18 | -#if (${column.javaType} == "Date")## 时间类型 | |
| 19 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 20 | -#end | |
| 21 | 18 | @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) |
| 22 | 19 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; |
| 23 | 20 | #end |
| ... | ... | @@ -29,12 +26,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 29 | 26 | public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam { |
| 30 | 27 | |
| 31 | 28 | #foreach ($column in $columns) |
| 32 | -#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | |
| 33 | 29 | #if (${column.listOperation})##查询操作 |
| 34 | 30 | #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 |
| 35 | - #columnTpl('begin', '开始') | |
| 36 | - | |
| 37 | - #columnTpl('end', '结束') | |
| 31 | + @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | |
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 33 | + private ${column.javaType}[] ${column.javaField}; | |
| 38 | 34 | #else##情况二,非 Between 的时间 |
| 39 | 35 | #columnTpl('', '') |
| 40 | 36 | #end | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm
| ... | ... | @@ -219,22 +219,16 @@ export default { |
| 219 | 219 | title: "", |
| 220 | 220 | // 是否显示弹出层 |
| 221 | 221 | open: false, |
| 222 | - #foreach ($column in $columns)## 时间范围 | |
| 223 | - #if ($column.listOperation) | |
| 224 | - #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | |
| 225 | - #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 226 | - dateRange${AttrName}: [], | |
| 227 | - #end | |
| 228 | - #end | |
| 229 | - #end | |
| 230 | 222 | // 查询参数 |
| 231 | 223 | queryParams: { |
| 232 | 224 | pageNo: 1, |
| 233 | 225 | pageSize: 10, |
| 234 | 226 | #foreach ($column in $columns) |
| 235 | - #if ($column.listOperation && $column.listOperationCondition != 'BETWEEN') | |
| 227 | + #if ($column.listOperation) | |
| 228 | + #if ($column.listOperationCondition != 'BETWEEN') | |
| 236 | 229 | $column.javaField: null, |
| 237 | - #else if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | |
| 230 | + #end | |
| 231 | + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 238 | 232 | $column.javaField: [], |
| 239 | 233 | #end |
| 240 | 234 | #end | ... | ... |
yudao-ui-admin-vue3/src/router/modules/remaining.ts
| ... | ... | @@ -72,7 +72,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ |
| 72 | 72 | children: [ |
| 73 | 73 | { |
| 74 | 74 | path: 'edit', |
| 75 | - component: () => import('@/views/infra/codegen/EditTable.vue'), | |
| 75 | + component: () => import('@/views/infra/codegen/components/EditTable.vue'), | |
| 76 | 76 | name: 'EditTable', |
| 77 | 77 | meta: { |
| 78 | 78 | noCache: true, | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue renamed to yudao-ui-admin-vue3/src/views/infra/codegen/components/EditTable.vue
| 1 | 1 | <script setup lang="ts"> |
| 2 | 2 | import { ref, unref, onMounted } from 'vue' |
| 3 | 3 | import { ContentDetailWrap } from '@/components/ContentDetailWrap' |
| 4 | -import BasicInfoForm from './components/BasicInfoForm.vue' | |
| 5 | -import CloumInfoFormVue from './components/CloumInfoForm.vue' | |
| 6 | -import GenInfoFormVue from './components/GenInfoForm.vue' | |
| 4 | +import BasicInfoForm from './BasicInfoForm.vue' | |
| 5 | +import CloumInfoFormVue from './CloumInfoForm.vue' | |
| 6 | +import GenInfoFormVue from './GenInfoForm.vue' | |
| 7 | 7 | import { ElTabs, ElTabPane, ElButton } from 'element-plus' |
| 8 | 8 | import { getCodegenTableApi } from '@/api/infra/codegen' |
| 9 | 9 | import { useRouter, useRoute } from 'vue-router' |
| ... | ... | @@ -38,7 +38,6 @@ const submitForm = async () => { |
| 38 | 38 | console.info(basicInfoData) |
| 39 | 39 | console.info(genInfoData) |
| 40 | 40 | } |
| 41 | - console.info(1) | |
| 42 | 41 | } |
| 43 | 42 | onMounted(() => { |
| 44 | 43 | getList() | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/components/GenInfoForm.vue
| ... | ... | @@ -47,6 +47,7 @@ const schema = reactive<FormSchema[]>([ |
| 47 | 47 | label: '模块名', |
| 48 | 48 | field: 'moduleName', |
| 49 | 49 | component: 'Input', |
| 50 | + labelMessage: '模块名,即一级目录,例如 system、infra、tool 等等', | |
| 50 | 51 | colProps: { |
| 51 | 52 | span: 12 |
| 52 | 53 | } |
| ... | ... | @@ -55,6 +56,7 @@ const schema = reactive<FormSchema[]>([ |
| 55 | 56 | label: '业务名', |
| 56 | 57 | field: 'businessName', |
| 57 | 58 | component: 'Input', |
| 59 | + labelMessage: '业务名,即二级目录,例如 user、permission、dict 等等', | |
| 58 | 60 | colProps: { |
| 59 | 61 | span: 12 |
| 60 | 62 | } |
| ... | ... | @@ -63,6 +65,7 @@ const schema = reactive<FormSchema[]>([ |
| 63 | 65 | label: '类名称', |
| 64 | 66 | field: 'className', |
| 65 | 67 | component: 'Input', |
| 68 | + labelMessage: '类名称(首字母大写),例如SysUser、SysMenu、SysDictData 等等', | |
| 66 | 69 | colProps: { |
| 67 | 70 | span: 12 |
| 68 | 71 | } |
| ... | ... | @@ -71,6 +74,7 @@ const schema = reactive<FormSchema[]>([ |
| 71 | 74 | label: '类描述', |
| 72 | 75 | field: 'classComment', |
| 73 | 76 | component: 'Input', |
| 77 | + labelMessage: '用作类描述,例如 用户', | |
| 74 | 78 | colProps: { |
| 75 | 79 | span: 12 |
| 76 | 80 | } |
| ... | ... | @@ -79,6 +83,7 @@ const schema = reactive<FormSchema[]>([ |
| 79 | 83 | label: '上级菜单', |
| 80 | 84 | field: 'parentMenuId', |
| 81 | 85 | component: 'Input', |
| 86 | + labelMessage: '分配到指定菜单下,例如 系统管理', | |
| 82 | 87 | colProps: { |
| 83 | 88 | span: 12 |
| 84 | 89 | } | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/components/ImportTable.vue
| ... | ... | @@ -8,17 +8,18 @@ import { |
| 8 | 8 | ElForm, |
| 9 | 9 | ElFormItem, |
| 10 | 10 | ElInput, |
| 11 | - ElEmpty | |
| 11 | + ElSelect, | |
| 12 | + ElOption | |
| 12 | 13 | } from 'element-plus' |
| 13 | 14 | import { useI18n } from '@/hooks/web/useI18n' |
| 14 | -import { useEmitt } from '@/hooks/web/useEmitt' | |
| 15 | 15 | import { getDataSourceConfigListApi } from '@/api/infra/dataSourceConfig' |
| 16 | 16 | import type { DataSourceConfigVO } from '@/api/infra/dataSourceConfig/types' |
| 17 | 17 | import type { DatabaseTableVO } from '@/api/infra/codegen/types' |
| 18 | 18 | const { t } = useI18n() // 国际化 |
| 19 | -const { emitter } = useEmitt() | |
| 19 | +const emit = defineEmits(['ok']) | |
| 20 | 20 | // ======== 显示页面 ======== |
| 21 | 21 | const visible = ref(false) |
| 22 | +const dbLoading = ref(true) | |
| 22 | 23 | const queryParams = reactive({ |
| 23 | 24 | tableName: undefined, |
| 24 | 25 | tableComment: undefined, |
| ... | ... | @@ -37,8 +38,10 @@ const dbTableList = ref<DatabaseTableVO[]>([]) |
| 37 | 38 | |
| 38 | 39 | /** 查询表数据 */ |
| 39 | 40 | const getList = async () => { |
| 41 | + dbLoading.value = true | |
| 40 | 42 | const res = await getSchemaTableListApi(queryParams) |
| 41 | 43 | dbTableList.value = res |
| 44 | + dbLoading.value = false | |
| 42 | 45 | } |
| 43 | 46 | // 查询操作 |
| 44 | 47 | const handleQuery = async () => { |
| ... | ... | @@ -56,19 +59,18 @@ const handleSelectionChange = (val: DatabaseTableVO[]) => { |
| 56 | 59 | tables.value = val.map((item) => item.name) |
| 57 | 60 | } |
| 58 | 61 | /** 导入按钮操作 */ |
| 59 | -const handleImportTable = () => { | |
| 62 | +const handleImportTable = async () => { | |
| 60 | 63 | if (tables.value.length === 0) { |
| 61 | 64 | ElMessage.error('请选择要导入的表') |
| 62 | 65 | return |
| 63 | 66 | } |
| 64 | - createCodegenListApi({ | |
| 67 | + await createCodegenListApi({ | |
| 65 | 68 | dataSourceConfigId: queryParams.dataSourceConfigId, |
| 66 | 69 | tableNames: tables.value |
| 67 | - }).then((res) => { | |
| 68 | - ElMessage.success(res.msg) | |
| 69 | - visible.value = false | |
| 70 | - emitter.emit('ok') | |
| 71 | 70 | }) |
| 71 | + ElMessage.success('导入成功') | |
| 72 | + visible.value = false | |
| 73 | + emit('ok') | |
| 72 | 74 | } |
| 73 | 75 | defineExpose({ |
| 74 | 76 | show |
| ... | ... | @@ -78,7 +80,7 @@ defineExpose({ |
| 78 | 80 | <!-- 导入表 --> |
| 79 | 81 | <Dialog title="导入表" v-model="visible" maxHeight="500px" width="50%"> |
| 80 | 82 | <el-form :model="queryParams" ref="queryRef" :inline="true"> |
| 81 | - <!-- <el-form-item label="数据源" prop="dataSourceConfigId"> | |
| 83 | + <el-form-item label="数据源" prop="dataSourceConfigId"> | |
| 82 | 84 | <el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable> |
| 83 | 85 | <el-option |
| 84 | 86 | v-for="config in dataSourceConfigs" |
| ... | ... | @@ -87,7 +89,7 @@ defineExpose({ |
| 87 | 89 | :value="config.id" |
| 88 | 90 | /> |
| 89 | 91 | </el-select> |
| 90 | - </el-form-item> --> | |
| 92 | + </el-form-item> | |
| 91 | 93 | <el-form-item label="表名称" prop="tableName"> |
| 92 | 94 | <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable /> |
| 93 | 95 | </el-form-item> |
| ... | ... | @@ -109,11 +111,9 @@ defineExpose({ |
| 109 | 111 | ref="table" |
| 110 | 112 | :data="dbTableList" |
| 111 | 113 | @selection-change="handleSelectionChange" |
| 114 | + v-loading="dbLoading" | |
| 112 | 115 | height="400px" |
| 113 | 116 | > |
| 114 | - <template #empty> | |
| 115 | - <el-empty description="加载中" /> | |
| 116 | - </template> | |
| 117 | 117 | <el-table-column type="selection" width="55" /> |
| 118 | 118 | <el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" /> |
| 119 | 119 | <el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" /> | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/components/index.ts
0 → 100644
| 1 | +import BasicInfoForm from './BasicInfoForm.vue' | |
| 2 | +import CloumInfoForm from './CloumInfoForm.vue' | |
| 3 | +import EditTable from './EditTable.vue' | |
| 4 | +import GenInfoForm from './GenInfoForm.vue' | |
| 5 | +import ImportTable from './ImportTable.vue' | |
| 6 | +import Preview from './Preview.vue' | |
| 7 | +export { BasicInfoForm, CloumInfoForm, EditTable, GenInfoForm, ImportTable, Preview } | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/index.vue
| ... | ... | @@ -6,8 +6,7 @@ import { useTable } from '@/hooks/web/useTable' |
| 6 | 6 | import { CodegenTableVO } from '@/api/infra/codegen/types' |
| 7 | 7 | import { allSchemas } from './codegen.data' |
| 8 | 8 | import { useI18n } from '@/hooks/web/useI18n' |
| 9 | -import ImportTable from './components/ImportTable.vue' | |
| 10 | -import Preview from './components/Preview.vue' | |
| 9 | +import { ImportTable, Preview } from './components' | |
| 11 | 10 | import download from '@/utils/download' |
| 12 | 11 | import { useRouter } from 'vue-router' |
| 13 | 12 | import { useMessage } from '@/hooks/web/useMessage' | ... | ... |
yudao-ui-admin/src/views/infra/codegen/index.vue
| ... | ... | @@ -85,7 +85,7 @@ |
| 85 | 85 | |
| 86 | 86 | <script> |
| 87 | 87 | import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen, |
| 88 | - syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/infra/codegen"; | |
| 88 | + syncCodegenFromDB } from "@/api/infra/codegen"; | |
| 89 | 89 | |
| 90 | 90 | import importTable from "./importTable"; |
| 91 | 91 | // 代码高亮插件 | ... | ... |