Commit 050f0bb6a259a9425b1717a8515736789ab234d1
1 parent
b5822060
页面装修 review 修改
Showing
13 changed files
with
59 additions
and
63 deletions
sql/mysql/optional/mall.sql
| @@ -453,9 +453,9 @@ CREATE TABLE `trade_delivery_express` ( | @@ -453,9 +453,9 @@ CREATE TABLE `trade_delivery_express` ( | ||
| 453 | DROP TABLE IF EXISTS `promotion_decorate_component`; | 453 | DROP TABLE IF EXISTS `promotion_decorate_component`; |
| 454 | CREATE TABLE `promotion_decorate_component` ( | 454 | CREATE TABLE `promotion_decorate_component` ( |
| 455 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | 455 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', |
| 456 | - `type` int NOT NULL COMMENT '页面类型', | ||
| 457 | - `component_code` varchar(64) NOT NULL COMMENT '组件编码', | ||
| 458 | - `component_value` json NOT NULL COMMENT '组件值:json 格式。包含配置和数据', | 456 | + `page_id` int NOT NULL COMMENT '所属页面id', |
| 457 | + `code` varchar(64) NOT NULL COMMENT '组件编码', | ||
| 458 | + `value` json NOT NULL COMMENT '组件值:json 格式。包含配置和数据', | ||
| 459 | `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态', | 459 | `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态', |
| 460 | `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | 460 | `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', |
| 461 | `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | 461 | `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageTypeEnum.java renamed to yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java
| @@ -7,22 +7,22 @@ import lombok.Getter; | @@ -7,22 +7,22 @@ import lombok.Getter; | ||
| 7 | import java.util.Arrays; | 7 | import java.util.Arrays; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| 10 | - * 装修页面类型枚举 | 10 | + * 装修页面枚举 |
| 11 | * | 11 | * |
| 12 | * @author jason | 12 | * @author jason |
| 13 | */ | 13 | */ |
| 14 | @AllArgsConstructor | 14 | @AllArgsConstructor |
| 15 | @Getter | 15 | @Getter |
| 16 | -public enum DecoratePageTypeEnum implements IntArrayValuable { | 16 | +public enum DecoratePageEnum implements IntArrayValuable { |
| 17 | 17 | ||
| 18 | INDEX(1, "首页"); | 18 | INDEX(1, "首页"); |
| 19 | 19 | ||
| 20 | - private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageTypeEnum::getType).toArray(); | 20 | + private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getId).toArray(); |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | - * 页面类型 | 23 | + * 页面 id |
| 24 | */ | 24 | */ |
| 25 | - private final Integer type; | 25 | + private final Integer id; |
| 26 | /** | 26 | /** |
| 27 | * 页面名称 | 27 | * 页面名称 |
| 28 | */ | 28 | */ |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java
| @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; |
| 6 | import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO; |
| 7 | -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageTypeEnum; | 7 | +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; |
| 8 | import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; | 8 | import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; |
| 9 | import io.swagger.v3.oas.annotations.Operation; | 9 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | import io.swagger.v3.oas.annotations.Parameter; | 10 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -36,11 +36,11 @@ public class DecorateComponentController { | @@ -36,11 +36,11 @@ public class DecorateComponentController { | ||
| 36 | 36 | ||
| 37 | @GetMapping("/get-page-components") | 37 | @GetMapping("/get-page-components") |
| 38 | @Operation(summary = "获取装修页面组件") | 38 | @Operation(summary = "获取装修页面组件") |
| 39 | - @Parameter(name = "type", description = "页面类型", required = true) | 39 | + @Parameter(name = "pageId", description = "页面 id", required = true) |
| 40 | // TODO 加权限 | 40 | // TODO 加权限 |
| 41 | public CommonResult<DecorateComponentRespVO> getPageComponents( | 41 | public CommonResult<DecorateComponentRespVO> getPageComponents( |
| 42 | - @RequestParam("type") @InEnum(DecoratePageTypeEnum.class) Integer type) { | ||
| 43 | - return success(INSTANCE.convert2(type, decorateComponentService.getPageComponents(type))); | 42 | + @RequestParam("pageId") @InEnum(DecoratePageEnum.class) Integer pageId) { |
| 43 | + return success(INSTANCE.convert2(pageId, decorateComponentService.getPageComponents(pageId))); | ||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | } | 46 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentReqVO.java
| 1 | package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo; | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageTypeEnum; | 4 | +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import lombok.Data; | 6 | import lombok.Data; |
| 7 | 7 | ||
| @@ -13,10 +13,10 @@ import java.util.List; | @@ -13,10 +13,10 @@ import java.util.List; | ||
| 13 | @Schema(description = "管理后台 - 页面装修 Request VO ") | 13 | @Schema(description = "管理后台 - 页面装修 Request VO ") |
| 14 | @Data | 14 | @Data |
| 15 | public class DecorateComponentReqVO { | 15 | public class DecorateComponentReqVO { |
| 16 | - @Schema(description = "页面类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 17 | - @NotNull(message = "页面类型不能为空") | ||
| 18 | - @InEnum(DecoratePageTypeEnum.class) | ||
| 19 | - private Integer type; | 16 | + @Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 17 | + @NotNull(message = "页面 id 不能为空") | ||
| 18 | + @InEnum(DecoratePageEnum.class) | ||
| 19 | + private Integer pageId; | ||
| 20 | 20 | ||
| 21 | @Schema(description = "页面组件列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") | 21 | @Schema(description = "页面组件列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") |
| 22 | @NotEmpty(message = "页面组件列表不能为空") | 22 | @NotEmpty(message = "页面组件列表不能为空") |
| @@ -31,11 +31,11 @@ public class DecorateComponentReqVO { | @@ -31,11 +31,11 @@ public class DecorateComponentReqVO { | ||
| 31 | 31 | ||
| 32 | @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") | 32 | @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") |
| 33 | @NotEmpty(message = "组件编码不能为空") | 33 | @NotEmpty(message = "组件编码不能为空") |
| 34 | - private String componentCode; | 34 | + private String code; |
| 35 | 35 | ||
| 36 | @Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") | 36 | @Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") |
| 37 | @NotEmpty(message = "组件值为空") | 37 | @NotEmpty(message = "组件值为空") |
| 38 | - private String componentValue; | 38 | + private String value; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | } | 41 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentRespVO.java
| @@ -9,8 +9,8 @@ import java.util.List; | @@ -9,8 +9,8 @@ import java.util.List; | ||
| 9 | @Data | 9 | @Data |
| 10 | public class DecorateComponentRespVO { | 10 | public class DecorateComponentRespVO { |
| 11 | 11 | ||
| 12 | - @Schema(description = "页面类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 13 | - private Integer type; | 12 | + @Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 13 | + private Integer pageId; | ||
| 14 | 14 | ||
| 15 | @Schema(description = "页面组件", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") | 15 | @Schema(description = "页面组件", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") |
| 16 | private List<ComponentRespVO> components; | 16 | private List<ComponentRespVO> components; |
| @@ -23,10 +23,10 @@ public class DecorateComponentRespVO { | @@ -23,10 +23,10 @@ public class DecorateComponentRespVO { | ||
| 23 | private Long id; | 23 | private Long id; |
| 24 | 24 | ||
| 25 | @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") | 25 | @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") |
| 26 | - private String componentCode; | 26 | + private String code; |
| 27 | 27 | ||
| 28 | @Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO") | 28 | @Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO") |
| 29 | - private String componentValue; | 29 | + private String value; |
| 30 | 30 | ||
| 31 | } | 31 | } |
| 32 | 32 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/AppDecorateController.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.decorate; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.decorate; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO; |
| 6 | -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageTypeEnum; | 6 | +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; |
| 7 | import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; | 7 | import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; |
| 8 | import io.swagger.v3.oas.annotations.Operation; | 8 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | import io.swagger.v3.oas.annotations.Parameter; | 9 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -30,10 +30,10 @@ public class AppDecorateController { | @@ -30,10 +30,10 @@ public class AppDecorateController { | ||
| 30 | 30 | ||
| 31 | @GetMapping("/get-page-components") | 31 | @GetMapping("/get-page-components") |
| 32 | @Operation(summary = "获取装修页面组件") | 32 | @Operation(summary = "获取装修页面组件") |
| 33 | - @Parameter(name = "type", description = "页面类型", required = true) | 33 | + @Parameter(name = "pageId", description = "页面 id", required = true) |
| 34 | public CommonResult<AppDecorateComponentRespVO> getPageComponents( | 34 | public CommonResult<AppDecorateComponentRespVO> getPageComponents( |
| 35 | - @RequestParam("type") @InEnum(DecoratePageTypeEnum.class) Integer type) { | ||
| 36 | - return success(INSTANCE.appConvert(type, decorateComponentService.getPageComponents(type))); | 35 | + @RequestParam("pageId") @InEnum(DecoratePageEnum.class) Integer pageId) { |
| 36 | + return success(INSTANCE.appConvert(pageId, decorateComponentService.getPageComponents(pageId))); | ||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | } | 39 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/vo/AppDecorateComponentRespVO.java
| @@ -9,8 +9,8 @@ import java.util.List; | @@ -9,8 +9,8 @@ import java.util.List; | ||
| 9 | @Data | 9 | @Data |
| 10 | public class AppDecorateComponentRespVO { | 10 | public class AppDecorateComponentRespVO { |
| 11 | 11 | ||
| 12 | - @Schema(description = "页面类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 13 | - private Integer type; | 12 | + @Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 13 | + private Integer pageId; | ||
| 14 | 14 | ||
| 15 | @Schema(description = "页面组件", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") | 15 | @Schema(description = "页面组件", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO") |
| 16 | private List<AppComponentRespVO> components; | 16 | private List<AppComponentRespVO> components; |
| @@ -19,14 +19,11 @@ public class AppDecorateComponentRespVO { | @@ -19,14 +19,11 @@ public class AppDecorateComponentRespVO { | ||
| 19 | @Data | 19 | @Data |
| 20 | public static class AppComponentRespVO { | 20 | public static class AppComponentRespVO { |
| 21 | 21 | ||
| 22 | - @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 23 | - private Long id; | ||
| 24 | - | ||
| 25 | @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") | 22 | @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") |
| 26 | - private String componentCode; | 23 | + private String code; |
| 27 | 24 | ||
| 28 | @Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO") | 25 | @Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO") |
| 29 | - private String componentValue; | 26 | + private String value; |
| 30 | 27 | ||
| 31 | } | 28 | } |
| 32 | 29 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java
| @@ -18,23 +18,23 @@ public interface DecorateComponentConvert { | @@ -18,23 +18,23 @@ public interface DecorateComponentConvert { | ||
| 18 | 18 | ||
| 19 | DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class); | 19 | DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class); |
| 20 | 20 | ||
| 21 | - default List<DecorateComponentDO> convertList(Integer type, List<DecorateComponentReqVO.ComponentReqVO> components) { | ||
| 22 | - return CollectionUtils.convertList(components, c -> convert(type, c)); | 21 | + default List<DecorateComponentDO> convertList(Integer pageId, List<DecorateComponentReqVO.ComponentReqVO> components) { |
| 22 | + return CollectionUtils.convertList(components, c -> convert(pageId, c)); | ||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | - default DecorateComponentRespVO convert2(Integer type, List<DecorateComponentDO> list) { | 25 | + default DecorateComponentRespVO convert2(Integer pageId, List<DecorateComponentDO> list) { |
| 26 | List<ComponentRespVO> components = CollectionUtils.convertList(list, this::convert3); | 26 | List<ComponentRespVO> components = CollectionUtils.convertList(list, this::convert3); |
| 27 | - return new DecorateComponentRespVO().setType(type).setComponents(components); | 27 | + return new DecorateComponentRespVO().setPageId(pageId).setComponents(components); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | - DecorateComponentDO convert(Integer type, DecorateComponentReqVO.ComponentReqVO reqVO); | 30 | + DecorateComponentDO convert(Integer pageId, DecorateComponentReqVO.ComponentReqVO reqVO); |
| 31 | 31 | ||
| 32 | ComponentRespVO convert3(DecorateComponentDO componentDO); | 32 | ComponentRespVO convert3(DecorateComponentDO componentDO); |
| 33 | 33 | ||
| 34 | // ========== App convert ========== | 34 | // ========== App convert ========== |
| 35 | - default AppDecorateComponentRespVO appConvert(Integer type, List<DecorateComponentDO> list) { | 35 | + default AppDecorateComponentRespVO appConvert(Integer pageId, List<DecorateComponentDO> list) { |
| 36 | List<AppComponentRespVO> components = CollectionUtils.convertList(list, this::appConvert2); | 36 | List<AppComponentRespVO> components = CollectionUtils.convertList(list, this::appConvert2); |
| 37 | - return new AppDecorateComponentRespVO().setType(type).setComponents(components); | 37 | + return new AppDecorateComponentRespVO().setPageId(pageId).setComponents(components); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | AppComponentRespVO appConvert2(DecorateComponentDO bean); | 40 | AppComponentRespVO appConvert2(DecorateComponentDO bean); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/decorate/DecorateComponentDO.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.decorate; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.decorate; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageTypeEnum; | 5 | +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; |
| 6 | import cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum; | 6 | import cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum; |
| 7 | import com.baomidou.mybatisplus.annotation.*; | 7 | import com.baomidou.mybatisplus.annotation.*; |
| 8 | 8 | ||
| @@ -24,23 +24,22 @@ public class DecorateComponentDO extends BaseDO { | @@ -24,23 +24,22 @@ public class DecorateComponentDO extends BaseDO { | ||
| 24 | @TableId | 24 | @TableId |
| 25 | private Long id; | 25 | private Long id; |
| 26 | 26 | ||
| 27 | - // TODO @jason:要不改成 page?貌似更合理; | ||
| 28 | /** | 27 | /** |
| 29 | - * 页面类型 | ||
| 30 | - * 枚举 {@link DecoratePageTypeEnum#getType()} | 28 | + * 所属页面 id |
| 29 | + * 枚举 {@link DecoratePageEnum#getId()} | ||
| 31 | */ | 30 | */ |
| 32 | - private Integer type; | 31 | + private Integer pageId; |
| 33 | 32 | ||
| 34 | - // TODO @jason:code、value,因为在 component | ||
| 35 | /** | 33 | /** |
| 36 | * 组件编码 | 34 | * 组件编码 |
| 37 | * 枚举 {@link DecorateComponentEnum#getCode()} | 35 | * 枚举 {@link DecorateComponentEnum#getCode()} |
| 38 | */ | 36 | */ |
| 39 | - private String componentCode; | 37 | + private String code; |
| 38 | + | ||
| 40 | /** | 39 | /** |
| 41 | * 组件值:json 格式。包含配置和数据 | 40 | * 组件值:json 格式。包含配置和数据 |
| 42 | */ | 41 | */ |
| 43 | - private String componentValue; | 42 | + private String value; |
| 44 | 43 | ||
| 45 | /** | 44 | /** |
| 46 | * 状态 | 45 | * 状态 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/decorate/DecorateComponentMapper.java
| @@ -9,8 +9,8 @@ import java.util.List; | @@ -9,8 +9,8 @@ import java.util.List; | ||
| 9 | @Mapper | 9 | @Mapper |
| 10 | public interface DecorateComponentMapper extends BaseMapperX<DecorateComponentDO> { | 10 | public interface DecorateComponentMapper extends BaseMapperX<DecorateComponentDO> { |
| 11 | 11 | ||
| 12 | - default List<DecorateComponentDO> selectByPageType(Integer type){ | ||
| 13 | - return selectList(DecorateComponentDO::getType, type); | 12 | + default List<DecorateComponentDO> selectByPage(Integer pageId){ |
| 13 | + return selectList(DecorateComponentDO::getPageId, pageId); | ||
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | } | 16 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.service.decorate; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.service.decorate; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; | 3 | import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentReqVO; |
| 4 | import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; | 4 | import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; |
| 5 | -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageTypeEnum; | 5 | +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; |
| 6 | 6 | ||
| 7 | import java.util.List; | 7 | import java.util.List; |
| 8 | 8 | ||
| @@ -21,10 +21,10 @@ public interface DecorateComponentService { | @@ -21,10 +21,10 @@ public interface DecorateComponentService { | ||
| 21 | void pageSave(DecorateComponentReqVO reqVO); | 21 | void pageSave(DecorateComponentReqVO reqVO); |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
| 24 | - * 根据页面类型。获取页面的组件信息 | 24 | + * 根据页面 id。获取页面的组件信息 |
| 25 | * | 25 | * |
| 26 | - * @param type 页面类型 {@link DecoratePageTypeEnum#getType()} | 26 | + * @param pageId 页面类型 {@link DecoratePageEnum#getId()} |
| 27 | */ | 27 | */ |
| 28 | - List<DecorateComponentDO> getPageComponents(Integer type); | 28 | + List<DecorateComponentDO> getPageComponents(Integer pageId); |
| 29 | 29 | ||
| 30 | } | 30 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java
| @@ -29,9 +29,9 @@ public class DecorateComponentServiceImpl implements DecorateComponentService { | @@ -29,9 +29,9 @@ public class DecorateComponentServiceImpl implements DecorateComponentService { | ||
| 29 | @Override | 29 | @Override |
| 30 | public void pageSave(DecorateComponentReqVO reqVO) { | 30 | public void pageSave(DecorateComponentReqVO reqVO) { |
| 31 | // 1.新增或修改页面组件 | 31 | // 1.新增或修改页面组件 |
| 32 | - List<DecorateComponentDO> oldList = decorateComponentMapper.selectByPageType(reqVO.getType()); | 32 | + List<DecorateComponentDO> oldList = decorateComponentMapper.selectByPage(reqVO.getPageId()); |
| 33 | 33 | ||
| 34 | - decorateComponentMapper.saveOrUpdateBatch(INSTANCE.convertList(reqVO.getType(), reqVO.getComponents())); | 34 | + decorateComponentMapper.saveOrUpdateBatch(INSTANCE.convertList(reqVO.getPageId(), reqVO.getComponents())); |
| 35 | // 2.删除相关组件 | 35 | // 2.删除相关组件 |
| 36 | Set<Long> deleteIds = convertSet(oldList, DecorateComponentDO::getId); | 36 | Set<Long> deleteIds = convertSet(oldList, DecorateComponentDO::getId); |
| 37 | deleteIds.removeAll(convertSet(reqVO.getComponents(), ComponentReqVO::getId, vo->Objects.nonNull(vo.getId()))); | 37 | deleteIds.removeAll(convertSet(reqVO.getComponents(), ComponentReqVO::getId, vo->Objects.nonNull(vo.getId()))); |
| @@ -41,8 +41,8 @@ public class DecorateComponentServiceImpl implements DecorateComponentService { | @@ -41,8 +41,8 @@ public class DecorateComponentServiceImpl implements DecorateComponentService { | ||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | @Override | 43 | @Override |
| 44 | - public List<DecorateComponentDO> getPageComponents(Integer type) { | ||
| 45 | - return decorateComponentMapper.selectByPageType(type); | 44 | + public List<DecorateComponentDO> getPageComponents(Integer pageId) { |
| 45 | + return decorateComponentMapper.selectByPage(pageId); | ||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | } | 48 | } |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java
| @@ -13,7 +13,7 @@ import java.util.ArrayList; | @@ -13,7 +13,7 @@ import java.util.ArrayList; | ||
| 13 | import java.util.List; | 13 | import java.util.List; |
| 14 | 14 | ||
| 15 | import static cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum.ROLLING_BANNER; | 15 | import static cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum.ROLLING_BANNER; |
| 16 | -import static cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageTypeEnum.INDEX; | 16 | +import static cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum.INDEX; |
| 17 | import static org.mockito.ArgumentMatchers.eq; | 17 | import static org.mockito.ArgumentMatchers.eq; |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| @@ -36,10 +36,10 @@ public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest { | @@ -36,10 +36,10 @@ public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest { | ||
| 36 | void testResp(){ | 36 | void testResp(){ |
| 37 | List<DecorateComponentDO> list = new ArrayList<>(1); | 37 | List<DecorateComponentDO> list = new ArrayList<>(1); |
| 38 | DecorateComponentDO decorateDO = new DecorateComponentDO() | 38 | DecorateComponentDO decorateDO = new DecorateComponentDO() |
| 39 | - .setType(INDEX.getType()).setComponentValue("") | ||
| 40 | - .setComponentCode(ROLLING_BANNER.getCode()).setId(1L); | 39 | + .setPageId(INDEX.getId()).setValue("") |
| 40 | + .setCode(ROLLING_BANNER.getCode()).setId(1L); | ||
| 41 | list.add(decorateDO); | 41 | list.add(decorateDO); |
| 42 | //mock 方法 | 42 | //mock 方法 |
| 43 | - Mockito.when(decorateComponentMapper.selectByPageType(eq(1))).thenReturn(list); | 43 | + Mockito.when(decorateComponentMapper.selectByPage(eq(1))).thenReturn(list); |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | \ No newline at end of file | 46 | \ No newline at end of file |