From 989d7c44d0b4c60e64bb49e59132b471f294fc99 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 4 Nov 2023 22:52:41 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E5=BA=97=E9=93=BA=E8=A3=85?= =?UTF-8?q?=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 +- .../diy/vo/template/DiyTemplateBaseVO.java | 4 +- .../dal/dataobject/diy/DiyPageDO.java | 2 + .../dal/dataobject/diy/DiyTemplateDO.java | 3 + .../service/diy/DiyPageServiceImpl.java | 8 ++- .../service/diy/DiyTemplateServiceImpl.java | 7 ++- yudao-server/pom.xml | 62 +++++++++---------- 7 files changed, 54 insertions(+), 38 deletions(-) diff --git a/pom.xml b/pom.xml index dae40f3dc..7f7c140bb 100644 --- a/pom.xml +++ b/pom.xml @@ -15,12 +15,12 @@ yudao-module-system yudao-module-infra - + yudao-module-member - - + yudao-module-pay + yudao-module-mall diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java index 7959b6c26..b79c7231f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotEmpty; import java.util.List; /** @@ -14,7 +14,7 @@ import java.util.List; public class DiyTemplateBaseVO { @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - @NotNull(message = "模板名称不能为空") + @NotEmpty(message = "模板名称不能为空") private String name; @Schema(description = "备注", example = "默认主题") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java index e5e3f4208..7e1044104 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java @@ -32,6 +32,8 @@ public class DiyPageDO extends BaseDO { private Long id; /** * 装修模板编号 + * + * 关联 {@link DiyTemplateDO#getId()} */ private Long templateId; /** diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java index a50fd4dde..684a6f9cb 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java @@ -14,6 +14,9 @@ import java.util.List; /** * 装修模板 DO * + * 1. 新建一个模版,下面可以包含多个 {@link DiyPageDO} 页面,例如说首页、我的 + * 2. 如果需要使用某个模版,则将 {@link #used} 设置为 true,表示已使用,有且仅有一个 + * * @author owen */ @TableName(value = "promotion_diy_template", autoResultMap = true) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java index d82b9b8ed..69f96ad8f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java @@ -42,7 +42,6 @@ public class DiyPageServiceImpl implements DiyPageService { DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); diyPage.setProperty("{}"); diyPageMapper.insert(diyPage); - // 返回 return diyPage.getId(); } @@ -57,6 +56,13 @@ public class DiyPageServiceImpl implements DiyPageService { diyPageMapper.updateById(updateObj); } + /** + * 校验 Page 页面,在一个 template 模版下的名字是唯一的 + * + * @param id Page 编号 + * @param templateId 模版编号 + * @param name Page 名字 + */ void validateNameUnique(Long id, Long templateId, String name) { if (templateId != null || StrUtil.isBlank(name)) { return; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java index 41025c5d6..530b31b94 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java @@ -32,9 +32,11 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { @Resource private DiyTemplateMapper diyTemplateMapper; + @Resource private DiyPageService diyPageService; + // TODO @疯狂:事务; @Override public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { // 校验名称唯一 @@ -120,9 +122,11 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { } @Override + // TODO @疯狂:事务; public void useDiyTemplate(Long id) { // 校验存在 validateDiyTemplateExists(id); + // TODO @疯狂:要不已使用的情况,抛个业务异常? // 已使用的更新为未使用 DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); if (used != null) { @@ -136,8 +140,8 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { this.updateUsed(id, true, LocalDateTime.now()); } - @Transactional(rollbackFor = Exception.class) @Override + @Transactional(rollbackFor = Exception.class) public void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO) { // 校验存在 validateDiyTemplateExists(updateReqVO.getId()); @@ -151,6 +155,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { return diyTemplateMapper.selectByUsed(true); } + // TODO @疯狂:挪到 useDiyTemplate 下面,改名 updateTemplateUsed 会不会好点哈; /** * 更新模板是否使用 * diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 87a961778..4463bd7fb 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -37,11 +37,11 @@ - - - - - + + cn.iocoder.boot + yudao-module-member-biz + ${revision} + @@ -56,11 +56,11 @@ - - - - - + + cn.iocoder.boot + yudao-module-pay-biz + ${revision} + @@ -69,27 +69,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + cn.iocoder.boot + yudao-module-promotion-biz + ${revision} + + + cn.iocoder.boot + yudao-module-product-biz + ${revision} + + + cn.iocoder.boot + yudao-module-trade-biz + ${revision} + + + cn.iocoder.boot + yudao-module-statistics-biz + ${revision} +