From a423552a2f8113e68ad79c0d54537351b3e2d753 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Wed, 30 Oct 2024 15:07:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B6=88=E6=81=AF=E7=B1=BB=E5=9E=8BCUR?= =?UTF-8?q?D=E5=AE=8C=E6=88=90,=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generator/AdminCodeGenerator.java | 6 +- .../generator/generator/WebGeneratorCode.java | 34 +++--- .../resources/vms/server/resourceMapper.vm | 2 +- .../src/main/resources/vms/web/columns.vm | 6 +- .../src/main/resources/vms/web/dialog.vm | 4 +- .../src/main/resources/vms/web/hook.vm | 51 +++++---- .../src/main/resources/vms/web/index.vm | 12 +- .../common/service/utils/minio/MinioUtil.java | 19 ++-- .../dto/system/message/MessageTypeAddDto.java | 34 ++++++ .../dto/system/message/MessageTypeDto.java | 30 +++++ .../system/message/MessageTypeUpdateDto.java | 33 ++++++ .../cn/bunny/dao/entity/system/Message.java | 46 ++++++++ .../bunny/dao/entity/system/MessageType.java | 38 +++++++ .../dao/pojo/constant/MinioConstant.java | 10 +- .../dao/vo/system/message/MessageTypeVo.java | 27 +++++ .../controller/ConfigurationController.java | 2 +- .../services/controller/DeptController.java | 2 +- .../controller/MessageController.java | 18 +++ .../controller/MessageTypeController.java | 79 +++++++++++++ .../bunny/services/mapper/MessageMapper.java | 18 +++ .../services/mapper/MessageTypeMapper.java | 39 +++++++ .../services/service/MessageService.java | 16 +++ .../services/service/MessageTypeService.java | 59 ++++++++++ .../service/impl/FilesServiceImpl.java | 51 ++++++++- .../service/impl/MessageServiceImpl.java | 20 ++++ .../service/impl/MessageTypeServiceImpl.java | 107 ++++++++++++++++++ .../main/resources/mapper/MessageMapper.xml | 26 +++++ .../resources/mapper/MessageTypeMapper.xml | 56 +++++++++ 28 files changed, 765 insertions(+), 80 deletions(-) create mode 100644 dao/src/main/java/cn/bunny/dao/dto/system/message/MessageTypeAddDto.java create mode 100644 dao/src/main/java/cn/bunny/dao/dto/system/message/MessageTypeDto.java create mode 100644 dao/src/main/java/cn/bunny/dao/dto/system/message/MessageTypeUpdateDto.java create mode 100644 dao/src/main/java/cn/bunny/dao/entity/system/Message.java create mode 100644 dao/src/main/java/cn/bunny/dao/entity/system/MessageType.java create mode 100644 dao/src/main/java/cn/bunny/dao/vo/system/message/MessageTypeVo.java create mode 100644 service/src/main/java/cn/bunny/services/controller/MessageController.java create mode 100644 service/src/main/java/cn/bunny/services/controller/MessageTypeController.java create mode 100644 service/src/main/java/cn/bunny/services/mapper/MessageMapper.java create mode 100644 service/src/main/java/cn/bunny/services/mapper/MessageTypeMapper.java create mode 100644 service/src/main/java/cn/bunny/services/service/MessageService.java create mode 100644 service/src/main/java/cn/bunny/services/service/MessageTypeService.java create mode 100644 service/src/main/java/cn/bunny/services/service/impl/MessageServiceImpl.java create mode 100644 service/src/main/java/cn/bunny/services/service/impl/MessageTypeServiceImpl.java create mode 100644 service/src/main/resources/mapper/MessageMapper.xml create mode 100644 service/src/main/resources/mapper/MessageTypeMapper.xml diff --git a/common/common-generator/src/main/java/cn/bunny/common/generator/generator/AdminCodeGenerator.java b/common/common-generator/src/main/java/cn/bunny/common/generator/generator/AdminCodeGenerator.java index d061802..b03e1d7 100644 --- a/common/common-generator/src/main/java/cn/bunny/common/generator/generator/AdminCodeGenerator.java +++ b/common/common-generator/src/main/java/cn/bunny/common/generator/generator/AdminCodeGenerator.java @@ -14,13 +14,13 @@ public class AdminCodeGenerator { // 作者名称 public static final String author = "Bunny"; // 公共路径 - // public static final String outputDir = "D:\\MyFolder\\auth-admin\\auth-server-java\\service"; - public static final String outputDir = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service"; + public static final String outputDir = "D:\\MyFolder\\auth-admin\\auth-server-java\\service"; + // public static final String outputDir = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service"; // 实体类名称 public static final String entity = "Bunny"; public static void main(String[] args) { - Generation("log_user_login"); + Generation("sys_message", "sys_message_type"); } /** diff --git a/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java b/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java index 0cb6c41..de48409 100644 --- a/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java +++ b/common/common-generator/src/main/java/cn/bunny/common/generator/generator/WebGeneratorCode.java @@ -3,10 +3,10 @@ package cn.bunny.common.generator.generator; import cn.bunny.common.generator.entity.BaseField; import cn.bunny.common.generator.entity.BaseResultMap; import cn.bunny.common.generator.utils.GeneratorCodeUtils; -import cn.bunny.dao.dto.log.UserLoginLogDto; -import cn.bunny.dao.dto.log.UserLoginLogUpdateDto; -import cn.bunny.dao.entity.log.UserLoginLog; -import cn.bunny.dao.vo.log.UserLoginLogVo; +import cn.bunny.dao.dto.system.message.MessageTypeDto; +import cn.bunny.dao.dto.system.message.MessageTypeUpdateDto; +import cn.bunny.dao.entity.system.MessageType; +import cn.bunny.dao.vo.system.message.MessageTypeVo; import com.baomidou.mybatisplus.annotation.TableName; import com.google.common.base.CaseFormat; import io.swagger.v3.oas.annotations.media.Schema; @@ -35,26 +35,26 @@ import java.util.stream.Stream; @Service public class WebGeneratorCode { // 公共路径 - public static String commonPath = "D:\\Project\\web\\PC\\auth\\auth-web\\src"; + public static String commonPath = "D:\\MyFolder\\auth-admin\\auth-web\\src"; // 生成API请求路径 public static String apiPath = commonPath + "\\api\\v1\\"; // 生成vue路径 - public static String vuePath = commonPath + "\\views\\monitor\\"; + public static String vuePath = commonPath + "\\views\\message\\"; // 生成仓库路径 - public static String storePath = commonPath + "\\store\\monitor\\"; + public static String storePath = commonPath + "\\store\\message\\"; // 后端controller - public static String controllerPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\"; - public static String servicePath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\"; - public static String serviceImplPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\"; - public static String mapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\"; - public static String resourceMapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\resources\\mapper\\"; + public static String controllerPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\"; + public static String servicePath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\"; + public static String serviceImplPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\"; + public static String mapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\"; + public static String resourceMapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\resources\\mapper\\"; public static void main(String[] args) throws Exception { - Class originalClass = UserLoginLog.class; - Class dtoClass = UserLoginLogDto.class; - Class addDtoClass = UserLoginLogDto.class; - Class updateDtoClass = UserLoginLogUpdateDto.class; - Class voClass = UserLoginLogVo.class; + Class originalClass = MessageType.class; + Class dtoClass = MessageTypeDto.class; + Class addDtoClass = MessageTypeDto.class; + Class updateDtoClass = MessageTypeUpdateDto.class; + Class voClass = MessageTypeVo.class; // 设置velocity资源加载器 Properties prop = new Properties(); diff --git a/common/common-generator/src/main/resources/vms/server/resourceMapper.vm b/common/common-generator/src/main/resources/vms/server/resourceMapper.vm index 066f075..ac7c00c 100644 --- a/common/common-generator/src/main/resources/vms/server/resourceMapper.vm +++ b/common/common-generator/src/main/resources/vms/server/resourceMapper.vm @@ -21,12 +21,12 @@ from $tableName #foreach($field in $pageQueryMap) + is_deleted = 0 and $field.column like CONCAT('%',#{dto.${field.property}},'%') #end - order by update_time desc diff --git a/common/common-generator/src/main/resources/vms/web/columns.vm b/common/common-generator/src/main/resources/vms/web/columns.vm index 0b0dc7d..a33f4ec 100644 --- a/common/common-generator/src/main/resources/vms/web/columns.vm +++ b/common/common-generator/src/main/resources/vms/web/columns.vm @@ -7,7 +7,7 @@ export const columns: TableColumnList = [ { type: 'index', index: (index: number) => index + 1, label: '序号', width: 60 }, #foreach($field in $baseFieldList) // $field.annotation -{ label: $t('${lowercaseName}_$field.name'), prop: '$field.name' }, +{ label: $t('$field.name'), prop: '$field.name' }, #end { label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 }, { label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 }, @@ -17,9 +17,9 @@ export const columns: TableColumnList = [ ]; // 添加规则 -export const rules = reactive({ +export const rules = reactive({ #foreach($field in $baseFieldList) // $field.annotation - $field.name: [{ required: true, message: `$leftBrace$t('input')}$leftBrace$t('${lowercaseName}_${field.name}')}`, trigger: 'blur' }], + $field.name: [{ required: true, message: `$leftBrace$t('input')}$leftBrace$t('${field.name}')}`, trigger: 'blur' }], #end }); diff --git a/common/common-generator/src/main/resources/vms/web/dialog.vm b/common/common-generator/src/main/resources/vms/web/dialog.vm index 783ce52..14324e0 100644 --- a/common/common-generator/src/main/resources/vms/web/dialog.vm +++ b/common/common-generator/src/main/resources/vms/web/dialog.vm @@ -28,8 +28,8 @@ #foreach($item in $baseFieldList) - - + + #end diff --git a/common/common-generator/src/main/resources/vms/web/hook.vm b/common/common-generator/src/main/resources/vms/web/hook.vm index bcb3b4c..1246f3d 100644 --- a/common/common-generator/src/main/resources/vms/web/hook.vm +++ b/common/common-generator/src/main/resources/vms/web/hook.vm @@ -6,6 +6,7 @@ import { h, ref } from 'vue'; import { messageBox } from '@/utils/message'; import type { FormItemProps } from '${typesPath}'; import { $t } from '@/plugins/i18n'; +import type { FormRules } from 'element-plus'; export const formRef = ref(); // 删除ids @@ -21,12 +22,10 @@ export async function onSearch() { ${lowercaseName}Store.loading = false; } -/** - * * 添加${classTitle} - */ +/** 添加${classTitle} */ export function onAdd() { addDialog({ - title: `$leftBrace $t("add_new")}$leftBrace$t("${lowercaseName}")}`, + title: `$leftBrace $t("addNew")}$leftBrace$t("${lowercaseName}")}`, width: '30%', props: { formInline: { @@ -86,15 +85,13 @@ export function onUpdate(row: any) { }); } -/** - * * 删除${classTitle} - */ +/** 删除${classTitle} */ export const onDelete = async (row: any) => { const id = row.id; // 是否确认删除 const result = await messageBox({ - title: $t('confirm_delete'), + title: $t('confirmDelete'), showMessage: false, confirmMessage: undefined, cancelMessage: $t("cancel_delete"), @@ -106,22 +103,32 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * 批量删除 - */ +/** 批量删除 */ export const onDeleteBatch = async () => { const ids = deleteIds.value; + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirm_delete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('cancel_delete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await ${lowercaseName}Store.delete${originalName}(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await ${lowercaseName}Store.delete${originalName}(ids); - await onSearch(); }; \ No newline at end of file diff --git a/common/common-generator/src/main/resources/vms/web/index.vm b/common/common-generator/src/main/resources/vms/web/index.vm index b2565a5..f449f2c 100644 --- a/common/common-generator/src/main/resources/vms/web/index.vm +++ b/common/common-generator/src/main/resources/vms/web/index.vm @@ -18,9 +18,7 @@ const formRef = ref(); const ${lowercaseName}Store = use${originalName}Store(); - /** - * * 当前页改变时 - */ + /** 当前页改变时 */ const onCurrentPageChange = async (value: number) => { ${lowercaseName}Store.pagination.currentPage = value; await onSearch(); @@ -64,8 +62,8 @@ onMounted(() => { #foreach($item in $formList) - - + + #end @@ -76,7 +74,7 @@ onMounted(() => {