【同步】BOOT 和 CLOUD 的功能
parent
04bd6bff04
commit
103685269e
|
|
@ -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 (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 (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 (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;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import java.util.function.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static cn.hutool.core.convert.Convert.toCollection;
|
||||||
import static java.util.Arrays.asList;
|
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());
|
return list.stream().filter(Objects::nonNull).flatMap(Collection::stream).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换为 LinkedHashSet
|
||||||
|
*
|
||||||
|
* @param <T> 元素类型
|
||||||
|
* @param elementType 集合中元素类型
|
||||||
|
* @param value 被转换的值
|
||||||
|
* @return {@link LinkedHashSet}
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> LinkedHashSet<T> toLinkedHashSet(Class<T> elementType, Object value) {
|
||||||
|
return (LinkedHashSet<T>) toCollection(LinkedHashSet.class, elementType, value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import cn.hutool.system.SystemUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.DocumentEnum;
|
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.RedisMQTemplate;
|
||||||
import cn.iocoder.yudao.framework.mq.redis.core.job.RedisPendingMessageResendJob;
|
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.pubsub.AbstractRedisChannelMessageListener;
|
||||||
import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
|
import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
|
||||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||||
|
|
@ -73,6 +74,17 @@ public class YudaoRedisMQConsumerAutoConfiguration {
|
||||||
return new RedisPendingMessageResendJob(listeners, redisTemplate, groupName, redissonClient);
|
return new RedisPendingMessageResendJob(listeners, redisTemplate, groupName, redissonClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 Redis Stream 消息清理任务
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnBean(AbstractRedisStreamMessageListener.class)
|
||||||
|
public RedisStreamMessageCleanupJob redisStreamMessageCleanupJob(List<AbstractRedisStreamMessageListener<?>> listeners,
|
||||||
|
RedisMQTemplate redisTemplate,
|
||||||
|
RedissonClient redissonClient) {
|
||||||
|
return new RedisStreamMessageCleanupJob(listeners, redisTemplate, redissonClient);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 Redis Stream 集群消费的容器
|
* 创建 Redis Stream 集群消费的容器
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ import java.util.Objects;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class RedisPendingMessageResendJob {
|
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 分钟
|
* 消息超时时间,默认 5 分钟
|
||||||
*
|
*
|
||||||
* 1. 超时的消息才会被重新投递
|
* 1. 超时的消息才会被重新投递
|
||||||
* 2. 由于定时任务 1 分钟一次,消息超时后不会被立即重投,极端情况下消息5分钟过期后,再等 1 分钟才会被扫瞄到
|
* 2. 由于定时任务 1 分钟一次,消息超时后不会被立即重投,极端情况下消息 5 分钟过期后,再等 1 分钟才会被扫瞄到
|
||||||
*/
|
*/
|
||||||
private static final int EXPIRE_TIME = 5 * 60;
|
private static final int EXPIRE_TIME = 5 * 60;
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ public class RedisPendingMessageResendJob {
|
||||||
private final RedissonClient redissonClient;
|
private final RedissonClient redissonClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一分钟执行一次,这里选择每分钟的35秒执行,是为了避免整点任务过多的问题
|
* 一分钟执行一次,这里选择每分钟的 35 秒执行,是为了避免整点任务过多的问题
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "35 * * * * ?")
|
@Scheduled(cron = "35 * * * * ?")
|
||||||
public void messageResend() {
|
public void messageResend() {
|
||||||
|
|
|
||||||
|
|
@ -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 <a href="https://www.cnblogs.com/nanxiang/p/16179519.html">记一次 redis stream 数据类型内存不释放问题</a>
|
||||||
|
*
|
||||||
|
* @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<AbstractRedisStreamMessageListener<?>> 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<String, Object, Object> 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.form;
|
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.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.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.user.BpmTaskCandidateUserStrategy;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.user.BpmTaskCandidateUserStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
|
|
@ -33,7 +33,7 @@ public class BpmTaskCandidateFormUserStrategy implements BpmTaskCandidateStrateg
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
|
public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
|
||||||
Object result = execution.getVariable(param);
|
Object result = execution.getVariable(param);
|
||||||
return Convert.toSet(Long.class, result);
|
return CollectionUtils.toLinkedHashSet(Long.class, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -41,7 +41,7 @@ public class BpmTaskCandidateFormUserStrategy implements BpmTaskCandidateStrateg
|
||||||
String param, Long startUserId, String processDefinitionId,
|
String param, Long startUserId, String processDefinitionId,
|
||||||
Map<String, Object> processVariables) {
|
Map<String, Object> processVariables) {
|
||||||
Object result = processVariables == null ? null : processVariables.get(param);
|
Object result = processVariables == null ? null : processVariables.get(param);
|
||||||
return Convert.toSet(Long.class, result);
|
return CollectionUtils.toLinkedHashSet(Long.class, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.other;
|
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.candidate.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||||
|
|
@ -37,7 +37,7 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
|
public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
|
||||||
Object result = FlowableUtils.getExpressionValue(execution, param);
|
Object result = FlowableUtils.getExpressionValue(execution, param);
|
||||||
return Convert.toSet(Long.class, result);
|
return CollectionUtils.toLinkedHashSet(Long.class, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -46,7 +46,7 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat
|
||||||
Map<String, Object> variables = processVariables == null ? new HashMap<>() : processVariables;
|
Map<String, Object> variables = processVariables == null ? new HashMap<>() : processVariables;
|
||||||
try {
|
try {
|
||||||
Object result = FlowableUtils.getExpressionValue(variables, param);
|
Object result = FlowableUtils.getExpressionValue(variables, param);
|
||||||
return Convert.toSet(Long.class, result);
|
return CollectionUtils.toLinkedHashSet(Long.class, result);
|
||||||
} catch (FlowableException ex) {
|
} catch (FlowableException ex) {
|
||||||
// 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常,
|
// 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常,
|
||||||
log.warn("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex);
|
log.warn("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex);
|
||||||
|
|
|
||||||
|
|
@ -873,12 +873,14 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
List<UserTask> returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null);
|
List<UserTask> returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null);
|
||||||
List<String> returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId);
|
List<String> returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId);
|
||||||
|
|
||||||
|
List<String> runExecutionIds = new ArrayList<>();
|
||||||
// 2. 给当前要被退回的 task 数组,设置退回意见
|
// 2. 给当前要被退回的 task 数组,设置退回意见
|
||||||
taskList.forEach(task -> {
|
taskList.forEach(task -> {
|
||||||
// 需要排除掉,不需要设置退回意见的任务
|
// 需要排除掉,不需要设置退回意见的任务
|
||||||
if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) {
|
if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
runExecutionIds.add(task.getExecutionId());
|
||||||
|
|
||||||
// 判断是否分配给自己任务,因为会签任务,一个节点会有多个任务
|
// 判断是否分配给自己任务,因为会签任务,一个节点会有多个任务
|
||||||
if (isAssignUserTask(userId, task)) { // 情况一:自己的任务,进行 RETURN 标记
|
if (isAssignUserTask(userId, task)) { // 情况一:自己的任务,进行 RETURN 标记
|
||||||
|
|
@ -898,7 +900,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
// 4. 执行驳回
|
// 4. 执行驳回
|
||||||
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
||||||
// 当多实例任务回退的时候有问题。相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
// 当多实例任务回退的时候有问题。相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
||||||
List<String> runExecutionIds = convertList(taskList, Task::getExecutionId);
|
|
||||||
runtimeService.createChangeActivityStateBuilder()
|
runtimeService.createChangeActivityStateBuilder()
|
||||||
.processInstanceId(currentTask.getProcessInstanceId())
|
.processInstanceId(currentTask.getProcessInstanceId())
|
||||||
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,14 @@ import lombok.Getter;
|
||||||
public enum CodegenFrontTypeEnum {
|
public enum CodegenFrontTypeEnum {
|
||||||
|
|
||||||
VUE2_ELEMENT_UI(10), // Vue2 Element UI 标准模版
|
VUE2_ELEMENT_UI(10), // Vue2 Element UI 标准模版
|
||||||
|
|
||||||
VUE3_ELEMENT_PLUS(20), // Vue3 Element Plus 标准模版
|
VUE3_ELEMENT_PLUS(20), // Vue3 Element Plus 标准模版
|
||||||
|
|
||||||
VUE3_VBEN2_ANTD_SCHEMA(30), // Vue3 VBEN2 + ANTD + Schema 模版
|
VUE3_VBEN2_ANTD_SCHEMA(30), // Vue3 VBEN2 + ANTD + Schema 模版
|
||||||
|
|
||||||
VUE3_VBEN5_ANTD_SCHEMA(40), // Vue3 VBEN5 + ANTD + schema 模版
|
VUE3_VBEN5_ANTD_SCHEMA(40), // Vue3 VBEN5 + ANTD + schema 模版
|
||||||
|
|
||||||
|
VUE3_VBEN5_ANTD_GENERAL(41), // Vue3 VBEN5 + ANTD 标准模版
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,9 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||||
AwsBasicCredentials.create(config.getAccessKey(), config.getAccessSecret()));
|
AwsBasicCredentials.create(config.getAccessKey(), config.getAccessSecret()));
|
||||||
URI endpoint = URI.create(buildEndpoint());
|
URI endpoint = URI.create(buildEndpoint());
|
||||||
S3Configuration serviceConfiguration = S3Configuration.builder() // Path-style 访问
|
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()
|
client = S3Client.builder()
|
||||||
.credentialsProvider(credentialsProvider)
|
.credentialsProvider(credentialsProvider)
|
||||||
.region(region)
|
.region(region)
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,25 @@ public class CodegenEngine {
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
|
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"), // 特殊:主子表专属逻辑
|
.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"))
|
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();
|
.build();
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,313 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
import type { Rule } from 'ant-design-vue/es/form';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||||
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
|
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
#if($table.templateType == 2)## 树表需要导入这些
|
||||||
|
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
import { handleTree } from '#/utils/tree';
|
||||||
|
#end
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
|
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
||||||
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formRef = ref();
|
||||||
|
const labelCol = { span: 5 };
|
||||||
|
const wrapperCol = { span: 13 };
|
||||||
|
const formData = ref<Partial<${simpleClassName}Api.${simpleClassName}>>({
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
#if ($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: [],
|
||||||
|
#else
|
||||||
|
$column.javaField: undefined,
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
});
|
||||||
|
const rules: Record<string, Rule[]> = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
$column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }],
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
};
|
||||||
|
## 特殊:树表专属逻辑
|
||||||
|
#if ( $table.templateType == 2 )
|
||||||
|
const ${classNameVar}Tree = ref<any[]>([]) // 树形结构
|
||||||
|
#end
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.id
|
||||||
|
? $t('ui.actionTitle.edit', ['${table.classComment}'])
|
||||||
|
: $t('ui.actionTitle.create', ['${table.classComment}']);
|
||||||
|
});
|
||||||
|
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
|
#if ( $subTables && $subTables.size() > 0 )
|
||||||
|
/** 子表的表单 */
|
||||||
|
const subTabsName = ref('$subClassNameVars.get(0)')
|
||||||
|
#foreach ($subClassNameVar in $subClassNameVars)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||||
|
const ${subClassNameVar}FormRef = ref<InstanceType<typeof ${subSimpleClassName}Form>>()
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
#if ($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: [],
|
||||||
|
#else
|
||||||
|
$column.javaField: undefined,
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
};
|
||||||
|
formRef.value?.resetFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
## 特殊:树表专属逻辑
|
||||||
|
#if ( $table.templateType == 2 )
|
||||||
|
/** 获得${table.classComment}树 */
|
||||||
|
const get${simpleClassName}Tree = async () => {
|
||||||
|
${classNameVar}Tree.value = []
|
||||||
|
const data = await get${simpleClassName}List()
|
||||||
|
const root: Tree = { id: 0, name: '顶级${table.classComment}', children: [] }
|
||||||
|
root.children = handleTree(data, 'id', '${treeParentColumn.javaField}')
|
||||||
|
${classNameVar}Tree.value.push(root)
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
|
#if ( $subTables && $subTables.size() > 0 )
|
||||||
|
// 校验子表单
|
||||||
|
#foreach ($subTable in $subTables)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
## TODO 列表值校验?
|
||||||
|
#else
|
||||||
|
const ${subClassNameVar}Valid = await ${subClassNameVar}FormRef.value?.validate();
|
||||||
|
if (!${subClassNameVar}Valid) {
|
||||||
|
subTabsName.value = '${subClassNameVar}';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = formData.value as ${simpleClassName}Api.${simpleClassName};
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
|
#if ( $subTables && $subTables.size() > 0 )
|
||||||
|
// 拼接子表的数据
|
||||||
|
#foreach ($subTable in $subTables)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
#if ($subTable.subJoinMany)
|
||||||
|
data.${subClassNameVar}s = ${subClassNameVar}FormRef.value?.getData();
|
||||||
|
#else
|
||||||
|
data.${subClassNameVar} = await ${subClassNameVar}FormRef.value?.getValues();
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
try {
|
||||||
|
await (formData.value?.id ? update${simpleClassName}(data) : create${simpleClassName}(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.operationSuccess'),
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
resetForm()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
data = await get${simpleClassName}(data.id);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
formData.value = data;
|
||||||
|
#if ( $table.templateType == 2 )
|
||||||
|
// 加载树数据
|
||||||
|
await get${simpleClassName}Tree()
|
||||||
|
#end
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle">
|
||||||
|
<Form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="rules"
|
||||||
|
:label-col="labelCol"
|
||||||
|
:wrapper-col="wrapperCol"
|
||||||
|
>
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
#set ($dictType = $column.dictType)
|
||||||
|
#set ($javaField = $column.javaField)
|
||||||
|
#set ($javaType = $column.javaType)
|
||||||
|
#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
|
||||||
|
#if ( $table.templateType == 2 && $column.id == $treeParentColumn.id )
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<TreeSelect
|
||||||
|
v-model:value="formData.${javaField}"
|
||||||
|
:treeData="${classNameVar}Tree"
|
||||||
|
#if ($treeNameColumn.javaField == "name")
|
||||||
|
:fieldNames="defaultProps"
|
||||||
|
#else
|
||||||
|
:fieldNames="{...defaultProps, label: '$treeNameColumn.javaField'}"
|
||||||
|
#end
|
||||||
|
checkable
|
||||||
|
treeDefaultExpandAll
|
||||||
|
placeholder="请选择${comment}"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<Input v-model:value="formData.${javaField}" placeholder="请输入${comment}" />
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<ImageUpload v-model:value="formData.${javaField}" />
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<FileUpload v-model:value="formData.${javaField}" />
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<RichTextarea v-model="formData.${javaField}" height="500px" />
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<Select v-model:value="formData.${javaField}" placeholder="请选择${comment}">
|
||||||
|
#if ("" != $dictType)## 有数据字典
|
||||||
|
<Select.Option
|
||||||
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
#else##没数据字典
|
||||||
|
<Select.Option label="请选择字典生成" value="" />
|
||||||
|
#end
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "checkbox")## 多选框
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<CheckboxGroup v-model:value="formData.${javaField}">
|
||||||
|
#if ("" != $dictType)## 有数据字典
|
||||||
|
<Checkbox
|
||||||
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
#else##没数据字典
|
||||||
|
<Checkbox label="请选择字典生成" />
|
||||||
|
#end
|
||||||
|
</CheckboxGroup>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "radio")## 单选框
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<RadioGroup v-model:value="formData.${javaField}">
|
||||||
|
#if ("" != $dictType)## 有数据字典
|
||||||
|
<Radio
|
||||||
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
|
:key="dict.value"
|
||||||
|
:value="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</Radio>
|
||||||
|
#else##没数据字典
|
||||||
|
<Radio value="1">请选择字典生成</Radio>
|
||||||
|
#end
|
||||||
|
</RadioGroup>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "datetime")## 时间框
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<DatePicker
|
||||||
|
v-model:value="formData.${javaField}"
|
||||||
|
valueFormat="x"
|
||||||
|
placeholder="选择${comment}"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "textarea")## 文本框
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<Textarea v-model:value="formData.${javaField}" placeholder="请输入${comment}" />
|
||||||
|
</Form.Item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</Form>
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
|
<!-- 子表的表单 -->
|
||||||
|
<Tabs v-model:active-key="subTabsName">
|
||||||
|
#foreach ($subTable in $subTables)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||||
|
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
||||||
|
<Tabs.TabPane key="$subClassNameVar" tab="${subTable.classComment}" force-render>
|
||||||
|
<${subSimpleClassName}Form ref="${subClassNameVar}FormRef" :${subJoinColumn_strikeCase}="formData?.id" />
|
||||||
|
</Tabs.TabPane>
|
||||||
|
#end
|
||||||
|
</Tabs>
|
||||||
|
#end
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,357 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import ${simpleClassName}Form from './modules/form.vue';
|
||||||
|
import { Download, Plus, RefreshCw, Search } from '@vben/icons';
|
||||||
|
import { ContentWrap } from "#/components/content-wrap";
|
||||||
|
import { VxeColumn, VxeTable } from 'vxe-table';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 11 || $table.templateType == 12 )
|
||||||
|
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
||||||
|
import ${subSimpleClassName}List from './modules/${subSimpleClassName_strikeCase}-list.vue'
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
import { ref, h, reactive,onMounted } from 'vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
#if (${table.templateType} == 2)## 树表接口
|
||||||
|
import { handleTree } from '@/utils/tree'
|
||||||
|
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#else## 标准表接口
|
||||||
|
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#end
|
||||||
|
import { downloadByData } from '#/utils/download';
|
||||||
|
|
||||||
|
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
|
||||||
|
/** 子表的列表 */
|
||||||
|
const subTabsName = ref('$subClassNameVars.get(0)')
|
||||||
|
#if ($table.templateType == 11)
|
||||||
|
const select${simpleClassName} = ref<${simpleClassName}Api.${simpleClassName}>();
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<${simpleClassName}Api.${simpleClassName}[]>([]) // 列表的数据
|
||||||
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
|
#if ( $table.templateType != 2 )
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
#end
|
||||||
|
const queryParams = reactive({
|
||||||
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
|
#if ( $table.templateType != 2 )
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if ($column.listOperation)
|
||||||
|
#if ($column.listOperationCondition != 'BETWEEN')
|
||||||
|
$column.javaField: undefined,
|
||||||
|
#end
|
||||||
|
#if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
|
||||||
|
$column.javaField: undefined,
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
|
#if ( $table.templateType == 2 )
|
||||||
|
const data = await get${simpleClassName}List(queryParams)
|
||||||
|
list.value = handleTree(data, 'id', '${treeParentColumn.javaField}')
|
||||||
|
#else
|
||||||
|
const data = await get${simpleClassName}Page(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
#end
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: ${simpleClassName}Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 创建${table.classComment} */
|
||||||
|
function onCreate() {
|
||||||
|
formModalApi.setData({}).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑${table.classComment} */
|
||||||
|
function onEdit(row: ${simpleClassName}Api.${simpleClassName}) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (${table.templateType} == 2)## 树表特有:新增下级
|
||||||
|
/** 新增下级${table.classComment} */
|
||||||
|
function onAppend(row: ${simpleClassName}Api.${simpleClassName}) {
|
||||||
|
formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open();
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
/** 删除${table.classComment} */
|
||||||
|
async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await delete${simpleClassName}(row.id as number);
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
await getList();
|
||||||
|
} catch {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function onExport() {
|
||||||
|
try {
|
||||||
|
exportLoading.value = true;
|
||||||
|
const data = await export${simpleClassName}(queryParams);
|
||||||
|
downloadByData(data, '${table.classComment}.xls');
|
||||||
|
}finally {
|
||||||
|
exportLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<FormModal @success="getList" />
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<Form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
layout="inline"
|
||||||
|
>
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if ($column.listOperation)
|
||||||
|
#set ($dictType = $column.dictType)
|
||||||
|
#set ($javaField = $column.javaField)
|
||||||
|
#set ($javaType = $column.javaType)
|
||||||
|
#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
|
||||||
|
#if ($column.htmlType == "input")
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<Input
|
||||||
|
v-model:value="queryParams.${javaField}"
|
||||||
|
placeholder="请输入${comment}"
|
||||||
|
allowClear
|
||||||
|
@pressEnter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif ($column.htmlType == "select" || $column.htmlType == "radio" || $column.htmlType == "checkbox")
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<Select
|
||||||
|
v-model:value="queryParams.${javaField}"
|
||||||
|
placeholder="请选择${comment}"
|
||||||
|
allowClear
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
||||||
|
<Select.Option
|
||||||
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
#else## 未设置 dictType 数据字典的情况
|
||||||
|
<Select.Option label="请选择字典生成" value="" />
|
||||||
|
#end
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
#elseif($column.htmlType == "datetime")
|
||||||
|
#if ($column.listOperationCondition != "BETWEEN")## 非范围
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<DatePicker
|
||||||
|
v-model:value="queryParams.${javaField}"
|
||||||
|
valueFormat="YYYY-MM-DD"
|
||||||
|
placeholder="选择${comment}"
|
||||||
|
allowClear
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
#else## 范围
|
||||||
|
<Form.Item label="${comment}" name="${javaField}">
|
||||||
|
<RangePicker
|
||||||
|
v-model:value="queryParams.${javaField}"
|
||||||
|
v-bind="getRangePickerDefaultProps()"
|
||||||
|
class="!w-220px"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<Form.Item>
|
||||||
|
<Button class="ml-2" @click="handleQuery" :icon="h(Search)">搜索</Button>
|
||||||
|
<Button class="ml-2" @click="resetQuery" :icon="h(RefreshCw)">重置</Button>
|
||||||
|
<Button
|
||||||
|
class="ml-2"
|
||||||
|
:icon="h(Plus)"
|
||||||
|
type="primary"
|
||||||
|
@click="onCreate"
|
||||||
|
v-access:code="['${permissionPrefix}:create']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.create', ['示例联系人']) }}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
:icon="h(Download)"
|
||||||
|
type="primary"
|
||||||
|
class="ml-2"
|
||||||
|
:loading="exportLoading"
|
||||||
|
@click="onExport"
|
||||||
|
v-access:code="['${permissionPrefix}:export']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.export') }}
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
|
<vxe-table :data="list" show-overflow :loading="loading">
|
||||||
|
## 特殊:主子表专属逻辑
|
||||||
|
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||||
|
<!-- 子表的列表 -->
|
||||||
|
<vxe-column type="expand" width="60">
|
||||||
|
<template #content="{ row }">
|
||||||
|
<!-- 子表的表单 -->
|
||||||
|
<Tabs v-model:active-key="subTabsName" class="mx-8">
|
||||||
|
#foreach ($subTable in $subTables)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||||
|
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
||||||
|
<Tabs.TabPane key="$subClassNameVar" tab="${subTable.classComment}" force-render>
|
||||||
|
<${subSimpleClassName}List :${subJoinColumn_strikeCase}="row?.id" />
|
||||||
|
</Tabs.TabPane>
|
||||||
|
#end
|
||||||
|
</Tabs>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if ($column.listOperationResult)
|
||||||
|
#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.javaType == "LocalDateTime")## 时间类型
|
||||||
|
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||||
|
<template #default="{row}">
|
||||||
|
{{formatDateTime(row.${javaField})}}
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||||
|
<vxe-column field="${javaField}" title="${comment}" align="center">
|
||||||
|
<template #default="{row}">
|
||||||
|
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
#else
|
||||||
|
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<vxe-column field="operation" title="操作" align="center">
|
||||||
|
<template #default="{row}">
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
@click="onEdit(row as any)"
|
||||||
|
v-access:code="['${permissionPrefix}:update']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.edit') }}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
class="ml-2"
|
||||||
|
@click="onDelete(row as any)"
|
||||||
|
v-access:code="['${permissionPrefix}:delete']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.delete') }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
</vxe-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<div class="mt-2 flex justify-end">
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:current="queryParams.pageNo"
|
||||||
|
v-model:page-size="queryParams.pageSize"
|
||||||
|
show-size-changer
|
||||||
|
@change="getList"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp情况
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 子表的表单 -->
|
||||||
|
<Tabs v-model:active-key="subTabsName">
|
||||||
|
#foreach ($subTable in $subTables)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||||
|
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
||||||
|
<Tabs.TabPane key="$subClassNameVar" tab="${subTable.classComment}" force-render>
|
||||||
|
<${subSimpleClassName}List :${subJoinColumn_strikeCase}="select${simpleClassName}?.id" />
|
||||||
|
</Tabs.TabPane>
|
||||||
|
#end
|
||||||
|
</Tabs>
|
||||||
|
</ContentWrap>
|
||||||
|
#end
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
#set ($subTable = $subTables.get($subIndex))##当前表
|
||||||
|
#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
|
||||||
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
import { use${subSimpleClassName}FormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<${simpleClassName}Api.${subSimpleClassName}>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.id
|
||||||
|
? $t('ui.actionTitle.edit', ['${subTable.classComment}'])
|
||||||
|
: $t('ui.actionTitle.create', ['${subTable.classComment}']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: use${subSimpleClassName}FormSchema(),
|
||||||
|
showDefaultActions: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as ${simpleClassName}Api.${subSimpleClassName};
|
||||||
|
data.${subJoinColumn.javaField} = formData.value?.${subJoinColumn.javaField};
|
||||||
|
try {
|
||||||
|
await (formData.value?.id ? update${subSimpleClassName}(data) : create${subSimpleClassName}(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.operationSuccess'),
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
let data = modalApi.getData<${simpleClassName}Api.${subSimpleClassName}>();
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
data = await get${subSimpleClassName}(data.id);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 设置到 values
|
||||||
|
formData.value = data;
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
## 主表的 normal 和 inner 使用相同的 form 表单
|
||||||
|
#parse("codegen/vue3_vben5_antd/schema/views/modules/form_sub_normal.vue.vm")
|
||||||
|
|
@ -0,0 +1,199 @@
|
||||||
|
#set ($subTable = $subTables.get($subIndex))##当前表
|
||||||
|
#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
|
||||||
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
||||||
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
import { Plus } from "@vben/icons";
|
||||||
|
import { Button, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
||||||
|
import type { OnActionClickParams } from '#/adapter/vxe-table';
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { use${subSimpleClassName}GridEditColumns } from '../data';
|
||||||
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#else
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { use${subSimpleClassName}FormSchema } from '../data';
|
||||||
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#end
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
|
||||||
|
}>()
|
||||||
|
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
/** 表格操作按钮的回调函数 */
|
||||||
|
function onActionClick({
|
||||||
|
code,
|
||||||
|
row,
|
||||||
|
}: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
|
||||||
|
switch (code) {
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: use${subSimpleClassName}GridEditColumns(onActionClick),
|
||||||
|
border: true,
|
||||||
|
showOverflow: true,
|
||||||
|
autoResize: true,
|
||||||
|
keepSource: true,
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 添加${subTable.classComment} */
|
||||||
|
const onAdd = async () => {
|
||||||
|
await gridApi.grid.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除${subTable.classComment} */
|
||||||
|
const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => {
|
||||||
|
await gridApi.grid.remove(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提供获取表格数据的方法供父组件调用 */
|
||||||
|
defineExpose({
|
||||||
|
getData: (): ${simpleClassName}Api.${subSimpleClassName}[] => {
|
||||||
|
const data = gridApi.grid.getData() as ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
|
const removeRecords = gridApi.grid.getRemoveRecords() as ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
|
const insertRecords = gridApi.grid.getInsertRecords() as ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
|
return data
|
||||||
|
.filter((row) => !removeRecords.some((removed) => removed.id === row.id))
|
||||||
|
.concat(insertRecords.map((row: any) => ({ ...row, id: undefined })));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
||||||
|
watch(
|
||||||
|
() => props.${subJoinColumn.javaField},
|
||||||
|
async (val) => {
|
||||||
|
if (!val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await nextTick();
|
||||||
|
await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: use${subSimpleClassName}FormSchema(),
|
||||||
|
showDefaultActions: false
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 暴露出表单校验方法和表单值获取方法 */
|
||||||
|
defineExpose({
|
||||||
|
validate: async () => {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
return valid;
|
||||||
|
},
|
||||||
|
getValues: formApi.getValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
||||||
|
watch(
|
||||||
|
() => props.${subJoinColumn.javaField},
|
||||||
|
async (val) => {
|
||||||
|
if (!val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await nextTick();
|
||||||
|
await formApi.setValues(await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
#end
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
<Grid class="mx-4">
|
||||||
|
#foreach($column in $subColumns)
|
||||||
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
#set ($javaField = $column.javaField)
|
||||||
|
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
||||||
|
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
||||||
|
<template #${javaField}="{ row }">
|
||||||
|
<Input v-model:value="row.${javaField}" />
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||||
|
<template #${javaField}="{ row }">
|
||||||
|
<UploadImg v-model:value="row.${javaField}" />
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||||
|
<template #${javaField}="{ row }">
|
||||||
|
<UploadFile v-model:value="row.${javaField}" />
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
|
<template #${javaField}="{ row }">
|
||||||
|
<Textarea v-model:value="row.${javaField}" />
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
|
<template #${javaField}="{ row, column }">
|
||||||
|
<Select v-model:value="row.${javaField}" class="w-full">
|
||||||
|
<Select.Option v-for="option in column.params.options" :key="option.value" :value="option.value">
|
||||||
|
{{ option.label }}
|
||||||
|
</Select.Option>
|
||||||
|
</Select>
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "checkbox")## 多选框
|
||||||
|
<template #${javaField}="{ row, column }">
|
||||||
|
<CheckboxGroup v-model:value="row.${javaField}" :options="column.params.options" />
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "radio")## 单选框
|
||||||
|
<template #${javaField}="{ row, column }">
|
||||||
|
<RadioGroup v-model:value="row.${javaField}" :options="column.params.options" />
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "datetime")## 时间框
|
||||||
|
<template #${javaField}="{ row }">
|
||||||
|
<DatePicker
|
||||||
|
v-model:value="row.${javaField}"
|
||||||
|
:showTime="true"
|
||||||
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
valueFormat='x'
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
#elseif($column.htmlType == "textarea")## 文本框
|
||||||
|
<template #${javaField}="{ row }">
|
||||||
|
<Textarea v-model:value="row.${javaField}" />
|
||||||
|
</template>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</Grid>
|
||||||
|
<div class="flex justify-center -mt-4">
|
||||||
|
<Button :icon="h(Plus)" type="primary" ghost @click="onAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||||
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
#else
|
||||||
|
<Form class="mx-4" />
|
||||||
|
#end
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,184 @@
|
||||||
|
#set ($subTable = $subTables.get($subIndex))##当前表
|
||||||
|
#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
|
||||||
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
|
||||||
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
|
#end
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
import { Plus } from '@vben/icons';
|
||||||
|
import { #if($table.templateType != 11)ref,#end h, nextTick,watch } from 'vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
import { delete${subSimpleClassName}, get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
|
||||||
|
#else
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#else
|
||||||
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#end
|
||||||
|
import { use${subSimpleClassName}GridColumns } from '../data';
|
||||||
|
#end
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
|
||||||
|
}>()
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: ${subSimpleClassName}Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 创建${subTable.classComment} */
|
||||||
|
function onCreate() {
|
||||||
|
if (!props.${subJoinColumn.javaField}){
|
||||||
|
message.warning("请先选择一个${table.classComment}!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formModalApi.setData({${subJoinColumn.javaField}: props.${subJoinColumn.javaField}}).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑${subTable.classComment} */
|
||||||
|
function onEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除${subTable.classComment} */
|
||||||
|
async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await delete${subSimpleClassName}(row.id as number);
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
onRefresh();
|
||||||
|
} catch {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表格操作按钮的回调函数 */
|
||||||
|
function onActionClick({
|
||||||
|
code,
|
||||||
|
row,
|
||||||
|
}: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
|
||||||
|
switch (code) {
|
||||||
|
case 'edit': {
|
||||||
|
onEdit(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
#if ($table.templateType == 11)
|
||||||
|
formOptions: {
|
||||||
|
schema: use${subSimpleClassName}GridFormSchema(),
|
||||||
|
},
|
||||||
|
#end
|
||||||
|
gridOptions: {
|
||||||
|
#if ($table.templateType == 11)
|
||||||
|
columns: use${subSimpleClassName}GridColumns(onActionClick),
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
if (!props.${subJoinColumn.javaField}){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return await get${subSimpleClassName}Page({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
${subJoinColumn.javaField}: props.${subJoinColumn.javaField},
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
#else
|
||||||
|
columns: use${subSimpleClassName}GridColumns(),
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
#end
|
||||||
|
height: '600px',
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
const onRefresh = async ()=> {
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
await gridApi.query();
|
||||||
|
#else
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
||||||
|
#else
|
||||||
|
await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]);
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
||||||
|
watch(
|
||||||
|
() => props.${subJoinColumn.javaField},
|
||||||
|
async (val) => {
|
||||||
|
if (!val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await nextTick();
|
||||||
|
await onRefresh()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
<FormModal @success="onRefresh" />
|
||||||
|
<Grid table-title="${subTable.classComment}列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||||
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
#else
|
||||||
|
<Grid table-title="${subTable.classComment}列表" />
|
||||||
|
#end
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点:
|
||||||
|
## 1)inner 使用 list 不分页,erp 使用 page 分页
|
||||||
|
## 2)erp 支持单个子表的新增、修改、删除,inner 不支持
|
||||||
|
#parse("codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm")
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
|
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn } from '#/adapter/vxe-table';
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
|
|
@ -40,7 +39,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
});
|
});
|
||||||
return handleTree(data);
|
return handleTree(data);
|
||||||
},
|
},
|
||||||
class: 'w-full',
|
|
||||||
labelField: '${treeNameColumn.javaField}',
|
labelField: '${treeNameColumn.javaField}',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
childrenField: 'children',
|
childrenField: 'children',
|
||||||
|
|
@ -75,18 +73,10 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入${comment}',
|
placeholder: '请输入${comment}',
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "imageUpload")## 图片上传 TODO @puhui999:目前分成了图片和文件上传,可以不用 fileType 之类哈,可以用下;
|
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||||
component: 'FileUpload',
|
component: 'ImageUpload',
|
||||||
componentProps: {
|
|
||||||
fileType: 'image',
|
|
||||||
maxCount: 1,
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||||
component: 'FileUpload',
|
component: 'FileUpload',
|
||||||
componentProps: {
|
|
||||||
fileType: 'file',
|
|
||||||
maxCount: 1,
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
component: 'RichTextarea',
|
component: 'RichTextarea',
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
|
|
@ -98,7 +88,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
options: [],
|
options: [],
|
||||||
#end
|
#end
|
||||||
placeholder: '请选择${comment}',
|
placeholder: '请选择${comment}',
|
||||||
class: 'w-full',
|
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "checkbox")## 多选框
|
#elseif($column.htmlType == "checkbox")## 多选框
|
||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
|
|
@ -136,7 +125,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
min: 0,
|
min: 0,
|
||||||
class: 'w-full',
|
|
||||||
controlsPosition: 'right',
|
controlsPosition: 'right',
|
||||||
placeholder: '请输入${comment}',
|
placeholder: '请输入${comment}',
|
||||||
},
|
},
|
||||||
|
|
@ -320,17 +308,9 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
placeholder: '请输入${comment}',
|
placeholder: '请输入${comment}',
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||||
component: 'FileUpload',
|
component: 'ImageUpload',
|
||||||
componentProps: {
|
|
||||||
fileType: 'image',
|
|
||||||
maxCount: 1,
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||||
component: 'FileUpload',
|
component: 'FileUpload',
|
||||||
componentProps: {
|
|
||||||
fileType: 'file',
|
|
||||||
maxCount: 1,
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
component: 'RichTextarea',
|
component: 'RichTextarea',
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
|
|
@ -342,7 +322,6 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
options: [],
|
options: [],
|
||||||
#end
|
#end
|
||||||
placeholder: '请选择${comment}',
|
placeholder: '请选择${comment}',
|
||||||
class: 'w-full',
|
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "checkbox")## 多选框
|
#elseif($column.htmlType == "checkbox")## 多选框
|
||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
|
|
@ -380,7 +359,6 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
min: 0,
|
min: 0,
|
||||||
class: 'w-full',
|
|
||||||
controlsPosition: 'right',
|
controlsPosition: 'right',
|
||||||
placeholder: '请输入${comment}',
|
placeholder: '请输入${comment}',
|
||||||
},
|
},
|
||||||
|
|
@ -603,17 +581,9 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
placeholder: '请输入${comment}',
|
placeholder: '请输入${comment}',
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||||
component: 'FileUpload',
|
component: 'ImageUpload',
|
||||||
componentProps: {
|
|
||||||
fileType: 'image',
|
|
||||||
maxCount: 1,
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||||
component: 'FileUpload',
|
component: 'FileUpload',
|
||||||
componentProps: {
|
|
||||||
fileType: 'file',
|
|
||||||
maxCount: 1,
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
component: 'RichTextarea',
|
component: 'RichTextarea',
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
|
|
@ -625,7 +595,6 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
options: [],
|
options: [],
|
||||||
#end
|
#end
|
||||||
placeholder: '请选择${comment}',
|
placeholder: '请选择${comment}',
|
||||||
class: 'w-full',
|
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "checkbox")## 多选框
|
#elseif($column.htmlType == "checkbox")## 多选框
|
||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
|
|
@ -663,7 +632,6 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
min: 0,
|
min: 0,
|
||||||
class: 'w-full',
|
|
||||||
controlsPosition: 'right',
|
controlsPosition: 'right',
|
||||||
placeholder: '请输入${comment}',
|
placeholder: '请输入${comment}',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,13 @@ const getTitle = computed(() => {
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
showDefaultActions: false
|
showDefaultActions: false
|
||||||
|
|
@ -113,7 +120,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.lock(false);
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
|
@ -132,7 +139,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
try {
|
try {
|
||||||
data = await get${simpleClassName}(data.id);
|
data = await get${simpleClassName}(data.id);
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.lock(false);
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 设置到 values
|
// 设置到 values
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: use${subSimpleClassName}FormSchema(),
|
schema: use${subSimpleClassName}FormSchema(),
|
||||||
showDefaultActions: false
|
showDefaultActions: false
|
||||||
|
|
@ -50,7 +57,7 @@
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.lock(false);
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
|
@ -69,7 +76,7 @@
|
||||||
try {
|
try {
|
||||||
data = await get${subSimpleClassName}(data.id);
|
data = await get${subSimpleClassName}(data.id);
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.lock(false);
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 设置到 values
|
// 设置到 values
|
||||||
|
|
|
||||||
|
|
@ -96,9 +96,16 @@ watch(
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
layout: 'horizontal',
|
commonConfig: {
|
||||||
schema: use${subSimpleClassName}FormSchema(),
|
componentProps: {
|
||||||
showDefaultActions: false
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: use${subSimpleClassName}FormSchema(),
|
||||||
|
showDefaultActions: false
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 暴露出表单校验方法和表单值获取方法 */
|
/** 暴露出表单校验方法和表单值获取方法 */
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
@Tag(name = "RPC 服务 - 商品 SKU")
|
@Tag(name = "RPC 服务 - 商品 SKU")
|
||||||
|
|
@ -33,6 +36,16 @@ public interface ProductSkuApi {
|
||||||
@Parameter(name = "ids", description = "SKU 编号列表", required = true, example = "1024,2048")
|
@Parameter(name = "ids", description = "SKU 编号列表", required = true, example = "1024,2048")
|
||||||
CommonResult<List<ProductSkuRespDTO>> getSkuList(@RequestParam("ids") Collection<Long> ids);
|
CommonResult<List<ProductSkuRespDTO>> getSkuList(@RequestParam("ids") Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询 SKU MAP
|
||||||
|
*
|
||||||
|
* @param ids SKU 编号列表
|
||||||
|
* @return SKU MAP
|
||||||
|
*/
|
||||||
|
default Map<Long, ProductSkuRespDTO> getSkuMap(Collection<Long> ids) {
|
||||||
|
return convertMap(getSkuList(ids).getCheckedData(), ProductSkuRespDTO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping(PREFIX + "/list-by-spu-id")
|
@GetMapping(PREFIX + "/list-by-spu-id")
|
||||||
@Operation(summary = "批量查询 SKU 信息")
|
@Operation(summary = "批量查询 SKU 信息")
|
||||||
@Parameter(name = "spuIds", description = "SPU 编号列表", required = true, example = "1024,2048")
|
@Parameter(name = "spuIds", description = "SPU 编号列表", required = true, example = "1024,2048")
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public interface ProductSpuApi {
|
||||||
* @param ids SPU 编号列表
|
* @param ids SPU 编号列表
|
||||||
* @return SPU MAP
|
* @return SPU MAP
|
||||||
*/
|
*/
|
||||||
default Map<Long, ProductSpuRespDTO> getSpusMap(Collection<Long> ids) {
|
default Map<Long, ProductSpuRespDTO> getSpuMap(Collection<Long> ids) {
|
||||||
return convertMap(getSpuList(ids).getCheckedData(), ProductSpuRespDTO::getId);
|
return convertMap(getSpuList(ids).getCheckedData(), ProductSpuRespDTO::getId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,15 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商品浏览记录 Response VO")
|
@Schema(description = "管理后台 - 商品浏览记录 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class ProductBrowseHistoryRespVO {
|
public class ProductBrowseHistoryRespVO {
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
// ========== 商品相关字段 ==========
|
// ========== 商品相关字段 ==========
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏
|
@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏
|
||||||
@Data
|
@Data
|
||||||
public class AppFavoriteBatchReqVO {
|
public class AppFavoriteBatchReqVO {
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502")
|
@Schema(description = "商品 SPU 编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||||
@NotEmpty(message = "商品 SPU 编号数组不能为空")
|
@NotEmpty(message = "商品 SPU 编号数组不能为空")
|
||||||
private List<Long> spuIds;
|
private List<Long> spuIds;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏
|
@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏
|
||||||
@Data
|
@Data
|
||||||
public class AppFavoriteReqVO {
|
public class AppFavoriteReqVO {
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||||
@NotNull(message = "商品 SPU 编号不能为空")
|
@NotNull(message = "商品 SPU 编号不能为空")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,14 @@ package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
|
||||||
|
|
||||||
@Schema(description = "用户 App - 商品收藏 Response VO")
|
@Schema(description = "用户 App - 商品收藏 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppFavoriteRespVO {
|
public class AppFavoriteRespVO {
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
// ========== 商品相关字段 ==========
|
// ========== 商品相关字段 ==========
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,11 @@ import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 删除商品浏览记录的 Request VO")
|
@Schema(description = "用户 APP - 删除商品浏览记录的 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppProductBrowseHistoryDeleteReqVO {
|
public class AppProductBrowseHistoryDeleteReqVO {
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502")
|
@Schema(description = "商品 SPU 编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||||
@NotEmpty(message = "商品 SPU 编号数组不能为空")
|
@NotEmpty(message = "商品 SPU 编号数组不能为空")
|
||||||
private List<Long> spuIds;
|
private List<Long> spuIds;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,33 +3,31 @@ package cn.iocoder.yudao.module.product.controller.app.history.vo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
|
||||||
|
|
||||||
@Schema(description = "用户 App - 商品浏览记录 Response VO")
|
@Schema(description = "用户 App - 商品浏览记录 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppProductBrowseHistoryRespVO {
|
public class AppProductBrowseHistoryRespVO {
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
// ========== 商品相关字段 ==========
|
// ========== 商品相关字段 ==========
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 名称", requiredMode = REQUIRED, example = "赵六")
|
@Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||||
private String spuName;
|
private String spuName;
|
||||||
|
|
||||||
@Schema(description = "商品封面图", requiredMode = REQUIRED, example = "https://www.iocoder.cn/pic.png")
|
@Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/pic.png")
|
||||||
private String picUrl;
|
private String picUrl;
|
||||||
|
|
||||||
@Schema(description = "商品单价", requiredMode = REQUIRED, example = "50")
|
@Schema(description = "商品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||||
private Integer price;
|
private Integer price;
|
||||||
|
|
||||||
@Schema(description = "商品销量", requiredMode = REQUIRED, example = "60")
|
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "60")
|
||||||
private Integer salesCount;
|
private Integer salesCount;
|
||||||
|
|
||||||
@Schema(description = "库存", requiredMode = REQUIRED, example = "80")
|
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "80")
|
||||||
private Integer stock;
|
private Integer stock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -13,6 +15,9 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||||
|
|
||||||
|
@Select("SELECT * FROM product_sku WHERE id = #{id}")
|
||||||
|
ProductSkuDO selectByIdIncludeDeleted(@Param("id") Long id);
|
||||||
|
|
||||||
default List<ProductSkuDO> selectListBySpuId(Long spuId) {
|
default List<ProductSkuDO> selectListBySpuId(Long spuId) {
|
||||||
return selectList(ProductSkuDO::getSpuId, spuId);
|
return selectList(ProductSkuDO::getSpuId, spuId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.enums.ProductConstants;
|
||||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -18,6 +20,9 @@ import java.util.Set;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||||
|
|
||||||
|
@Select("SELECT * FROM product_spu WHERE id = #{id}")
|
||||||
|
ProductSpuDO selectByIdIncludeDeleted(@Param("id") Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品 SPU 分页列表数据
|
* 获取商品 SPU 分页列表数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProductSkuDO validateSku(Long skuId) {
|
private ProductSkuDO validateSku(Long skuId) {
|
||||||
ProductSkuDO sku = productSkuService.getSku(skuId);
|
ProductSkuDO sku = productSkuService.getSku(skuId, true);
|
||||||
if (sku == null) {
|
if (sku == null) {
|
||||||
throw exception(SKU_NOT_EXISTS);
|
throw exception(SKU_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProductSpuDO validateSpu(Long spuId) {
|
private ProductSpuDO validateSpu(Long spuId) {
|
||||||
ProductSpuDO spu = productSpuService.getSpu(spuId);
|
ProductSpuDO spu = productSpuService.getSpu(spuId, true);
|
||||||
if (null == spu) {
|
if (null == spu) {
|
||||||
throw exception(SPU_NOT_EXISTS);
|
throw exception(SPU_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,15 @@ public interface ProductSkuService {
|
||||||
*/
|
*/
|
||||||
ProductSkuDO getSku(Long id);
|
ProductSkuDO getSku(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得商品 SKU 信息
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @param includeDeleted 是否包含已删除的
|
||||||
|
* @return 商品 SKU 信息
|
||||||
|
*/
|
||||||
|
ProductSkuDO getSku(Long id, boolean includeDeleted);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得商品 SKU 列表
|
* 获得商品 SKU 列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,14 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||||
return productSkuMapper.selectById(id);
|
return productSkuMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductSkuDO getSku(Long id, boolean includeDeleted) {
|
||||||
|
if (includeDeleted) {
|
||||||
|
return productSkuMapper.selectByIdIncludeDeleted(id);
|
||||||
|
}
|
||||||
|
return getSku(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProductSkuDO> getSkuList(Collection<Long> ids) {
|
public List<ProductSkuDO> getSkuList(Collection<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,15 @@ public interface ProductSpuService {
|
||||||
*/
|
*/
|
||||||
ProductSpuDO getSpu(Long id);
|
ProductSpuDO getSpu(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得商品 SPU
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @param includeDeleted 是否包含已删除的
|
||||||
|
* @return 商品 SPU
|
||||||
|
*/
|
||||||
|
ProductSpuDO getSpu(Long id, boolean includeDeleted);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得商品 SPU 列表
|
* 获得商品 SPU 列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||||
return productSpuMapper.selectById(id);
|
return productSpuMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductSpuDO getSpu(Long id, boolean includeDeleted) {
|
||||||
|
if (includeDeleted) {
|
||||||
|
return productSpuMapper.selectByIdIncludeDeleted(id);
|
||||||
|
}
|
||||||
|
return getSpu(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProductSpuDO> getSpuList(Collection<Long> ids) {
|
public List<ProductSpuDO> getSpuList(Collection<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ public class PointActivityController {
|
||||||
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
|
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
|
||||||
convertSet(activityList, PointActivityDO::getId));
|
convertSet(activityList, PointActivityDO::getId));
|
||||||
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
||||||
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
|
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpuMap(
|
||||||
convertSet(activityList, PointActivityDO::getSpuId));
|
convertSet(activityList, PointActivityDO::getSpuId));
|
||||||
List<PointActivityRespVO> result = BeanUtils.toBean(activityList, PointActivityRespVO.class);
|
List<PointActivityRespVO> result = BeanUtils.toBean(activityList, PointActivityRespVO.class);
|
||||||
result.forEach(activity -> {
|
result.forEach(activity -> {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -20,6 +20,9 @@ public class AppCouponTemplateRespVO {
|
||||||
@Schema(description = "优惠券说明", example = "优惠券使用说明")
|
@Schema(description = "优惠券说明", example = "优惠券使用说明")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量
|
||||||
|
private Integer totalCount;
|
||||||
|
|
||||||
@Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制
|
@Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制
|
||||||
private Integer takeLimitCount;
|
private Integer takeLimitCount;
|
||||||
|
|
||||||
|
|
@ -62,6 +65,9 @@ public class AppCouponTemplateRespVO {
|
||||||
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
||||||
private Integer discountLimitPrice;
|
private Integer discountLimitPrice;
|
||||||
|
|
||||||
|
@Schema(description = "领取优惠券的数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Integer takeCount;
|
||||||
|
|
||||||
// ========== 用户相关字段 ==========
|
// ========== 用户相关字段 ==========
|
||||||
|
|
||||||
@Schema(description = "是否可以领取", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "是否可以领取", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ public class AppPointActivityController {
|
||||||
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
|
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
|
||||||
convertSet(activityList, PointActivityDO::getId));
|
convertSet(activityList, PointActivityDO::getId));
|
||||||
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
||||||
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
|
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpuMap(
|
||||||
convertSet(activityList, PointActivityDO::getSpuId));
|
convertSet(activityList, PointActivityDO::getSpuId));
|
||||||
List<AppPointActivityRespVO> result = BeanUtils.toBean(activityList, AppPointActivityRespVO.class);
|
List<AppPointActivityRespVO> result = BeanUtils.toBean(activityList, AppPointActivityRespVO.class);
|
||||||
result.forEach(activity -> {
|
result.forEach(activity -> {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityType
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
|
@ -180,7 +181,7 @@ public class CouponServiceImpl implements CouponService {
|
||||||
* @param couponId 模版编号
|
* @param couponId 模版编号
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) // 每次调用开启一个新的事务,避免在一个大的事务里面
|
||||||
public void invalidateCoupon(Long couponId, Long userId) {
|
public void invalidateCoupon(Long couponId, Long userId) {
|
||||||
if (couponId == null || couponId <= 0) {
|
if (couponId == null || couponId <= 0) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -270,13 +271,17 @@ public class CouponServiceImpl implements CouponService {
|
||||||
if (CollUtil.isEmpty(userIds)) {
|
if (CollUtil.isEmpty(userIds)) {
|
||||||
throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE);
|
throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验模板
|
// 校验模板
|
||||||
if (couponTemplate == null) {
|
if (couponTemplate == null) {
|
||||||
throw exception(COUPON_TEMPLATE_NOT_EXISTS);
|
throw exception(COUPON_TEMPLATE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
// 校验剩余数量
|
// 校验领取方式
|
||||||
if (ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
|
if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {
|
||||||
|
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
|
||||||
|
}
|
||||||
|
// 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时)
|
||||||
|
if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
|
||||||
|
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TIME_LIMIT_COUNT_MAX) // 非不限制
|
||||||
&& couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
|
&& couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
|
||||||
throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
|
throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
@ -286,10 +291,6 @@ public class CouponServiceImpl implements CouponService {
|
||||||
throw exception(COUPON_TEMPLATE_EXPIRED);
|
throw exception(COUPON_TEMPLATE_EXPIRED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 校验领取方式
|
|
||||||
if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {
|
|
||||||
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
package cn.iocoder.yudao.module.trade.controller.app.aftersale;
|
package cn.iocoder.yudao.module.trade.controller.app.aftersale;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSalePageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
|
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
|
@ -31,16 +32,17 @@ public class AppAfterSaleController {
|
||||||
|
|
||||||
@GetMapping(value = "/page")
|
@GetMapping(value = "/page")
|
||||||
@Operation(summary = "获得售后分页")
|
@Operation(summary = "获得售后分页")
|
||||||
public CommonResult<PageResult<AppAfterSaleRespVO>> getAfterSalePage(PageParam pageParam) {
|
public CommonResult<PageResult<AppAfterSaleRespVO>> getAfterSalePage(AppAfterSalePageReqVO pageReqVO) {
|
||||||
return success(AfterSaleConvert.INSTANCE.convertPage02(
|
PageResult<AfterSaleDO> pageResult = afterSaleService.getAfterSalePage(getLoginUserId(), pageReqVO);
|
||||||
afterSaleService.getAfterSalePage(getLoginUserId(), pageParam)));
|
return success(BeanUtils.toBean(pageResult, AppAfterSaleRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/get")
|
@GetMapping(value = "/get")
|
||||||
@Operation(summary = "获得售后订单")
|
@Operation(summary = "获得售后订单")
|
||||||
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
||||||
public CommonResult<AppAfterSaleRespVO> getAfterSale(@RequestParam("id") Long id) {
|
public CommonResult<AppAfterSaleRespVO> getAfterSale(@RequestParam("id") Long id) {
|
||||||
return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
|
AfterSaleDO afterSale = afterSaleService.getAfterSale(getLoginUserId(), id);
|
||||||
|
return success(BeanUtils.toBean(afterSale, AppAfterSaleRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/create")
|
@PostMapping(value = "/create")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Schema(description = "用户 App - 交易售后分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AppAfterSalePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "售后状态", example = "10, 20")
|
||||||
|
private Set<Integer> statuses;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.app.base.spu;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品 SPU 基础 Response VO
|
* 商品 SPU 基础 Response VO
|
||||||
*
|
*
|
||||||
|
|
@ -25,4 +23,10 @@ public class AppProductSpuBaseRespVO {
|
||||||
@Schema(description = "商品分类编号", example = "1")
|
@Schema(description = "商品分类编号", example = "1")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
|
@Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000")
|
||||||
|
private Integer stock;
|
||||||
|
|
||||||
|
@Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup;
|
package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
@Schema(description = "用户 App - 自提门店 Response VO")
|
@Schema(description = "用户 App - 自提门店 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppDeliveryPickUpStoreRespVO {
|
public class AppDeliveryPickUpStoreRespVO {
|
||||||
|
|
@ -28,6 +32,16 @@ public class AppDeliveryPickUpStoreRespVO {
|
||||||
@Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号")
|
@Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号")
|
||||||
private String detailAddress;
|
private String detailAddress;
|
||||||
|
|
||||||
|
@Schema(description = "营业开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "营业开始时间不能为空")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm")
|
||||||
|
private LocalTime openingTime;
|
||||||
|
|
||||||
|
@Schema(description = "营业结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "营业结束时间不能为空")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm")
|
||||||
|
private LocalTime closingTime;
|
||||||
|
|
||||||
@Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88")
|
@Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88")
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUse
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
|
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||||
|
|
@ -63,10 +62,6 @@ public interface AfterSaleConvert {
|
||||||
|
|
||||||
ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean);
|
ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean);
|
||||||
|
|
||||||
AppAfterSaleRespVO convert(AfterSaleDO bean);
|
|
||||||
|
|
||||||
PageResult<AppAfterSaleRespVO> convertPage02(PageResult<AfterSaleDO> page);
|
|
||||||
|
|
||||||
default AfterSaleDetailRespVO convert(AfterSaleDO afterSale, TradeOrderDO order, TradeOrderItemDO orderItem,
|
default AfterSaleDetailRespVO convert(AfterSaleDO afterSale, TradeOrderDO order, TradeOrderItemDO orderItem,
|
||||||
MemberUserRespDTO user, List<AfterSaleLogDO> logs) {
|
MemberUserRespDTO user, List<AfterSaleLogDO> logs) {
|
||||||
AfterSaleDetailRespVO respVO = convert02(afterSale);
|
AfterSaleDetailRespVO respVO = convert02(afterSale);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.trade.convert.cart;
|
package cn.iocoder.yudao.module.trade.convert.cart;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||||
|
|
@ -33,21 +34,18 @@ public interface TradeCartConvert {
|
||||||
cartVO.setId(cart.getId()).setCount(cart.getCount()).setSelected(cart.getSelected());
|
cartVO.setId(cart.getId()).setCount(cart.getCount()).setSelected(cart.getSelected());
|
||||||
ProductSpuRespDTO spu = spuMap.get(cart.getSpuId());
|
ProductSpuRespDTO spu = spuMap.get(cart.getSpuId());
|
||||||
ProductSkuRespDTO sku = skuMap.get(cart.getSkuId());
|
ProductSkuRespDTO sku = skuMap.get(cart.getSkuId());
|
||||||
cartVO.setSpu(convert(spu)).setSku(convert(sku));
|
cartVO.setSpu(BeanUtils.toBean(spu, AppProductSpuBaseRespVO.class))
|
||||||
|
.setSku(BeanUtils.toBean(sku, AppProductSkuBaseRespVO.class));
|
||||||
// 如果 SPU 不存在,或者下架,或者库存不足,说明是无效的
|
// 如果 SPU 不存在,或者下架,或者库存不足,说明是无效的
|
||||||
if (spu == null
|
if (spu == null
|
||||||
|| !ProductSpuStatusEnum.isEnable(spu.getStatus())
|
|| !ProductSpuStatusEnum.isEnable(spu.getStatus())
|
||||||
|| spu.getStock() <= 0) {
|
|| spu.getStock() <= 0) {
|
||||||
cartVO.setSelected(false); // 强制设置成不可选中
|
|
||||||
invalidList.add(cartVO);
|
invalidList.add(cartVO);
|
||||||
} else {
|
} else {
|
||||||
// 虽然 SKU 可能也会不存在,但是可以通过购物车重新选择
|
|
||||||
validList.add(cartVO);
|
validList.add(cartVO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new AppCartListRespVO().setValidList(validList).setInvalidList(invalidList);
|
return new AppCartListRespVO().setValidList(validList).setInvalidList(invalidList);
|
||||||
}
|
}
|
||||||
AppProductSpuBaseRespVO convert(ProductSpuRespDTO spu);
|
|
||||||
AppProductSkuBaseRespVO convert(ProductSkuRespDTO sku);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package cn.iocoder.yudao.module.trade.dal.mysql.aftersale;
|
package cn.iocoder.yudao.module.trade.dal.mysql.aftersale;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSalePageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
@ -27,9 +27,10 @@ public interface AfterSaleMapper extends BaseMapperX<AfterSaleDO> {
|
||||||
.orderByDesc(AfterSaleDO::getId));
|
.orderByDesc(AfterSaleDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<AfterSaleDO> selectPage(Long userId, PageParam pageParam) {
|
default PageResult<AfterSaleDO> selectPage(Long userId, AppAfterSalePageReqVO pageReqVO) {
|
||||||
return selectPage(pageParam, new LambdaQueryWrapperX<AfterSaleDO>()
|
return selectPage(pageReqVO, new LambdaQueryWrapperX<AfterSaleDO>()
|
||||||
.eqIfPresent(AfterSaleDO::getUserId, userId)
|
.eq(AfterSaleDO::getUserId, userId)
|
||||||
|
.inIfPresent(AfterSaleDO::getStatus, pageReqVO.getStatuses())
|
||||||
.orderByDesc(AfterSaleDO::getId));
|
.orderByDesc(AfterSaleDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
package cn.iocoder.yudao.module.trade.service.aftersale;
|
package cn.iocoder.yudao.module.trade.service.aftersale;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSalePageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,10 +28,10 @@ public interface AfterSaleService {
|
||||||
* 【会员】获得售后订单分页
|
* 【会员】获得售后订单分页
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param pageParam 分页参数
|
* @param pageReqVO 分页参数
|
||||||
* @return 售后订单分页
|
* @return 售后订单分页
|
||||||
*/
|
*/
|
||||||
PageResult<AfterSaleDO> getAfterSalePage(Long userId, PageParam pageParam);
|
PageResult<AfterSaleDO> getAfterSalePage(Long userId, AppAfterSalePageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【会员】获得售后单
|
* 【会员】获得售后单
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.service.aftersale;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||||
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
||||||
|
|
@ -16,6 +15,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePage
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSalePageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert;
|
import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||||
|
|
@ -87,8 +87,8 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<AfterSaleDO> getAfterSalePage(Long userId, PageParam pageParam) {
|
public PageResult<AfterSaleDO> getAfterSalePage(Long userId, AppAfterSalePageReqVO pageReqVO) {
|
||||||
return tradeAfterSaleMapper.selectPage(userId, pageParam);
|
return tradeAfterSaleMapper.selectPage(userId, pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -386,7 +386,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
||||||
public void afterCommit() {
|
public void afterCommit() {
|
||||||
// 创建退款单
|
// 创建退款单
|
||||||
PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties)
|
PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties)
|
||||||
.setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));;
|
.setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));
|
||||||
Long payRefundId = payRefundApi.createRefund(createReqDTO).getCheckedData();
|
Long payRefundId = payRefundApi.createRefund(createReqDTO).getCheckedData();
|
||||||
// 更新售后单的退款单号
|
// 更新售后单的退款单号
|
||||||
tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId));
|
tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId));
|
||||||
|
|
|
||||||
|
|
@ -545,6 +545,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||||
if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) {
|
if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) {
|
||||||
throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
|
throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
|
||||||
}
|
}
|
||||||
|
// 1.3 校验是否支持延迟(不允许取消)
|
||||||
|
if (TradeOrderStatusEnum.isUnpaid(order.getStatus())) {
|
||||||
|
PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId()).getCheckedData();
|
||||||
|
if (payOrder != null && PayOrderStatusEnum.isSuccess(payOrder.getStatus())) {
|
||||||
|
log.warn("[cancelOrderByMember][order({}) 支付单已支付(支付回调延迟),不支持取消]", order.getId());
|
||||||
|
throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 取消订单
|
// 2. 取消订单
|
||||||
cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
|
cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
|
||||||
|
|
@ -581,6 +589,15 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL)
|
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL)
|
||||||
public void cancelOrderBySystem(TradeOrderDO order) {
|
public void cancelOrderBySystem(TradeOrderDO order) {
|
||||||
|
// 校验是否支持延迟(不允许取消)
|
||||||
|
if (TradeOrderStatusEnum.isUnpaid(order.getStatus())) {
|
||||||
|
PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId()).getCheckedData();
|
||||||
|
if (payOrder != null && PayOrderStatusEnum.isSuccess(payOrder.getStatus())) {
|
||||||
|
log.warn("[cancelOrderBySystem][order({}) 支付单已支付(支付回调延迟),不支持取消]", order.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT);
|
cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -895,12 +912,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
throw exception(ORDER_NOT_FOUND);
|
throw exception(ORDER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.3 校验订单是否支付
|
// 1.3 校验订单是否支付
|
||||||
if (!order.getPayStatus()) {
|
if (!order.getPayStatus()) {
|
||||||
throw exception(ORDER_CANCEL_PAID_FAIL, "已支付");
|
throw exception(ORDER_CANCEL_PAID_FAIL, "已支付");
|
||||||
}
|
}
|
||||||
// 1.3 校验订单是否未退款
|
// 1.4 校验订单是否未退款
|
||||||
if (ObjUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
|
if (ObjUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
|
||||||
throw exception(ORDER_CANCEL_PAID_FAIL, "未退款");
|
throw exception(ORDER_CANCEL_PAID_FAIL, "未退款");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
|
|
@ -101,13 +102,17 @@ public class TradeBrokerageOrderHandler implements TradeOrderHandler {
|
||||||
protected void addBrokerage(Long userId, List<TradeOrderItemDO> orderItems) {
|
protected void addBrokerage(Long userId, List<TradeOrderItemDO> orderItems) {
|
||||||
MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData();
|
MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData();
|
||||||
Assert.notNull(user);
|
Assert.notNull(user);
|
||||||
ProductSpuRespDTO spu = productSpuApi.getSpu(orderItems.get(0).getSpuId()).getCheckedData();
|
Map<Long, ProductSpuRespDTO> spusMap = productSpuApi.getSpuMap(convertList(orderItems, TradeOrderItemDO::getSpuId));
|
||||||
Assert.notNull(spu);
|
Map<Long, ProductSkuRespDTO> skusMap = productSkuApi.getSkuMap(convertList(orderItems, TradeOrderItemDO::getSkuId));
|
||||||
ProductSkuRespDTO sku = productSkuApi.getSku(orderItems.get(0).getSkuId()).getCheckedData();
|
|
||||||
|
|
||||||
// 每一个订单项,都会去生成分销记录
|
// 每一个订单项,都会去生成分销记录
|
||||||
List<BrokerageAddReqBO> addList = convertList(orderItems,
|
List<BrokerageAddReqBO> addList = convertList(orderItems, item -> {
|
||||||
item -> TradeOrderConvert.INSTANCE.convert(user, item, spu, sku));
|
ProductSpuRespDTO spu = spusMap.get(item.getSpuId());
|
||||||
|
Assert.notNull(spu);
|
||||||
|
ProductSkuRespDTO sku = skusMap.get(item.getSkuId());
|
||||||
|
Assert.notNull(sku);
|
||||||
|
return TradeOrderConvert.INSTANCE.convert(user, item, spu, sku);
|
||||||
|
});
|
||||||
brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList);
|
brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过租户最大租户配额({})!");
|
ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过租户最大租户配额({})!");
|
||||||
ErrorCode USER_IMPORT_INIT_PASSWORD = new ErrorCode(1_002_003_009, "初始密码不能为空");
|
ErrorCode USER_IMPORT_INIT_PASSWORD = new ErrorCode(1_002_003_009, "初始密码不能为空");
|
||||||
ErrorCode USER_MOBILE_NOT_EXISTS = new ErrorCode(1_002_003_010, "该手机号尚未注册");
|
ErrorCode USER_MOBILE_NOT_EXISTS = new ErrorCode(1_002_003_010, "该手机号尚未注册");
|
||||||
|
ErrorCode USER_REGISTER_DISABLED = new ErrorCode(1_002_003_011, "注册功能已关闭");
|
||||||
|
|
||||||
// ========== 部门模块 1-002-004-000 ==========
|
// ========== 部门模块 1-002-004-000 ==========
|
||||||
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");
|
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||||
import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
|
import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
|
|
@ -96,6 +97,7 @@ public class TenantServiceImpl implements TenantService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
||||||
|
@DataPermission(enable = false) // 参见 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1154 说明
|
||||||
public Long createTenant(TenantSaveReqVO createReqVO) {
|
public Long createTenant(TenantSaveReqVO createReqVO) {
|
||||||
// 校验租户名称是否重复
|
// 校验租户名称是否重复
|
||||||
validTenantNameDuplicate(createReqVO.getName(), null);
|
validTenantNameDuplicate(createReqVO.getName(), null);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.user;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
|
@ -61,6 +62,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||||
|
|
||||||
static final String USER_INIT_PASSWORD_KEY = "system.user.init-password";
|
static final String USER_INIT_PASSWORD_KEY = "system.user.init-password";
|
||||||
|
|
||||||
|
static final String USER_REGISTER_ENABLED_KEY = "system.user.register-enabled";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserMapper userMapper;
|
private AdminUserMapper userMapper;
|
||||||
|
|
||||||
|
|
@ -117,14 +120,18 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long registerUser(AuthRegisterReqVO registerReqVO) {
|
public Long registerUser(AuthRegisterReqVO registerReqVO) {
|
||||||
// 1.1 校验账户配合
|
// 1.1 校验是否开启注册
|
||||||
|
if (ObjUtil.notEqual(configApi.getConfigValueByKey(USER_REGISTER_ENABLED_KEY).getCheckedData(), "true")) {
|
||||||
|
throw exception(USER_REGISTER_DISABLED);
|
||||||
|
}
|
||||||
|
// 1.2 校验账户配合
|
||||||
tenantService.handleTenantInfo(tenant -> {
|
tenantService.handleTenantInfo(tenant -> {
|
||||||
long count = userMapper.selectCount();
|
long count = userMapper.selectCount();
|
||||||
if (count >= tenant.getAccountCount()) {
|
if (count >= tenant.getAccountCount()) {
|
||||||
throw exception(USER_COUNT_MAX, tenant.getAccountCount());
|
throw exception(USER_COUNT_MAX, tenant.getAccountCount());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 1.2 校验正确性
|
// 1.3 校验正确性
|
||||||
validateUserForCreateOrUpdate(null, registerReqVO.getUsername(), null, null, null, null);
|
validateUserForCreateOrUpdate(null, registerReqVO.getUsername(), null, null, null, null);
|
||||||
|
|
||||||
// 2. 插入用户
|
// 2. 插入用户
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue