From eb44015b7415e1d7c897cdbef216aaed278680fc Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 17 Jun 2023 12:22:12 +0800 Subject: [PATCH] =?UTF-8?q?!513=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- yudao-dependencies/pom.xml | 4 +- .../config/YudaoCaptchaConfiguration.java | 16 ++- .../core/service/RedisCaptchaServiceImpl.java | 4 + .../codegen/java/controller/vo/respVO.vm | 2 +- .../main/resources/codegen/vue3/api/api.ts.vm | 2 +- .../codegen/vue3_schema/api/api.ts.vm | 2 +- .../codegen/vue3_vben/views/data.ts.vm | 96 +++++++++++++++-- .../codegen/vue3_vben/views/form.vue.vm | 85 ++++++++------- .../codegen/vue3_vben/views/index.vue.vm | 100 +++++++++--------- 10 files changed, 206 insertions(+), 107 deletions(-) diff --git a/pom.xml b/pom.xml index c81dcff1e..425d30ef5 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ 3.8.1 1.18.26 - 2.7.11 + 2.7.12 1.5.5.Final UTF-8 diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 255517daa..331f7384d 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -16,7 +16,7 @@ 1.7.3-snapshot - 2.7.11 + 2.7.12 2021.0.5 2021.0.4.0 @@ -76,7 +76,7 @@ 8.5.2 4.6.3 2.2.1 - 3.1.715 + 3.1.758 1.4.0 1.5.6 2.12.2 diff --git a/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java b/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java index 2a690d800..057445519 100644 --- a/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java @@ -3,11 +3,15 @@ package cn.iocoder.yudao.framework.captcha.config; import cn.hutool.core.util.ClassUtil; import cn.iocoder.yudao.framework.captcha.core.enums.CaptchaRedisKeyConstants; import cn.iocoder.yudao.framework.captcha.core.service.RedisCaptchaServiceImpl; +import com.xingyuv.captcha.properties.AjCaptchaProperties; import com.xingyuv.captcha.service.CaptchaCacheService; +import com.xingyuv.captcha.service.impl.CaptchaServiceFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.data.redis.core.StringRedisTemplate; +import javax.annotation.Resource; + @AutoConfiguration public class YudaoCaptchaConfiguration { @@ -17,9 +21,17 @@ public class YudaoCaptchaConfiguration { ClassUtil.loadClass(CaptchaRedisKeyConstants.class.getName()); } + @Resource + private StringRedisTemplate stringRedisTemplate; + @Bean - public CaptchaCacheService captchaCacheService(StringRedisTemplate stringRedisTemplate) { - return new RedisCaptchaServiceImpl(stringRedisTemplate); + public CaptchaCacheService captchaCacheService(AjCaptchaProperties config) { + // 缓存类型 redis/local/.... + CaptchaCacheService ret = CaptchaServiceFactory.getCache(config.getCacheType().name()); + if (ret instanceof RedisCaptchaServiceImpl) { + ((RedisCaptchaServiceImpl) ret).setStringRedisTemplate(stringRedisTemplate); + } + return ret; } } diff --git a/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/service/RedisCaptchaServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/service/RedisCaptchaServiceImpl.java index 1429c47c2..4b47bd193 100644 --- a/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/service/RedisCaptchaServiceImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/service/RedisCaptchaServiceImpl.java @@ -20,6 +20,10 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService { @Resource // 保证 aj-captcha 的 SPI 创建时的注入 private StringRedisTemplate stringRedisTemplate; + public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) { + this.stringRedisTemplate = stringRedisTemplate; + } + @Override public String type() { return "redis"; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm index 2288ceee8..517d8bcd5 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm @@ -17,7 +17,7 @@ public class ${sceneEnum.prefixClass}${table.className}RespVO extends ${sceneEnu #foreach ($column in $columns) #if (${column.listOperationResult} && (!${column.createOperation} || !${column.updateOperation}))##不是通用字段 - @Schema(description = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end) + @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end) private ${column.javaType} ${column.javaField}; #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm index 8bd1c4ee3..401796db8 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm @@ -16,7 +16,7 @@ export interface ${simpleClassName}VO { } // 查询${table.classComment}列表 -export const get${simpleClassName}Page = async (params: ${simpleClassName}PageReqVO) => { +export const get${simpleClassName}Page = async (params) => { return await request.get({ url: `${baseURL}/page`, params }) } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm index 32114e788..48cd5422b 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm @@ -16,7 +16,7 @@ export interface ${simpleClassName}VO { } // 查询${table.classComment}列表 -export const get${simpleClassName}Page = async (params: ${simpleClassName}PageReqVO) => { +export const get${simpleClassName}Page = async (params) => { return await request.get({ url: '${baseURL}/page', params }) } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm index cf130155f..6f0c01d80 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm @@ -1,5 +1,5 @@ import { BasicColumn, FormSchema, useRender } from '@/components/Table' -import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' +import { DICT_TYPE, getDictOptions } from '@/utils/dict' export const columns: BasicColumn[] = [ #foreach($column in $columns) @@ -53,7 +53,7 @@ export const searchFormSchema: FormSchema[] = [ component: 'Select', componentProps: { #if ("" != $dictType)## 设置了 dictType 数据字典的情况 - options: getIntDictOptions(DICT_TYPE.$dictType.toUpperCase()) + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()) #else## 未设置 dictType 数据字典的情况 options: [] #end @@ -67,7 +67,7 @@ export const searchFormSchema: FormSchema[] = [ #end ] -export const formSchema: FormSchema[] = [ +export const createFormSchema: FormSchema[] = [ { label: '编号', field: 'id', @@ -75,7 +75,7 @@ export const formSchema: FormSchema[] = [ component: 'Input' }, #foreach($column in $columns) -#if ($column.createOperation || $column.updateOperation) +#if ($column.createOperation) #set ($dictType = $column.dictType) #set ($javaField = $column.javaField) #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) @@ -90,16 +90,24 @@ export const formSchema: FormSchema[] = [ #if ($column.htmlType == "input") component: 'Input' #elseif($column.htmlType == "imageUpload")## 图片上传 - component: 'Upload' + component: 'FileUpload', + componentProps: { + fileType: 'file', + maxCount: 1 + } #elseif($column.htmlType == "fileUpload")## 文件上传 - component: 'Upload' + component: 'FileUpload', + componentProps: { + fileType: 'image', + maxCount: 1 + } #elseif($column.htmlType == "editor")## 文本编辑器 - component: 'InputTextArea' + component: 'Editor' #elseif($column.htmlType == "select")## 下拉框 component: 'Select', componentProps: { #if ("" != $dictType)## 有数据字典 - options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') #else##没数据字典 options:[] #end @@ -108,16 +116,16 @@ export const formSchema: FormSchema[] = [ component: 'Checkbox', componentProps: { #if ("" != $dictType)## 有数据字典 - options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') #else##没数据字典 options:[] #end } #elseif($column.htmlType == "radio")## 单选框 - component: 'Radio', + component: 'RadioButtonGroup', componentProps: { #if ("" != $dictType)## 有数据字典 - options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') #else##没数据字典 options:[] #end @@ -132,3 +140,69 @@ export const formSchema: FormSchema[] = [ #end #end ] + +export const updateFormSchema: FormSchema[] = [ + { + label: '编号', + field: 'id', + show: false, + component: 'Input' + }, +#foreach($column in $columns) +#if ($column.updateOperation) +#set ($dictType = $column.dictType) +#set ($javaField = $column.javaField) +#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#set ($comment = $column.columnComment) +#if (!$column.primaryKey)## 忽略主键,不用在表单里 + { + label: '${comment}', + field: '${javaField}', + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 + required: true, + #end + #if ($column.htmlType == "input") + component: 'Input' + #elseif($column.htmlType == "imageUpload")## 图片上传 + component: 'Upload' + #elseif($column.htmlType == "fileUpload")## 文件上传 + component: 'Upload' + #elseif($column.htmlType == "editor")## 文本编辑器 + component: 'Editor' + #elseif($column.htmlType == "select")## 下拉框 + component: 'Select', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') + #else##没数据字典 + options:[] + #end + } + #elseif($column.htmlType == "checkbox")## 多选框 + component: 'Checkbox', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') + #else##没数据字典 + options:[] + #end + } + #elseif($column.htmlType == "radio")## 单选框 + component: 'RadioButtonGroup', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') + #else##没数据字典 + options:[] + #end + } + #elseif($column.htmlType == "datetime")## 时间框 + component: 'DatePicker' + #elseif($column.htmlType == "textarea")## 文本域 + component: 'InputTextArea' + #end + }, +#end +#end +#end +] \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm index 2d69b5147..5815a4daa 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm @@ -1,49 +1,56 @@ - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm index 9130ec9b3..e5faddd29 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm @@ -33,58 +33,60 @@ <${simpleClassName}Modal @register="registerModal" @success="reload()" /> -