From 33fb112dfecc23df103e8039f57097a451238519 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 16 Dec 2025 21:09:48 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90infra=E3=80=91=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=20admin=20uniapp=20=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E7=9A=84=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/codegen/CodegenFrontTypeEnum.java | 2 + .../service/codegen/inner/CodegenEngine.java | 19 ++ .../codegen/vue3_admin_uniapp/api/api.ts.vm | 55 ++++ .../components/search-form.vue.vm | 257 ++++++++++++++++++ .../views/detail/index.vue.vm | 143 ++++++++++ .../vue3_admin_uniapp/views/form/index.vue.vm | 225 +++++++++++++++ .../vue3_admin_uniapp/views/index.vue.vm | 220 +++++++++++++++ 7 files changed, 921 insertions(+) create mode 100644 yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/api/api.ts.vm create mode 100644 yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/components/search-form.vue.vm create mode 100644 yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/detail/index.vue.vm create mode 100644 yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/form/index.vue.vm create mode 100644 yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/index.vue.vm diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java index 7f55507e42..b3c8116cd6 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java @@ -23,6 +23,8 @@ public enum CodegenFrontTypeEnum { VUE3_VBEN5_EP_SCHEMA(50), // Vue3 VBEN5 + EP + schema 模版 VUE3_VBEN5_EP_GENERAL(51), // Vue3 VBEN5 + EP 标准模版 + + VUE3_ADMIN_UNIAPP_WOT(60), // Vue3 Admin + Uniapp + WOT 标准模版 ; /** diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java index cf8e030945..5de27ce23f 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java @@ -137,6 +137,16 @@ public class CodegenEngine { vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue")) .put(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType(), vue3TemplatePath("api/api.ts"), vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts")) + .put(CodegenFrontTypeEnum.VUE3_ADMIN_UNIAPP_WOT.getType(), vue3AdminUniappTemplatePath("api/api.ts"), + vue3UniappFilePath("api/${table.moduleName}/${table.businessName}/index.ts")) + .put(CodegenFrontTypeEnum.VUE3_ADMIN_UNIAPP_WOT.getType(), vue3AdminUniappTemplatePath("views/index.vue"), + vue3UniappFilePath("pages-${table.moduleName}/${table.businessName}/index.vue")) + .put(CodegenFrontTypeEnum.VUE3_ADMIN_UNIAPP_WOT.getType(), vue3AdminUniappTemplatePath("components/search-form.vue"), + vue3UniappFilePath("pages-${table.moduleName}/${table.businessName}/components/search-form.vue")) + .put(CodegenFrontTypeEnum.VUE3_ADMIN_UNIAPP_WOT.getType(), vue3AdminUniappTemplatePath("views/form/index.vue"), + vue3UniappFilePath("pages-${table.moduleName}/${table.businessName}/form/index.vue")) + .put(CodegenFrontTypeEnum.VUE3_ADMIN_UNIAPP_WOT.getType(), vue3AdminUniappTemplatePath("views/detail/index.vue"), + vue3UniappFilePath("pages-${table.moduleName}/${table.businessName}/detail/index.vue")) // VUE3_VBEN2_ANTD_SCHEMA .put(CodegenFrontTypeEnum.VUE3_VBEN2_ANTD_SCHEMA.getType(), vue3VbenTemplatePath("views/data.ts"), vue3VbenFilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts")) @@ -617,6 +627,15 @@ public class CodegenEngine { "src/" + path; } + private static String vue3AdminUniappTemplatePath(String path) { + return "codegen/vue3_admin_uniapp/" + path + ".vm"; + } + + private static String vue3UniappFilePath(String path) { + return "yudao-ui-${sceneEnum.basePackage}-uniapp/" + // 顶级目录 + "src/" + path; + } + private static String vue3VbenFilePath(String path) { return "yudao-ui-${sceneEnum.basePackage}-vben/" + // 顶级目录 "src/" + path; diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/api/api.ts.vm b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/api/api.ts.vm new file mode 100644 index 0000000000..4754bfacdd --- /dev/null +++ b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/api/api.ts.vm @@ -0,0 +1,55 @@ +import type { PageParam, PageResult } from '@/http/types' +import { http } from '@/http/http' + +// TODO @AI:不使用 baseUrl,而是参考之前的,直接写在每个方法里。 +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") +const baseUrl = '${baseURL}' + +#set ($primaryJavaType = $primaryColumn.javaType.toLowerCase()) +#if(${primaryJavaType} == "long" || ${primaryJavaType} == "integer" || ${primaryJavaType} == "short" || ${primaryJavaType} == "double" || ${primaryJavaType} == "bigdecimal" || ${primaryJavaType} == "byte") +#set ($primaryTsType = "number") +#else +#set ($primaryTsType = "string") +#end + +/** ${table.classComment}信息 */ +export interface ${simpleClassName} { +#foreach ($column in $columns) + #if ($column.primaryKey || $column.createOperation || $column.updateOperation || $column.listOperationResult) + #set ($javaType = $column.javaType.toLowerCase()) + #set ($optional = $column.nullable || $column.primaryKey) + #if(${javaType} == "long" || ${javaType} == "integer" || ${javaType} == "short" || ${javaType} == "double" || ${javaType} == "bigdecimal" || ${javaType} == "byte") + ${column.javaField}#if($optional)?#end: number + #elseif(${javaType} == "boolean") + ${column.javaField}#if($optional)?#end: boolean + #else + ${column.javaField}#if($optional)?#end: string + #end + #end +#end +} + +/** 获取${table.classComment}分页列表 */ +export function get${simpleClassName}Page(params: PageParam) { + return http.get>(baseUrl + '/page', params) +} + +/** 获取${table.classComment}详情 */ +export function get${simpleClassName}(id: ${primaryTsType}) { + return http.get<${simpleClassName}>(baseUrl + '/get?id=' + id) +} + +/** 创建${table.classComment} */ +export function create${simpleClassName}(data: ${simpleClassName}) { + return http.post(baseUrl + '/create', data) +} + +/** 更新${table.classComment} */ +export function update${simpleClassName}(data: ${simpleClassName}) { + return http.put(baseUrl + '/update', data) +} + +/** 删除${table.classComment} */ +export function delete${simpleClassName}(id: ${primaryTsType}) { + return http.delete(baseUrl + '/delete?id=' + id) +} diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/components/search-form.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/components/search-form.vue.vm new file mode 100644 index 0000000000..fad564b15c --- /dev/null +++ b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/components/search-form.vue.vm @@ -0,0 +1,257 @@ + + + diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/detail/index.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/detail/index.vue.vm new file mode 100644 index 0000000000..fdc340d686 --- /dev/null +++ b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/detail/index.vue.vm @@ -0,0 +1,143 @@ + + + + + diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/form/index.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/form/index.vue.vm new file mode 100644 index 0000000000..ffee229db7 --- /dev/null +++ b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/form/index.vue.vm @@ -0,0 +1,225 @@ + + + + + diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/index.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/index.vue.vm new file mode 100644 index 0000000000..7cebd5ac83 --- /dev/null +++ b/yudao-module-infra/src/main/resources/codegen/vue3_admin_uniapp/views/index.vue.vm @@ -0,0 +1,220 @@ + + + + +