diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 7b13fbec0..ce201e19b 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -450,6 +450,11 @@ CREATE TABLE `infra_codegen_table` ( `template_type` tinyint NOT NULL DEFAULT 1 COMMENT '模板类型', `front_type` tinyint NOT NULL COMMENT '前端类型', `parent_menu_id` bigint NULL DEFAULT NULL COMMENT '父菜单编号', + `master_table_id` bigint NULL DEFAULT NULL COMMENT '主表的编号', + `sub_join_column_id` bigint NULL DEFAULT NULL COMMENT '【自己】子表关联主表的字段编号', + `sub_join_many` bit(1) NULL DEFAULT NULL COMMENT '主表与子表是否一对多', + `tree_parent_column_id` bigint NULL DEFAULT NULL COMMENT '树表的父字段编号', + `tree_name_column_id` bigint NULL DEFAULT NULL COMMENT '树表的名字字段编号', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm index 5e9da3238..fdafffd54 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm @@ -35,21 +35,113 @@ export function get${simpleClassName}(id) { }) } +#if ( $table.templateType != 2 ) // 获得${table.classComment}分页 -export function get${simpleClassName}Page(query) { +export function get${simpleClassName}Page(params) { return request({ url: '${baseURL}/page', method: 'get', - params: query + params }) } - +#else +// 获得${table.classComment}列表 +export function get${simpleClassName}List(params) { + return request({ + url: '${baseURL}/list', + method: 'get', + params + }) +} +#end // 导出${table.classComment} Excel -export function export${simpleClassName}Excel(query) { +export function export${simpleClassName}Excel(params) { return request({ url: '${baseURL}/export-excel', method: 'get', - params: query, + params, responseType: 'blob' }) } +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + #set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 + #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 + #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) + #set ($subClassNameVar = $subClassNameVars.get($index)) + +// ==================== 子表($subTable.classComment) ==================== + ## 情况一:MASTER_ERP 时,需要分查询页子表 + #if ( $table.templateType == 11 ) + + // 获得${subTable.classComment}分页 + export function get${simpleClassName}Page(params) { + return request({ + url: '${baseURL}/${subSimpleClassName_strikeCase}/page', + method: 'get', + params + }) + } + ## 情况二:非 MASTER_ERP 时,需要列表查询子表 + #else + #if ( $subTable.subJoinMany ) + + // 获得${subTable.classComment}列表 + export function get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaField}) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField}, + method: 'get' + }) + } + #else + + // 获得${subTable.classComment} + export function get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField}) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField}, + method: 'get' + }) + } + #end + #end + ## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 + #if ( $table.templateType == 11 ) + // 新增${subTable.classComment} + export function create${subSimpleClassName}(data) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, + method: 'post', + data + }) + } + + // 修改${subTable.classComment} + export function update${subSimpleClassName}(data) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, + method: 'post', + data + }) + } + + // 删除${subTable.classComment} + export function delete${subSimpleClassName}(id) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id, + method: 'delete' + }) + } + + // 获得${subTable.classComment} + export function get${subSimpleClassName}(id) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id, + method: 'get' + }) + } + #end +#end \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm new file mode 100644 index 000000000..c1b4a0a0f --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm @@ -0,0 +1,204 @@ +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 + + \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm new file mode 100644 index 000000000..d8542c3d5 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm @@ -0,0 +1,2 @@ +## 主表的 normal 和 inner 使用相同的 form 表单 +#parse("codegen/vue3/views/components/form_sub_normal.vue.vm") \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm new file mode 100644 index 000000000..90df79812 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm @@ -0,0 +1,362 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm new file mode 100644 index 000000000..5ad208b3b --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm @@ -0,0 +1,181 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm new file mode 100644 index 000000000..3fe648892 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm @@ -0,0 +1,4 @@ +## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点: +## 1)inner 使用 list 不分页,erp 使用 page 分页 +## 2)erp 支持单个子表的新增、修改、删除,inner 不支持 +#parse("codegen/vue3/views/components/list_sub_erp.vue.vm") \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm new file mode 100644 index 000000000..7be0ed089 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm @@ -0,0 +1,333 @@ + + + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm index 7a6add604..58b41890d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm @@ -47,18 +47,67 @@ - 新增 导出 + #if ( $table.templateType == 2 ) + + + 展开/折叠 + + + #end - - + ## 特殊:主子表专属逻辑 TODO puhui999: 普通模式 + #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) + + ## 特殊:树表专属逻辑 + #elseif ( $table.templateType == 2 ) + + #else + + #end + ## 特殊:主子表专属逻辑 TODO puhui999: 内嵌模式 + #if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 ) + + + + + #end #foreach($column in $columns) #if ($column.listOperationResult) #set ($dictType=$column.dictType) @@ -84,7 +133,7 @@ #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm index 5536c39c4..432a968f8 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm @@ -146,9 +146,11 @@ import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.busine import { defaultProps, handleTree } from '@/utils/tree' #end ## 特殊:主子表专属逻辑 +#if ( $subTables && $subTables.size() > 0 ) #foreach ($subSimpleClassName in $subSimpleClassNames) import ${subSimpleClassName}Form from './components/${subSimpleClassName}Form.vue' #end +#end const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm index eab90c12a..13c448054 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -113,7 +113,7 @@ -## 特殊:主子表专属逻辑 +## 特殊:主子表专属逻辑 TODO puhui999: 普通模式 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) #end -## 特殊:主子表专属逻辑 +## 特殊:主子表专属逻辑 TODO puhui999: 内嵌模式 #if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 ) @@ -213,7 +213,7 @@ <${simpleClassName}Form ref="formRef" @success="getList" /> -## 特殊:主子表专属逻辑 +## 特殊:主子表专属逻辑 TODO puhui999: ERP 模式 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) @@ -243,7 +243,7 @@ import download from '@/utils/download' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' import ${simpleClassName}Form from './${simpleClassName}Form.vue' ## 特殊:主子表专属逻辑 -#if ( $table.templateType != 10 ) +#if ( $subTables && $subTables.size() > 0 ) #foreach ($subSimpleClassName in $subSimpleClassNames) import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue' #end @@ -343,9 +343,9 @@ const handleExport = async () => { exportLoading.value = false } } -## 特殊:主子表专属逻辑 -#if ( $table.templateType == 11 ) +## 特殊:主子表专属逻辑 +#if ( $subTables && $subTables.size() > 0 ) /** 选中行操作 */ const currentRow = ref({}) // 选中行 const handleCurrentChange = (row) => { diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index f15b0cf8d..264ad7e10 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -48,7 +48,7 @@ spring: primary: master datasource: master: - name: ruoyi-vue-pro + name: ruoyi-vue-pro4 url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 @@ -62,7 +62,7 @@ spring: # username: SYSDBA # DM 连接的示例 # password: SYSDBA # DM 连接的示例 slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro + name: ruoyi-vue-pro4 lazy: true # 开启懒加载,保证启动速度 url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 @@ -78,8 +78,8 @@ spring: redis: host: 127.0.0.1 # 地址 port: 6379 # 端口 - database: 0 # 数据库索引 -# password: dev # 密码,建议生产环境开启 + database: 4 # 数据库索引 + password: 123456 # 密码,建议生产环境开启 --- #################### 定时任务相关配置 ####################