From 4a3703e3026f715d0119e7cdb05e371fd719684e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 25 Jun 2023 11:24:55 +0800 Subject: [PATCH] mall + promotion:review 页面装修 --- yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java | 8 ++++---- yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentReqVO.java | 41 ----------------------------------------- yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java | 6 +++--- yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java | 4 ++-- yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java | 6 +++--- yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java | 3 ++- 7 files changed, 58 insertions(+), 54 deletions(-) delete mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentReqVO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java index a4f9206..9536df7 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.decorate; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO; import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; @@ -27,10 +27,10 @@ public class DecorateComponentController { private DecorateComponentService decorateComponentService; @PostMapping("/page-save") - @Operation(summary = "页面装修保存") + @Operation(summary = "保存页面装修") // TODO 加权限 - public CommonResult pageSave(@Valid @RequestBody DecorateComponentReqVO reqVO) { - decorateComponentService.pageSave(reqVO); + public CommonResult savePageComponents(@Valid @RequestBody DecorateComponentSaveReqVO reqVO) { + decorateComponentService.savePageComponents(reqVO); return success(true); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentReqVO.java deleted file mode 100644 index de349a0..0000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 页面装修 Request VO ") -@Data -public class DecorateComponentReqVO { - @Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "页面 id 不能为空") - @InEnum(DecoratePageEnum.class) - private Integer pageId; - - @Schema(description = "页面组件列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") - @NotEmpty(message = "页面组件列表不能为空") - @Valid - private List components; - - @Schema(description = "管理后台 - 页面装修组件 Request VO") - @Data - public static class ComponentReqVO { - @Schema(description = "组件编码", example = "1") - private Long id; - - @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") - @NotEmpty(message = "组件编码不能为空") - private String code; - - @Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") - @NotEmpty(message = "组件值为空") - private String value; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java new file mode 100644 index 0000000..f3838a7 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo; + +import cn.iocoder.yudao.framework.common.validation.InEnum; +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +@Schema(description = "管理后台 - 页面装修的保存 Request VO ") +@Data +public class DecorateComponentSaveReqVO { + + @Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "页面 id 不能为空") + @InEnum(DecoratePageEnum.class) + private Integer pageId; + + @Schema(description = "页面组件列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") + @NotEmpty(message = "页面组件列表不能为空") + @Valid + private List components; + + @Schema(description = "管理后台 - 页面装修组件 Request VO") + @Data + public static class ComponentReqVO { + + @Schema(description = "组件编码", example = "1") + private Long id; + + @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") + @NotEmpty(message = "组件编码不能为空") + private String code; + + @Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") + @NotEmpty(message = "组件值为空") + private String value; + + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java index 2a163fb..c815220 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.promotion.convert.decorate; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO; import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; @@ -18,7 +18,7 @@ public interface DecorateComponentConvert { DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class); - default List convertList(Integer pageId, List components) { + default List convertList(Integer pageId, List components) { return CollectionUtils.convertList(components, c -> convert(pageId, c)); } @@ -27,7 +27,7 @@ public interface DecorateComponentConvert { return new DecorateComponentRespVO().setPageId(pageId).setComponents(components); } - DecorateComponentDO convert(Integer pageId, DecorateComponentReqVO.ComponentReqVO reqVO); + DecorateComponentDO convert(Integer pageId, DecorateComponentSaveReqVO.ComponentReqVO reqVO); ComponentRespVO convert3(DecorateComponentDO componentDO); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java index 2ecd844..cf1431f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.promotion.service.decorate; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; @@ -18,7 +18,7 @@ public interface DecorateComponentService { * * @param reqVO 请求 VO */ - void pageSave(DecorateComponentReqVO reqVO); + void savePageComponents(DecorateComponentSaveReqVO reqVO); /** * 根据页面 id。获取页面的组件信息 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java index 731ead7..7325692 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.promotion.service.decorate; import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO.ComponentReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO.ComponentReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper; import org.springframework.stereotype.Service; @@ -27,7 +27,7 @@ public class DecorateComponentServiceImpl implements DecorateComponentService { private DecorateComponentMapper decorateComponentMapper; @Override - public void pageSave(DecorateComponentReqVO reqVO) { + public void savePageComponents(DecorateComponentSaveReqVO reqVO) { // 1.新增或修改页面组件 List oldList = decorateComponentMapper.selectByPage(reqVO.getPageId()); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java index c78e4dd..0673979 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java @@ -16,6 +16,7 @@ import static cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponent import static cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum.INDEX; import static org.mockito.ArgumentMatchers.eq; +// TODO @芋艿:后续 review 下 /** * @author jason */ @@ -42,4 +43,4 @@ public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest { //mock 方法 Mockito.when(decorateComponentMapper.selectByPage(eq(1))).thenReturn(list); } -} \ No newline at end of file +} -- libgit2 0.21.4