From 04bd6bff043f66273d0786ab42f97494a0498fc3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 30 Apr 2025 16:03:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=EF=BC=9A=E7=BD=91=E5=85=B3=E4=BC=A0?= =?UTF-8?q?=E9=80=92=20login-user=20=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=20usertype=20=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/filter/TokenAuthenticationFilter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java index 88ce4e178..071e1a0cd 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java @@ -135,7 +135,17 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter { } try { loginUserStr = URLDecoder.decode(loginUserStr, StandardCharsets.UTF_8); // 解码,解决中文乱码问题 - return JsonUtils.parseObject(loginUserStr, LoginUser.class); + LoginUser loginUser = JsonUtils.parseObject(loginUserStr, LoginUser.class); + // 用户类型不匹配,无权限 + // 注意:只有 /admin-api/* 和 /app-api/* 有 userType,才需要比对用户类型 + // 类似 WebSocket 的 /ws/* 连接地址,是不需要比对用户类型的 + Integer userType = WebFrameworkUtils.getLoginUserType(request); + if (userType != null + && loginUser != null + && ObjectUtil.notEqual(loginUser.getUserType(), userType)) { + throw new AccessDeniedException("错误的用户类型"); + } + return loginUser; } catch (Exception ex) { log.error("[buildLoginUserByHeader][解析 LoginUser({}) 发生异常]", loginUserStr, ex); ; throw ex; From 103685269e632dba60c717f5168a99481695a6ab Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 2 May 2025 20:25:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E5=90=8C=E6=AD=A5=E3=80=91BOOT=20?= =?UTF-8?q?=E5=92=8C=20CLOUD=20=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/ruoyi-vue-pro.sql | 2 +- .../util/collection/CollectionUtils.java | 14 + ...YudaoRedisMQConsumerAutoConfiguration.java | 12 + .../job/RedisPendingMessageResendJob.java | 6 +- .../job/RedisStreamMessageCleanupJob.java | 72 ++++ .../BpmTaskCandidateFormUserStrategy.java | 6 +- .../BpmTaskCandidateExpressionStrategy.java | 6 +- .../bpm/service/task/BpmTaskServiceImpl.java | 3 +- .../enums/codegen/CodegenFrontTypeEnum.java | 5 + .../file/core/client/s3/S3FileClient.java | 4 +- .../service/codegen/inner/CodegenEngine.java | 19 + .../vue3_vben5_antd/general/index.vue.vm | 0 .../vue3_vben5_antd/general/views/data.ts.vm | 349 +++++++++++++++++ .../vue3_vben5_antd/general/views/form.vue.vm | 313 +++++++++++++++ .../general/views/index.vue.vm | 357 ++++++++++++++++++ .../general/views/modules/form_sub_erp.vue.vm | 93 +++++ .../views/modules/form_sub_inner.vue.vm | 2 + .../views/modules/form_sub_normal.vue.vm | 199 ++++++++++ .../general/views/modules/list_sub_erp.vue.vm | 184 +++++++++ .../views/modules/list_sub_inner.vue.vm | 4 + .../vue3_vben5_antd/schema/views/data.ts.vm | 44 +-- .../vue3_vben5_antd/schema/views/form.vue.vm | 11 +- .../schema/views/modules/form_sub_erp.vue.vm | 11 +- .../views/modules/form_sub_normal.vue.vm | 13 +- .../module/product/api/sku/ProductSkuApi.java | 13 + .../module/product/api/spu/ProductSpuApi.java | 2 +- .../vo/ProductBrowseHistoryRespVO.java | 8 +- .../favorite/vo/AppFavoriteBatchReqVO.java | 6 +- .../app/favorite/vo/AppFavoriteReqVO.java | 5 +- .../app/favorite/vo/AppFavoriteRespVO.java | 6 +- .../AppProductBrowseHistoryDeleteReqVO.java | 4 +- .../vo/AppProductBrowseHistoryRespVO.java | 16 +- .../dal/mysql/sku/ProductSkuMapper.java | 9 +- .../dal/mysql/spu/ProductSpuMapper.java | 5 + .../comment/ProductCommentServiceImpl.java | 4 +- .../service/sku/ProductSkuService.java | 9 + .../service/sku/ProductSkuServiceImpl.java | 8 + .../service/spu/ProductSpuService.java | 9 + .../service/spu/ProductSpuServiceImpl.java | 8 + .../admin/point/PointActivityController.java | 2 +- .../vo/template/AppCouponTemplateRespVO.java | 8 +- .../app/point/AppPointActivityController.java | 2 +- .../service/coupon/CouponServiceImpl.java | 17 +- .../app/aftersale/AppAfterSaleController.java | 14 +- .../aftersale/vo/AppAfterSalePageReqVO.java | 20 + .../app/base/spu/AppProductSpuBaseRespVO.java | 8 +- .../pickup/AppDeliveryPickUpStoreRespVO.java | 14 + .../convert/aftersale/AfterSaleConvert.java | 5 - .../trade/convert/cart/TradeCartConvert.java | 8 +- .../dal/mysql/aftersale/AfterSaleMapper.java | 9 +- .../service/aftersale/AfterSaleService.java | 6 +- .../aftersale/AfterSaleServiceImpl.java | 8 +- .../order/TradeOrderUpdateServiceImpl.java | 20 +- .../handler/TradeBrokerageOrderHandler.java | 15 +- .../system/enums/ErrorCodeConstants.java | 1 + .../service/tenant/TenantServiceImpl.java | 2 + .../service/user/AdminUserServiceImpl.java | 13 +- 57 files changed, 1873 insertions(+), 140 deletions(-) create mode 100644 yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisStreamMessageCleanupJob.java delete mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/index.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/data.ts.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/form.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/index.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/form_sub_erp.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/form_sub_inner.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/form_sub_normal.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/list_sub_erp.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/list_sub_inner.vue.vm create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSalePageReqVO.java diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 9d425c13d..cceeab3be 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -1055,7 +1055,7 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2172, 31, 'RABBITMQ', '31', 'iot_data_bridge_type_enum', 0, 'primary', '', '', '1', '2025-03-09 12:41:47', '1', '2025-03-17 09:40:46', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2173, 32, 'KAFKA', '32', 'iot_data_bridge_type_enum', 0, 'primary', '', '', '1', '2025-03-09 12:41:59', '1', '2025-03-17 09:40:46', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3000, 16, '百川智能', 'BaiChuan', 'ai_platform', 0, '', '', '', '1', '2025-03-23 12:15:46', '1', '2025-03-23 12:15:46', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '50', 'infra_codegen_front_type', 0, '', '', NULL, '1', '2025-04-23 21:47:47', '1', '2025-04-23 21:47:47', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '40', 'infra_codegen_front_type', 0, '', '', NULL, '1', '2025-04-23 21:47:47', '1', '2025-04-23 21:47:47', b'0'); COMMIT; -- ---------------------------- diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java index ed58c4f16..aa523b94d 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java @@ -11,6 +11,7 @@ import java.util.function.*; import java.util.stream.Collectors; import java.util.stream.Stream; +import static cn.hutool.core.convert.Convert.toCollection; import static java.util.Arrays.asList; /** @@ -335,4 +336,17 @@ public class CollectionUtils { return list.stream().filter(Objects::nonNull).flatMap(Collection::stream).collect(Collectors.toList()); } + /** + * 转换为 LinkedHashSet + * + * @param 元素类型 + * @param elementType 集合中元素类型 + * @param value 被转换的值 + * @return {@link LinkedHashSet} + */ + @SuppressWarnings("unchecked") + public static LinkedHashSet toLinkedHashSet(Class elementType, Object value) { + return (LinkedHashSet) toCollection(LinkedHashSet.class, elementType, value); + } + } \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/config/YudaoRedisMQConsumerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/config/YudaoRedisMQConsumerAutoConfiguration.java index d02e84b14..c9ab3e541 100644 --- a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/config/YudaoRedisMQConsumerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/config/YudaoRedisMQConsumerAutoConfiguration.java @@ -6,6 +6,7 @@ import cn.hutool.system.SystemUtil; import cn.iocoder.yudao.framework.common.enums.DocumentEnum; import cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate; import cn.iocoder.yudao.framework.mq.redis.core.job.RedisPendingMessageResendJob; +import cn.iocoder.yudao.framework.mq.redis.core.job.RedisStreamMessageCleanupJob; import cn.iocoder.yudao.framework.mq.redis.core.pubsub.AbstractRedisChannelMessageListener; import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener; import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; @@ -73,6 +74,17 @@ public class YudaoRedisMQConsumerAutoConfiguration { return new RedisPendingMessageResendJob(listeners, redisTemplate, groupName, redissonClient); } + /** + * 创建 Redis Stream 消息清理任务 + */ + @Bean + @ConditionalOnBean(AbstractRedisStreamMessageListener.class) + public RedisStreamMessageCleanupJob redisStreamMessageCleanupJob(List> listeners, + RedisMQTemplate redisTemplate, + RedissonClient redissonClient) { + return new RedisStreamMessageCleanupJob(listeners, redisTemplate, redissonClient); + } + /** * 创建 Redis Stream 集群消费的容器 * diff --git a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisPendingMessageResendJob.java b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisPendingMessageResendJob.java index b84f17c15..cb4e3991f 100644 --- a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisPendingMessageResendJob.java +++ b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisPendingMessageResendJob.java @@ -23,13 +23,13 @@ import java.util.Objects; @AllArgsConstructor public class RedisPendingMessageResendJob { - private static final String LOCK_KEY = "redis:pending:msg:lock"; + private static final String LOCK_KEY = "redis:stream:pending-message-resend:lock"; /** * 消息超时时间,默认 5 分钟 * * 1. 超时的消息才会被重新投递 - * 2. 由于定时任务 1 分钟一次,消息超时后不会被立即重投,极端情况下消息5分钟过期后,再等 1 分钟才会被扫瞄到 + * 2. 由于定时任务 1 分钟一次,消息超时后不会被立即重投,极端情况下消息 5 分钟过期后,再等 1 分钟才会被扫瞄到 */ private static final int EXPIRE_TIME = 5 * 60; @@ -39,7 +39,7 @@ public class RedisPendingMessageResendJob { private final RedissonClient redissonClient; /** - * 一分钟执行一次,这里选择每分钟的35秒执行,是为了避免整点任务过多的问题 + * 一分钟执行一次,这里选择每分钟的 35 秒执行,是为了避免整点任务过多的问题 */ @Scheduled(cron = "35 * * * * ?") public void messageResend() { diff --git a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisStreamMessageCleanupJob.java b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisStreamMessageCleanupJob.java new file mode 100644 index 000000000..19da84594 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisStreamMessageCleanupJob.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.framework.mq.redis.core.job; + +import cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate; +import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.data.redis.core.StreamOperations; +import org.springframework.scheduling.annotation.Scheduled; + +import java.util.List; + +/** + * Redis Stream 消息清理任务 + * 用于定期清理已消费的消息,防止内存占用过大 + * + * @see 记一次 redis stream 数据类型内存不释放问题 + * + * @author 芋道源码 + */ +@Slf4j +@AllArgsConstructor +public class RedisStreamMessageCleanupJob { + + private static final String LOCK_KEY = "redis:stream:message-cleanup:lock"; + + /** + * 保留的消息数量,默认保留最近 10000 条消息 + */ + private static final long MAX_COUNT = 10000; + + private final List> listeners; + private final RedisMQTemplate redisTemplate; + private final RedissonClient redissonClient; + + /** + * 每小时执行一次清理任务 + */ + @Scheduled(cron = "0 0 * * * ?") + public void cleanup() { + RLock lock = redissonClient.getLock(LOCK_KEY); + // 尝试加锁 + if (lock.tryLock()) { + try { + execute(); + } catch (Exception ex) { + log.error("[cleanup][执行异常]", ex); + } finally { + lock.unlock(); + } + } + } + + /** + * 执行清理逻辑 + */ + private void execute() { + StreamOperations ops = redisTemplate.getRedisTemplate().opsForStream(); + listeners.forEach(listener -> { + try { + // 使用 XTRIM 命令清理消息,只保留最近的 MAX_LEN 条消息 + Long trimCount = ops.trim(listener.getStreamKey(), MAX_COUNT, true); + if (trimCount != null && trimCount > 0) { + log.info("[execute][Stream({}) 清理消息数量({})]", listener.getStreamKey(), trimCount); + } + } catch (Exception ex) { + log.error("[execute][Stream({}) 清理异常]", listener.getStreamKey(), ex); + } + }); + } +} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/form/BpmTaskCandidateFormUserStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/form/BpmTaskCandidateFormUserStrategy.java index 2d315979a..6298c3259 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/form/BpmTaskCandidateFormUserStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/form/BpmTaskCandidateFormUserStrategy.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.form; -import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Assert; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.user.BpmTaskCandidateUserStrategy; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; @@ -33,7 +33,7 @@ public class BpmTaskCandidateFormUserStrategy implements BpmTaskCandidateStrateg @Override public Set calculateUsersByTask(DelegateExecution execution, String param) { Object result = execution.getVariable(param); - return Convert.toSet(Long.class, result); + return CollectionUtils.toLinkedHashSet(Long.class, result); } @Override @@ -41,7 +41,7 @@ public class BpmTaskCandidateFormUserStrategy implements BpmTaskCandidateStrateg String param, Long startUserId, String processDefinitionId, Map processVariables) { Object result = processVariables == null ? null : processVariables.get(param); - return Convert.toSet(Long.class, result); + return CollectionUtils.toLinkedHashSet(Long.class, result); } } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java index c008c1cb6..64ca9e853 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.other; -import cn.hutool.core.convert.Convert; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; @@ -37,7 +37,7 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat @Override public Set calculateUsersByTask(DelegateExecution execution, String param) { Object result = FlowableUtils.getExpressionValue(execution, param); - return Convert.toSet(Long.class, result); + return CollectionUtils.toLinkedHashSet(Long.class, result); } @Override @@ -46,7 +46,7 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat Map variables = processVariables == null ? new HashMap<>() : processVariables; try { Object result = FlowableUtils.getExpressionValue(variables, param); - return Convert.toSet(Long.class, result); + return CollectionUtils.toLinkedHashSet(Long.class, result); } catch (FlowableException ex) { // 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常, log.warn("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java index 3683cdf17..8a7c0e488 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java @@ -873,12 +873,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { List returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null); List returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId); + List runExecutionIds = new ArrayList<>(); // 2. 给当前要被退回的 task 数组,设置退回意见 taskList.forEach(task -> { // 需要排除掉,不需要设置退回意见的任务 if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) { return; } + runExecutionIds.add(task.getExecutionId()); // 判断是否分配给自己任务,因为会签任务,一个节点会有多个任务 if (isAssignUserTask(userId, task)) { // 情况一:自己的任务,进行 RETURN 标记 @@ -898,7 +900,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { // 4. 执行驳回 // 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因: // 当多实例任务回退的时候有问题。相关 issue: https://github.com/flowable/flowable-engine/issues/3944 - List runExecutionIds = convertList(taskList, Task::getExecutionId); runtimeService.createChangeActivityStateBuilder() .processInstanceId(currentTask.getProcessInstanceId()) .moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey()) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java index 1b6bb41ab..db4326f91 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java @@ -13,9 +13,14 @@ import lombok.Getter; public enum CodegenFrontTypeEnum { VUE2_ELEMENT_UI(10), // Vue2 Element UI 标准模版 + VUE3_ELEMENT_PLUS(20), // Vue3 Element Plus 标准模版 + VUE3_VBEN2_ANTD_SCHEMA(30), // Vue3 VBEN2 + ANTD + Schema 模版 + VUE3_VBEN5_ANTD_SCHEMA(40), // Vue3 VBEN5 + ANTD + schema 模版 + + VUE3_VBEN5_ANTD_GENERAL(41), // Vue3 VBEN5 + ANTD 标准模版 ; /** diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java index d74d80560..a33f0d738 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java @@ -46,7 +46,9 @@ public class S3FileClient extends AbstractFileClient { AwsBasicCredentials.create(config.getAccessKey(), config.getAccessSecret())); URI endpoint = URI.create(buildEndpoint()); S3Configuration serviceConfiguration = S3Configuration.builder() // Path-style 访问 - .pathStyleAccessEnabled(Boolean.TRUE.equals(config.getEnablePathStyleAccess())).build(); + .pathStyleAccessEnabled(Boolean.TRUE.equals(config.getEnablePathStyleAccess())) + .chunkedEncodingEnabled(false) // 禁用分块编码,参见 https://t.zsxq.com/kBy57 + .build(); client = S3Client.builder() .credentialsProvider(credentialsProvider) .region(region) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java index 0ec4f9826..0b5b870eb 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java @@ -163,6 +163,25 @@ public class CodegenEngine { vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue")) .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑 vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue")) + // VUE3_VBEN5_ANTD + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/data.ts"), + vue3FilePath("views/${table.moduleName}/${table.businessName}/data.ts")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/index.vue"), + vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/form.vue"), + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/form.vue")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("api/api.ts"), + vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/modules/form_sub_normal.vue"), // 特殊:主子表专属逻辑 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/modules/form_sub_inner.vue"), // 特殊:主子表专属逻辑 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/modules/form_sub_erp.vue"), // 特殊:主子表专属逻辑 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/modules/list_sub_inner.vue"), // 特殊:主子表专属逻辑 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue")) + .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_GENERAL.getType(), vue3Vben5AntdGeneralTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue")) .build(); @Resource diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/index.vue.vm deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/data.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/data.ts.vm new file mode 100644 index 000000000..9f356f684 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/data.ts.vm @@ -0,0 +1,349 @@ +import type { VxeTableGridOptions } from '@vben/plugins/vxe-table'; +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn } from '#/adapter/vxe-table'; +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; + +import { z } from '#/adapter/form'; +#if(${table.templateType} == 2)## 树表需要导入这些 +import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; +import { handleTree } from '#/utils/tree'; +#end +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; +import { getRangePickerDefaultProps } from '#/utils/date'; +import { useAccess } from '@vben/access'; + +const { hasAccessByCodes } = useAccess(); + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ +#foreach($column in $columns) +#if ($column.listOperation) + #set ($dictType = $column.dictType) + #set ($javaType = $column.javaType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") + #set ($dictMethod = "number") + #elseif ($javaType == "String") + #set ($dictMethod = "string") + #elseif ($javaType == "Boolean") + #set ($dictMethod = "boolean") + #end + { + fieldName: '${javaField}', + label: '${comment}', + #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor") + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入${comment}', + }, + #elseif ($column.htmlType == "select" || $column.htmlType == "radio") + component: 'Select', + componentProps: { + allowClear: true, + #if ("" != $dictType)## 设置了 dictType 数据字典的情况 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), + #else## 未设置 dictType 数据字典的情况 + options: [], + #end + placeholder: '请选择${comment}', + }, + #elseif($column.htmlType == "datetime") + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + #end + }, +#end +#end + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>, +): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] { + return [ +#if ($table.templateType == 12) ## 内嵌情况 + { type: 'expand', width: 80, slots: { content: 'expand_content' } }, +#end +#foreach($column in $columns) +#if ($column.listOperationResult) + #set ($dictType = $column.dictType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + { + field: '${javaField}', + title: '${comment}', + minWidth: 120, + #if ($column.javaType == "LocalDateTime")## 时间类型 + formatter: 'formatDateTime', + #elseif("" != $dictType)## 数据字典 + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.$dictType.toUpperCase() }, + }, + #end + #if (${table.templateType} == 2 && $column.id == $treeNameColumn.id)## 树表特有:标记树节点列 + treeNode: true, + #end + }, +#end +#end + { + field: 'operation', + title: '操作', + minWidth: 200, + align: 'center', + fixed: 'right', + headerAlign: 'center', + showOverflow: false, + cellRender: { + attrs: { + nameField: '${columns[0].javaField}', + nameTitle: '${table.classComment}', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ +#if (${table.templateType} == 2)## 树表特有操作 + { + code: 'append', + text: '新增下级', + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:create']), + }, +#end + { + code: 'edit', + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']), + }, + { + code: 'delete', + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']), +#if (${table.templateType} == 2)## 树表禁止删除带有子节点的数据 + disabled: (row: ${simpleClassName}Api.${simpleClassName}) => { + return !!(row.children && row.children.length > 0); + }, +#end + }, + ], + }, + }, + ]; +} + +## 标准模式和内嵌模式时,主子关系一对一则生成表单schema,一对多则生成列表schema(内嵌模式时表单schema也要生成)。erp 模式时都生成 +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) + #set ($index = $foreach.count - 1) + #set ($subColumns = $subColumnsList.get($index))##当前字段数组 + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) +// ==================== 子表($subTable.classComment) ==================== + +#if ($table.templateType == 11) ## erp 情况 +/** 列表的搜索表单 */ +export function use${subSimpleClassName}GridFormSchema(): VbenFormSchema[] { + return [ + #foreach($column in $subColumns) + #if ($column.listOperation) + #set ($dictType = $column.dictType) + #set ($javaType = $column.javaType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") + #set ($dictMethod = "number") + #elseif ($javaType == "String") + #set ($dictMethod = "string") + #elseif ($javaType == "Boolean") + #set ($dictMethod = "boolean") + #end + { + fieldName: '${javaField}', + label: '${comment}', + #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor") + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入${comment}', + }, + #elseif ($column.htmlType == "select" || $column.htmlType == "radio") + component: 'Select', + componentProps: { + allowClear: true, + #if ("" != $dictType)## 设置了 dictType 数据字典的情况 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), + #else## 未设置 dictType 数据字典的情况 + options: [], + #end + placeholder: '请选择${comment}', + }, + #elseif($column.htmlType == "datetime") + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + #end + }, + #end + #end + ]; +} + +/** 列表的字段 */ +export function use${subSimpleClassName}GridColumns( + onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, +): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] { + return [ + #foreach($column in $subColumns) + #if ($column.listOperationResult) + #set ($dictType = $column.dictType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + { + field: '${javaField}', + title: '${comment}', + minWidth: 120, + #if ($column.javaType == "LocalDateTime")## 时间类型 + formatter: 'formatDateTime', + #elseif("" != $dictType)## 数据字典 + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.$dictType.toUpperCase() }, + }, + #end + }, + #end + #end + { + field: 'operation', + title: '操作', + minWidth: 200, + align: 'center', + fixed: 'right', + headerAlign: 'center', + showOverflow: false, + cellRender: { + attrs: { + nameField: '${columns[0].javaField}', + nameTitle: '${subTable.classComment}', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'edit', + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']), + }, + { + code: 'delete', + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']), + }, + ], + }, + }, + ]; +} + +#else + #if ($subTable.subJoinMany) ## 一对多 + /** 新增/修改列表的字段 */ + export function use${subSimpleClassName}GridEditColumns( + onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, + ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] { + return [ + #foreach($column in $subColumns) + #if ($column.createOperation || $column.updateOperation) + #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写 + #set ($dictType = $column.dictType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") + #set ($dictMethod = "number") + #elseif ($javaType == "String") + #set ($dictMethod = "string") + #elseif ($javaType == "Boolean") + #set ($dictMethod = "boolean") + #end + { + field: '${javaField}', + title: '${comment}', + minWidth: 120, + slots: { default: '${javaField}' }, + #if ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio") + #if ("" != $dictType)## 有数据字典 + params: { + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), + }, + #else + params: { + options: [], + }, + #end + #end + }, + #end + #end + #end + { + field: 'operation', + title: '操作', + minWidth: 60, + align: 'center', + fixed: 'right', + headerAlign: 'center', + showOverflow: false, + cellRender: { + attrs: { + nameField: '${columns[0].javaField}', + nameTitle: '${table.classComment}', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'delete', + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']), + }, + ], + }, + }, + ]; + } + #end + #if ($table.templateType == 12) ## 内嵌情况 + /** 列表的字段 */ + export function use${subSimpleClassName}GridColumns(): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] { + return [ + #foreach($column in $subColumns) + #if ($column.listOperationResult) + #set ($dictType = $column.dictType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + { + field: '${javaField}', + title: '${comment}', + minWidth: 120, + #if ($column.javaType == "LocalDateTime")## 时间类型 + formatter: 'formatDateTime', + #elseif("" != $dictType)## 数据字典 + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.$dictType.toUpperCase() }, + }, + #end + }, + #end + #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_vben5_antd/general/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/form.vue.vm new file mode 100644 index 000000000..281df2479 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/form.vue.vm @@ -0,0 +1,313 @@ + + +