Skip to content

Commit 7739c2a

Browse files
committed
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-cloud
# Conflicts: # yudao-module-mall/yudao-module-promotion-server/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java # yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImpl.java
2 parents cad6da4 + 0f27c0a commit 7739c2a

File tree

41 files changed

+2853
-1396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2853
-1396
lines changed

sql/postgresql/ruoyi-vue-pro.sql

Lines changed: 1257 additions & 1335 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,85 @@
11
package cn.iocoder.yudao.framework.common.util.json.databind;
22

3+
import cn.hutool.core.util.ObjUtil;
34
import cn.hutool.core.util.ReflectUtil;
5+
import cn.hutool.core.util.StrUtil;
46
import com.fasterxml.jackson.annotation.JsonFormat;
7+
import com.fasterxml.jackson.annotation.JsonProperty;
58
import com.fasterxml.jackson.core.JsonGenerator;
69
import com.fasterxml.jackson.databind.JsonSerializer;
710
import com.fasterxml.jackson.databind.SerializerProvider;
11+
import lombok.extern.slf4j.Slf4j;
812

913
import java.io.IOException;
1014
import java.lang.reflect.Field;
1115
import java.time.LocalDateTime;
1216
import java.time.ZoneId;
1317
import java.time.format.DateTimeFormatter;
18+
import java.util.HashMap;
19+
import java.util.Map;
20+
import java.util.concurrent.ConcurrentHashMap;
1421

1522
/**
1623
* 基于时间戳的 LocalDateTime 序列化器
1724
*
1825
* @author 老五
1926
*/
27+
@Slf4j
2028
public class TimestampLocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
2129

2230
public static final TimestampLocalDateTimeSerializer INSTANCE = new TimestampLocalDateTimeSerializer();
2331

32+
private static final Map<Class<?>, Map<String, Field>> FIELD_CACHE = new ConcurrentHashMap<>();
33+
2434
@Override
2535
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
2636
// 情况一:有 JsonFormat 自定义注解,则使用它。https://github.com/YunaiV/ruoyi-vue-pro/pull/1019
2737
String fieldName = gen.getOutputContext().getCurrentName();
2838
if (fieldName != null) {
29-
Class<?> clazz = gen.getOutputContext().getCurrentValue().getClass();
30-
Field field = ReflectUtil.getField(clazz, fieldName);
31-
JsonFormat[] jsonFormats = field.getAnnotationsByType(JsonFormat.class);
32-
if (jsonFormats.length > 0) {
33-
String pattern = jsonFormats[0].pattern();
34-
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
35-
gen.writeString(formatter.format(value));
36-
return;
39+
Object currentValue = gen.getOutputContext().getCurrentValue();
40+
if (currentValue != null) {
41+
Class<?> clazz = currentValue.getClass();
42+
Map<String, Field> fieldMap = FIELD_CACHE.computeIfAbsent(clazz, this::buildFieldMap);
43+
Field field = fieldMap.get(fieldName);
44+
// 进一步修复:https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1480
45+
if (field != null && field.isAnnotationPresent(JsonFormat.class)) {
46+
JsonFormat jsonFormat = field.getAnnotation(JsonFormat.class);
47+
try {
48+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(jsonFormat.pattern());
49+
gen.writeString(formatter.format(value));
50+
return;
51+
} catch (Exception ex) {
52+
log.warn("[serialize][({}#{}) 使用 JsonFormat pattern 失败,尝试使用默认的 Long 时间戳]",
53+
clazz.getName(), fieldName, ex);
54+
}
55+
}
3756
}
3857
}
3958

4059
// 情况二:默认将 LocalDateTime 对象,转换为 Long 时间戳
4160
gen.writeNumber(value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
4261
}
4362

63+
/**
64+
* 构建字段映射(缓存)
65+
*
66+
* @param clazz 类
67+
* @return 字段映射
68+
*/
69+
private Map<String, Field> buildFieldMap(Class<?> clazz) {
70+
Map<String, Field> fieldMap = new HashMap<>();
71+
for (Field field : ReflectUtil.getFields(clazz)) {
72+
String fieldName = field.getName();
73+
JsonProperty jsonProperty = field.getAnnotation(JsonProperty.class);
74+
if (jsonProperty != null) {
75+
String value = jsonProperty.value();
76+
if (StrUtil.isNotEmpty(value) && ObjUtil.notEqual("\u0000", value)) {
77+
fieldName = value;
78+
}
79+
}
80+
fieldMap.put(fieldName, field);
81+
}
82+
return fieldMap;
83+
}
84+
4485
}

yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public CommonResult<PageResult<BpmTaskRespVO>> getTaskDonePage(@Valid BpmTaskPag
100100

101101
@GetMapping("manager-page")
102102
@Operation(summary = "获取全部任务的分页", description = "用于【流程任务】菜单")
103-
@PreAuthorize("@ss.hasPermission('bpm:task:mananger-query')")
103+
@PreAuthorize("@ss.hasPermission('bpm:task:manager-query')")
104104
public CommonResult<PageResult<BpmTaskRespVO>> getTaskManagerPage(@Valid BpmTaskPageReqVO pageVO) {
105105
PageResult<HistoricTaskInstance> pageResult = taskService.getTaskPage(getLoginUserId(), pageVO);
106106
if (CollUtil.isEmpty(pageResult.getList())) {

yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehav
3434
public BpmParallelMultiInstanceBehavior(Activity activity,
3535
AbstractBpmnActivityBehavior innerActivityBehavior) {
3636
super(activity, innerActivityBehavior);
37+
// 关联 Pull Request:https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1483
38+
// 在解析/构造阶段基于 activityId 初始化与 activity 绑定且不变的字段,避免在运行期修改 Behavior 实例状态
39+
super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的
40+
super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(activity.getId());
41+
// 从 execution.getVariable() 读取当前所有任务处理的人的 key
42+
super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(activity.getId());
3743
}
3844

3945
/**

yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceB
3030

3131
public BpmSequentialMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior) {
3232
super(activity, innerActivityBehavior);
33+
// 关联 Pull Request:https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1483
34+
// 在解析/构造阶段基于 activityId 初始化与 activity 绑定且不变的字段,避免在运行期修改 Behavior 实例状态
35+
super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的
36+
super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(activity.getId());
37+
// 从 execution.getVariable() 读取当前所有任务处理的人的 key
38+
super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(activity.getId());
3339
}
3440

3541
/**
@@ -88,10 +94,6 @@ protected void executeOriginalBehavior(DelegateExecution execution, ExecutionEnt
8894
super.executeOriginalBehavior(execution, multiInstanceRootExecution, loopCounter);
8995
return;
9096
}
91-
// 参见 https://gitee.com/zhijiantianya/yudao-cloud/issues/IC239F
92-
super.collectionExpression = null;
93-
super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId());
94-
super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId());
9597
super.executeOriginalBehavior(execution, multiInstanceRootExecution, loopCounter);
9698
}
9799

yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public Set<Long> calculateUsersByTask(DelegateExecution execution) {
125125
});
126126
}
127127

128+
@DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致找不到候选人
128129
public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId,
129130
Long startUserId, String processDefinitionId, Map<String, Object> processVariables) {
130131
// 如果是 CallActivity 子流程,不进行计算候选人

yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmCopyTaskDelegate.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import cn.hutool.core.collection.CollUtil;
44
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
5+
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
56
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceCopyService;
67
import org.flowable.bpmn.model.FlowElement;
78
import org.flowable.engine.delegate.DelegateExecution;
@@ -40,8 +41,9 @@ public void execute(DelegateExecution execution) {
4041
}
4142
// 2. 执行抄送
4243
FlowElement currentFlowElement = execution.getCurrentFlowElement();
43-
processInstanceCopyService.createProcessInstanceCopy(userIds, null, execution.getProcessInstanceId(),
44-
currentFlowElement.getId(), currentFlowElement.getName(), null);
44+
FlowableUtils.execute(execution.getTenantId(), () ->
45+
processInstanceCopyService.createProcessInstanceCopy(userIds, null, execution.getProcessInstanceId(),
46+
currentFlowElement.getId(), currentFlowElement.getName(), null));
4547
}
4648

4749
}

yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenFrontTypeEnum.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public enum CodegenFrontTypeEnum {
2323

2424
VUE3_VBEN5_EP_SCHEMA(50), // Vue3 VBEN5 + EP + schema 模版
2525
VUE3_VBEN5_EP_GENERAL(51), // Vue3 VBEN5 + EP 标准模版
26+
27+
VUE3_ADMIN_UNIAPP_WOT(60), // Vue3 Admin + Uniapp + WOT 标准模版
2628
;
2729

2830
/**

yudao-module-infra/yudao-module-infra-server/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createR
7272
return success(fileService.createFile(createReqVO));
7373
}
7474

75+
@GetMapping("/get")
76+
@Operation(summary = "获得文件")
77+
@Parameter(name = "id", description = "编号", required = true)
78+
@PreAuthorize("@ss.hasPermission('infra:file:query')")
79+
public CommonResult<FileRespVO> getFile(@RequestParam("id") Long id) {
80+
return success(BeanUtils.toBean(fileService.getFile(id), FileRespVO.class));
81+
}
82+
7583
@DeleteMapping("/delete")
7684
@Operation(summary = "删除文件")
7785
@Parameter(name = "id", description = "编号", required = true)

yudao-module-infra/yudao-module-infra-server/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
import cn.hutool.core.util.StrUtil;
55
import cn.iocoder.yudao.framework.common.pojo.PageResult;
66
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
7+
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
78
import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenCreateListReqVO;
89
import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenUpdateReqVO;
910
import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTablePageReqVO;
1011
import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.DatabaseTableRespVO;
1112
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
1213
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
14+
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
1315
import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenColumnMapper;
1416
import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper;
1517
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
1618
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
1719
import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
1820
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
1921
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
22+
import cn.iocoder.yudao.module.infra.service.db.DataSourceConfigService;
2023
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
24+
import com.baomidou.mybatisplus.annotation.DbType;
2125
import com.baomidou.mybatisplus.generator.config.po.TableField;
2226
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
2327
import com.google.common.annotations.VisibleForTesting;
@@ -45,6 +49,8 @@ public class CodegenServiceImpl implements CodegenService {
4549

4650
@Resource
4751
private DatabaseTableService databaseTableService;
52+
@Resource
53+
private DataSourceConfigService dataSourceConfigService;
4854

4955
@Resource
5056
private CodegenTableMapper codegenTableMapper;
@@ -284,8 +290,11 @@ public Map<String, String> generationCodes(Long tableId) {
284290
}
285291
}
286292

293+
// 获取数据源对应的数据库类型
294+
DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(table.getDataSourceConfigId());
295+
DbType dbType = JdbcUtils.getDbType(dataSourceConfig.getUrl());
287296
// 执行生成
288-
return codegenEngine.execute(table, columns, subTables, subColumnsList);
297+
return codegenEngine.execute(dbType, table, columns, subTables, subColumnsList);
289298
}
290299

291300
@Override

0 commit comments

Comments
 (0)