Commit 48b1c19f281025ab5a259afab87e18695633aab4
Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
Showing
29 changed files
with
1381 additions
and
8 deletions
sql/mysql/mall.sql
| 1 | 1 | INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) |
| 2 | -VALUES ('核销订单', '', 2, 2, 2166, 'pick-up-order', 'ep:list', 'mall/trade/delivery/pickUpOrder/index', 'PickUpOrder'); | |
| 3 | 2 | \ No newline at end of file |
| 3 | +VALUES ('核销订单', '', 2, 2, 2166, 'pick-up-order', 'ep:list', 'mall/trade/delivery/pickUpOrder/index', 'PickUpOrder'); | |
| 4 | + | |
| 5 | +CREATE TABLE promotion_diy_template | |
| 6 | +( | |
| 7 | + id bigint AUTO_INCREMENT COMMENT '装修模板编号' | |
| 8 | + PRIMARY KEY, | |
| 9 | + name varchar(100) NOT NULL COMMENT '模板名称', | |
| 10 | + used bit DEFAULT b'0' NOT NULL COMMENT '是否使用', | |
| 11 | + used_time datetime NULL COMMENT '使用时间', | |
| 12 | + remark varchar(255) NULL COMMENT '备注', | |
| 13 | + preview_image_urls varchar(2000) NULL COMMENT '预览图,多个逗号分隔', | |
| 14 | + property text NULL COMMENT '页面属性,JSON 格式', | |
| 15 | + creator varchar(64) DEFAULT '' NULL COMMENT '创建者', | |
| 16 | + create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间', | |
| 17 | + updater varchar(64) DEFAULT '' NULL COMMENT '更新者', | |
| 18 | + update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 19 | + deleted bit DEFAULT b'0' NOT NULL COMMENT '是否删除', | |
| 20 | + tenant_id bigint DEFAULT 0 NOT NULL COMMENT '租户编号' | |
| 21 | +) | |
| 22 | + COMMENT '装修模板'; | |
| 23 | + | |
| 24 | +CREATE TABLE promotion_diy_page | |
| 25 | +( | |
| 26 | + id bigint AUTO_INCREMENT COMMENT '装修页面编号' | |
| 27 | + PRIMARY KEY, | |
| 28 | + template_id bigint NULL COMMENT '装修模板编号', | |
| 29 | + name varchar(100) NOT NULL COMMENT '页面名称', | |
| 30 | + remark varchar(255) NULL COMMENT '备注', | |
| 31 | + preview_image_urls varchar(2000) NULL COMMENT '预览图,多个逗号分隔', | |
| 32 | + property text NULL COMMENT '页面属性,JSON 格式', | |
| 33 | + creator varchar(64) DEFAULT '' NULL COMMENT '创建者', | |
| 34 | + create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间', | |
| 35 | + updater varchar(64) DEFAULT '' NULL COMMENT '更新者', | |
| 36 | + update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 37 | + deleted bit DEFAULT b'0' NOT NULL COMMENT '是否删除', | |
| 38 | + tenant_id bigint DEFAULT 0 NOT NULL COMMENT '租户编号' | |
| 39 | +) | |
| 40 | + COMMENT '装修页面'; | |
| 41 | + | |
| 42 | +CREATE INDEX idx_template_id ON promotion_diy_page (template_id); | |
| 43 | + | |
| 44 | +-- 装修,上级菜单:营销中心 | |
| 45 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) | |
| 46 | +VALUES ('商城装修', '', 2, 20, 2030, 'diy-template', 'fa6-solid:brush', 'mall/promotion/diy/template/index', 0, 'DiyTemplate'); | |
| 47 | +SELECT @diyParentId := LAST_INSERT_ID(); | |
| 48 | + | |
| 49 | +-- 装修模板 | |
| 50 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) | |
| 51 | +VALUES ('装修模板', '', 2, 1, @diyParentId, 'diy-template', 'fa6-solid:brush', 'mall/promotion/diy/template/index', 0, 'DiyTemplate'); | |
| 52 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 53 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 54 | +VALUES ('装修模板查询', 'promotion:diy-template:query', 3, 1, @parentId, '', '', '', 0); | |
| 55 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 56 | +VALUES ('装修模板创建', 'promotion:diy-template:create', 3, 2, @parentId, '', '', '', 0); | |
| 57 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 58 | +VALUES ('装修模板更新', 'promotion:diy-template:update', 3, 3, @parentId, '', '', '', 0); | |
| 59 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 60 | +VALUES ('装修模板删除', 'promotion:diy-template:delete', 3, 4, @parentId, '', '', '', 0); | |
| 61 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 62 | +VALUES ('装修模板使用', 'promotion:diy-template:use', 3, 5, @parentId, '', '', '', 0); | |
| 63 | + | |
| 64 | +-- 装修页面 | |
| 65 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) | |
| 66 | +VALUES ('装修页面', '', 2, 2, @diyParentId, 'diy-page', 'foundation:page-edit', 'mall/promotion/diy/page/index', 0, 'DiyPage'); | |
| 67 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 68 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 69 | +VALUES ('装修页面查询', 'promotion:diy-page:query', 3, 1, @parentId, '', '', '', 0); | |
| 70 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 71 | +VALUES ('装修页面创建', 'promotion:diy-page:create', 3, 2, @parentId, '', '', '', 0); | |
| 72 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 73 | +VALUES ('装修页面更新', 'promotion:diy-page:update', 3, 3, @parentId, '', '', '', 0); | |
| 74 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 75 | +VALUES ('装修页面删除', 'promotion:diy-page:delete', 3, 4, @parentId, '', '', '', 0);; | |
| 4 | 76 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| ... | ... | @@ -116,4 +116,11 @@ public interface ErrorCodeConstants { |
| 116 | 116 | // ========== 文章管理 1-013-016-000 ========== |
| 117 | 117 | ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在"); |
| 118 | 118 | |
| 119 | + // ========== 装修模板 1-013-017-000 ========== | |
| 120 | + ErrorCode DIY_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_017_000, "装修模板不存在"); | |
| 121 | + ErrorCode DIY_TEMPLATE_USED_CANNOT_DELETE = new ErrorCode(1_013_017_001, "不能删除正在使用的装修模板"); | |
| 122 | + | |
| 123 | + // ========== 装修页面 1-013-018-000 ========== | |
| 124 | + ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); | |
| 125 | + | |
| 119 | 126 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageRespVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; | |
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | |
| 11 | +import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; | |
| 12 | +import io.swagger.v3.oas.annotations.Operation; | |
| 13 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 14 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | +import org.springframework.validation.annotation.Validated; | |
| 17 | +import org.springframework.web.bind.annotation.*; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import javax.validation.Valid; | |
| 21 | +import java.util.Collection; | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 24 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 25 | + | |
| 26 | +@Tag(name = "管理后台 - 装修页面") | |
| 27 | +@RestController | |
| 28 | +@RequestMapping("/promotion/diy-page") | |
| 29 | +@Validated | |
| 30 | +public class DiyPageController { | |
| 31 | + | |
| 32 | + @Resource | |
| 33 | + private DiyPageService diyPageService; | |
| 34 | + | |
| 35 | + @PostMapping("/create") | |
| 36 | + @Operation(summary = "创建装修页面") | |
| 37 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:create')") | |
| 38 | + public CommonResult<Long> createDiyPage(@Valid @RequestBody DiyPageCreateReqVO createReqVO) { | |
| 39 | + return success(diyPageService.createDiyPage(createReqVO)); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @PutMapping("/update") | |
| 43 | + @Operation(summary = "更新装修页面") | |
| 44 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") | |
| 45 | + public CommonResult<Boolean> updateDiyPage(@Valid @RequestBody DiyPageUpdateReqVO updateReqVO) { | |
| 46 | + diyPageService.updateDiyPage(updateReqVO); | |
| 47 | + return success(true); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @DeleteMapping("/delete") | |
| 51 | + @Operation(summary = "删除装修页面") | |
| 52 | + @Parameter(name = "id", description = "编号", required = true) | |
| 53 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:delete')") | |
| 54 | + public CommonResult<Boolean> deleteDiyPage(@RequestParam("id") Long id) { | |
| 55 | + diyPageService.deleteDiyPage(id); | |
| 56 | + return success(true); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @GetMapping("/get") | |
| 60 | + @Operation(summary = "获得装修页面") | |
| 61 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 62 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") | |
| 63 | + public CommonResult<DiyPageRespVO> getDiyPage(@RequestParam("id") Long id) { | |
| 64 | + DiyPageDO diyPage = diyPageService.getDiyPage(id); | |
| 65 | + return success(DiyPageConvert.INSTANCE.convert(diyPage)); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @GetMapping("/list") | |
| 69 | + @Operation(summary = "获得装修页面列表") | |
| 70 | + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | |
| 71 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") | |
| 72 | + public CommonResult<List<DiyPageRespVO>> getDiyPageList(@RequestParam("ids") Collection<Long> ids) { | |
| 73 | + List<DiyPageDO> list = diyPageService.getDiyPageList(ids); | |
| 74 | + return success(DiyPageConvert.INSTANCE.convertList(list)); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @GetMapping("/page") | |
| 78 | + @Operation(summary = "获得装修页面分页") | |
| 79 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") | |
| 80 | + public CommonResult<PageResult<DiyPageRespVO>> getDiyPagePage(@Valid DiyPagePageReqVO pageVO) { | |
| 81 | + PageResult<DiyPageDO> pageResult = diyPageService.getDiyPagePage(pageVO); | |
| 82 | + return success(DiyPageConvert.INSTANCE.convertPage(pageResult)); | |
| 83 | + } | |
| 84 | + | |
| 85 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateRespVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; | |
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | |
| 11 | +import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; | |
| 12 | +import io.swagger.v3.oas.annotations.Operation; | |
| 13 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 14 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | +import org.springframework.validation.annotation.Validated; | |
| 17 | +import org.springframework.web.bind.annotation.*; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import javax.validation.Valid; | |
| 21 | + | |
| 22 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 23 | + | |
| 24 | +@Tag(name = "管理后台 - 装修模板") | |
| 25 | +@RestController | |
| 26 | +@RequestMapping("/promotion/diy-template") | |
| 27 | +@Validated | |
| 28 | +public class DiyTemplateController { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private DiyTemplateService diyTemplateService; | |
| 32 | + | |
| 33 | + @PostMapping("/create") | |
| 34 | + @Operation(summary = "创建装修模板") | |
| 35 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:create')") | |
| 36 | + public CommonResult<Long> createDiyTemplate(@Valid @RequestBody DiyTemplateCreateReqVO createReqVO) { | |
| 37 | + return success(diyTemplateService.createDiyTemplate(createReqVO)); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @PutMapping("/update") | |
| 41 | + @Operation(summary = "更新装修模板") | |
| 42 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") | |
| 43 | + public CommonResult<Boolean> updateDiyTemplate(@Valid @RequestBody DiyTemplateUpdateReqVO updateReqVO) { | |
| 44 | + diyTemplateService.updateDiyTemplate(updateReqVO); | |
| 45 | + return success(true); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @PutMapping("/use") | |
| 49 | + @Operation(summary = "使用装修模板") | |
| 50 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:use')") | |
| 51 | + public CommonResult<Boolean> useDiyTemplate(@RequestParam("id") Long id) { | |
| 52 | + diyTemplateService.useDiyTemplate(id); | |
| 53 | + return success(true); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @DeleteMapping("/delete") | |
| 57 | + @Operation(summary = "删除装修模板") | |
| 58 | + @Parameter(name = "id", description = "编号", required = true) | |
| 59 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:delete')") | |
| 60 | + public CommonResult<Boolean> deleteDiyTemplate(@RequestParam("id") Long id) { | |
| 61 | + diyTemplateService.deleteDiyTemplate(id); | |
| 62 | + return success(true); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @GetMapping("/get") | |
| 66 | + @Operation(summary = "获得装修模板") | |
| 67 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 68 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") | |
| 69 | + public CommonResult<DiyTemplateRespVO> getDiyTemplate(@RequestParam("id") Long id) { | |
| 70 | + DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); | |
| 71 | + return success(DiyTemplateConvert.INSTANCE.convert(diyTemplate)); | |
| 72 | + } | |
| 73 | + | |
| 74 | + @GetMapping("/page") | |
| 75 | + @Operation(summary = "获得装修模板分页") | |
| 76 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") | |
| 77 | + public CommonResult<PageResult<DiyTemplateRespVO>> getDiyTemplatePage(@Valid DiyTemplatePageReqVO pageVO) { | |
| 78 | + PageResult<DiyTemplateDO> pageResult = diyTemplateService.getDiyTemplatePage(pageVO); | |
| 79 | + return success(DiyTemplateConvert.INSTANCE.convertPage(pageResult)); | |
| 80 | + } | |
| 81 | + | |
| 82 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 装修页面 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 11 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +public class DiyPageBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "装修模板编号", example = "26179") | |
| 17 | + private Long templateId; | |
| 18 | + | |
| 19 | + @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | |
| 20 | + @NotNull(message = "页面名称不能为空") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "备注", example = "随便") | |
| 24 | + private String remark; | |
| 25 | + | |
| 26 | + @Schema(description = "预览图") | |
| 27 | + private List<String> previewImageUrls; | |
| 28 | + | |
| 29 | + @Schema(description = "页面属性", example = "[]") | |
| 30 | + private String property; | |
| 31 | + | |
| 32 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 装修页面创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class DiyPageCreateReqVO extends DiyPageBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 装修页面分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class DiyPagePageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "页面名称", example = "王五") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "创建时间") | |
| 24 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 25 | + private LocalDateTime[] createTime; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 装修页面 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class DiyPageRespVO extends DiyPageBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 装修页面更新 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class DiyPageUpdateReqVO extends DiyPageBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") | |
| 17 | + @NotNull(message = "装修页面编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 装修模板 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 11 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +public class DiyTemplateBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") | |
| 17 | + @NotNull(message = "模板名称不能为空") | |
| 18 | + private String name; | |
| 19 | + | |
| 20 | + @Schema(description = "备注", example = "默认主题") | |
| 21 | + private String remark; | |
| 22 | + | |
| 23 | + @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") | |
| 24 | + private List<String> previewImageUrls; | |
| 25 | + | |
| 26 | + @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | |
| 27 | + private String property; | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 装修模板创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class DiyTemplateCreateReqVO extends DiyTemplateBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 装修模板分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class DiyTemplatePageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "模板名称", example = "默认主题") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "是否使用", example = "true") | |
| 24 | + private Boolean used; | |
| 25 | + | |
| 26 | + @Schema(description = "使用时间", example = "使用时间") | |
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 28 | + private LocalDateTime[] usedTime; | |
| 29 | + | |
| 30 | + @Schema(description = "创建时间") | |
| 31 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 32 | + private LocalDateTime[] createTime; | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 装修模板 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class DiyTemplateRespVO extends DiyTemplateBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | + @Schema(description = "是否使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 23 | + private Boolean used; | |
| 24 | + | |
| 25 | + @Schema(description = "使用时间", example = "使用时间") | |
| 26 | + private LocalDateTime usedTime; | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 装修模板更新 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class DiyTemplateUpdateReqVO extends DiyTemplateBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | |
| 17 | + @NotNull(message = "装修模板编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.convert.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageRespVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | |
| 8 | +import org.mapstruct.Mapper; | |
| 9 | +import org.mapstruct.factory.Mappers; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 装修页面 Convert | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@Mapper | |
| 19 | +public interface DiyPageConvert { | |
| 20 | + | |
| 21 | + DiyPageConvert INSTANCE = Mappers.getMapper(DiyPageConvert.class); | |
| 22 | + | |
| 23 | + DiyPageDO convert(DiyPageCreateReqVO bean); | |
| 24 | + | |
| 25 | + DiyPageDO convert(DiyPageUpdateReqVO bean); | |
| 26 | + | |
| 27 | + DiyPageRespVO convert(DiyPageDO bean); | |
| 28 | + | |
| 29 | + List<DiyPageRespVO> convertList(List<DiyPageDO> list); | |
| 30 | + | |
| 31 | + PageResult<DiyPageRespVO> convertPage(PageResult<DiyPageDO> page); | |
| 32 | + | |
| 33 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.convert.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateRespVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | |
| 8 | +import org.mapstruct.Mapper; | |
| 9 | +import org.mapstruct.factory.Mappers; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 装修模板 Convert | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@Mapper | |
| 19 | +public interface DiyTemplateConvert { | |
| 20 | + | |
| 21 | + DiyTemplateConvert INSTANCE = Mappers.getMapper(DiyTemplateConvert.class); | |
| 22 | + | |
| 23 | + DiyTemplateDO convert(DiyTemplateCreateReqVO bean); | |
| 24 | + | |
| 25 | + DiyTemplateDO convert(DiyTemplateUpdateReqVO bean); | |
| 26 | + | |
| 27 | + DiyTemplateRespVO convert(DiyTemplateDO bean); | |
| 28 | + | |
| 29 | + List<DiyTemplateRespVO> convertList(List<DiyTemplateDO> list); | |
| 30 | + | |
| 31 | + PageResult<DiyTemplateRespVO> convertPage(PageResult<DiyTemplateDO> page); | |
| 32 | + | |
| 33 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 装修页面 DO | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@TableName(value = "promotion_diy_page", autoResultMap = true) | |
| 19 | +@KeySequence("promotion_diy_page_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class DiyPageDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 装修页面编号 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Long id; | |
| 33 | + /** | |
| 34 | + * 装修模板编号 | |
| 35 | + */ | |
| 36 | + private Long templateId; | |
| 37 | + /** | |
| 38 | + * 页面名称 | |
| 39 | + */ | |
| 40 | + private String name; | |
| 41 | + /** | |
| 42 | + * 备注 | |
| 43 | + */ | |
| 44 | + private String remark; | |
| 45 | + /** | |
| 46 | + * 预览图,多个逗号分隔 | |
| 47 | + */ | |
| 48 | + @TableField(typeHandler = StringListTypeHandler.class) | |
| 49 | + private List<String> previewImageUrls; | |
| 50 | + /** | |
| 51 | + * 页面属性,JSON 格式 | |
| 52 | + */ | |
| 53 | + private String property; | |
| 54 | + | |
| 55 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 装修模板 DO | |
| 16 | + * | |
| 17 | + * @author owen | |
| 18 | + */ | |
| 19 | +@TableName(value = "promotion_diy_template", autoResultMap = true) | |
| 20 | +@KeySequence("promotion_diy_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 21 | +@Data | |
| 22 | +@EqualsAndHashCode(callSuper = true) | |
| 23 | +@ToString(callSuper = true) | |
| 24 | +@Builder | |
| 25 | +@NoArgsConstructor | |
| 26 | +@AllArgsConstructor | |
| 27 | +public class DiyTemplateDO extends BaseDO { | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 装修模板编号 | |
| 31 | + */ | |
| 32 | + @TableId | |
| 33 | + private Long id; | |
| 34 | + /** | |
| 35 | + * 模板名称 | |
| 36 | + */ | |
| 37 | + private String name; | |
| 38 | + /** | |
| 39 | + * 是否使用 | |
| 40 | + */ | |
| 41 | + private Boolean used; | |
| 42 | + /** | |
| 43 | + * 使用时间 | |
| 44 | + */ | |
| 45 | + private LocalDateTime usedTime; | |
| 46 | + /** | |
| 47 | + * 备注 | |
| 48 | + */ | |
| 49 | + private String remark; | |
| 50 | + /** | |
| 51 | + * 预览图 | |
| 52 | + */ | |
| 53 | + @TableField(typeHandler = StringListTypeHandler.class) | |
| 54 | + private List<String> previewImageUrls; | |
| 55 | + /** | |
| 56 | + * 底部导航属性,JSON 格式 | |
| 57 | + */ | |
| 58 | + private String property; | |
| 59 | + | |
| 60 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 装修页面 Mapper | |
| 12 | + * | |
| 13 | + * @author owen | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface DiyPageMapper extends BaseMapperX<DiyPageDO> { | |
| 17 | + | |
| 18 | + default PageResult<DiyPageDO> selectPage(DiyPagePageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<DiyPageDO>() | |
| 20 | + .likeIfPresent(DiyPageDO::getName, reqVO.getName()) | |
| 21 | + .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime()) | |
| 22 | + .isNull(DiyPageDO::getTemplateId) | |
| 23 | + .orderByDesc(DiyPageDO::getId)); | |
| 24 | + } | |
| 25 | + | |
| 26 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 装修模板 Mapper | |
| 12 | + * | |
| 13 | + * @author owen | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface DiyTemplateMapper extends BaseMapperX<DiyTemplateDO> { | |
| 17 | + | |
| 18 | + default PageResult<DiyTemplateDO> selectPage(DiyTemplatePageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<DiyTemplateDO>() | |
| 20 | + .likeIfPresent(DiyTemplateDO::getName, reqVO.getName()) | |
| 21 | + .eqIfPresent(DiyTemplateDO::getUsed, reqVO.getUsed()) | |
| 22 | + .betweenIfPresent(DiyTemplateDO::getUsedTime, reqVO.getUsedTime()) | |
| 23 | + .betweenIfPresent(DiyTemplateDO::getCreateTime, reqVO.getCreateTime()) | |
| 24 | + .orderByDesc(DiyTemplateDO::getUsed) // 排序规则1:已使用的排到最前面 | |
| 25 | + .orderByDesc(DiyTemplateDO::getId)); // 排序规则2:新创建的排到前面 | |
| 26 | + } | |
| 27 | + | |
| 28 | + default DiyTemplateDO selectByUsed(boolean used) { | |
| 29 | + return selectOne(DiyTemplateDO::getUsed, used); | |
| 30 | + } | |
| 31 | + | |
| 32 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | |
| 8 | + | |
| 9 | +import javax.validation.Valid; | |
| 10 | +import java.util.Collection; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 装修页面 Service 接口 | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +public interface DiyPageService { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 创建装修页面 | |
| 22 | + * | |
| 23 | + * @param createReqVO 创建信息 | |
| 24 | + * @return 编号 | |
| 25 | + */ | |
| 26 | + Long createDiyPage(@Valid DiyPageCreateReqVO createReqVO); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 更新装修页面 | |
| 30 | + * | |
| 31 | + * @param updateReqVO 更新信息 | |
| 32 | + */ | |
| 33 | + void updateDiyPage(@Valid DiyPageUpdateReqVO updateReqVO); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 删除装修页面 | |
| 37 | + * | |
| 38 | + * @param id 编号 | |
| 39 | + */ | |
| 40 | + void deleteDiyPage(Long id); | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 获得装修页面 | |
| 44 | + * | |
| 45 | + * @param id 编号 | |
| 46 | + * @return 装修页面 | |
| 47 | + */ | |
| 48 | + DiyPageDO getDiyPage(Long id); | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 获得装修页面列表 | |
| 52 | + * | |
| 53 | + * @param ids 编号 | |
| 54 | + * @return 装修页面列表 | |
| 55 | + */ | |
| 56 | + List<DiyPageDO> getDiyPageList(Collection<Long> ids); | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 获得装修页面分页 | |
| 60 | + * | |
| 61 | + * @param pageReqVO 分页查询 | |
| 62 | + * @return 装修页面分页 | |
| 63 | + */ | |
| 64 | + PageResult<DiyPageDO> getDiyPagePage(DiyPagePageReqVO pageReqVO); | |
| 65 | + | |
| 66 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.diy; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.collection.ListUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; | |
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | |
| 11 | +import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | + | |
| 15 | +import javax.annotation.Resource; | |
| 16 | +import java.util.Collection; | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 20 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * 装修页面 Service 实现类 | |
| 24 | + * | |
| 25 | + * @author owen | |
| 26 | + */ | |
| 27 | +@Service | |
| 28 | +@Validated | |
| 29 | +public class DiyPageServiceImpl implements DiyPageService { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private DiyPageMapper diyPageMapper; | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public Long createDiyPage(DiyPageCreateReqVO createReqVO) { | |
| 36 | + // 插入 | |
| 37 | + DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); | |
| 38 | + diyPageMapper.insert(diyPage); | |
| 39 | + // 返回 | |
| 40 | + return diyPage.getId(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void updateDiyPage(DiyPageUpdateReqVO updateReqVO) { | |
| 45 | + // 校验存在 | |
| 46 | + validateDiyPageExists(updateReqVO.getId()); | |
| 47 | + // 更新 | |
| 48 | + DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); | |
| 49 | + diyPageMapper.updateById(updateObj); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void deleteDiyPage(Long id) { | |
| 54 | + // 校验存在 | |
| 55 | + validateDiyPageExists(id); | |
| 56 | + // 删除 | |
| 57 | + diyPageMapper.deleteById(id); | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void validateDiyPageExists(Long id) { | |
| 61 | + if (diyPageMapper.selectById(id) == null) { | |
| 62 | + throw exception(DIY_PAGE_NOT_EXISTS); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public DiyPageDO getDiyPage(Long id) { | |
| 68 | + return diyPageMapper.selectById(id); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public List<DiyPageDO> getDiyPageList(Collection<Long> ids) { | |
| 73 | + if (CollUtil.isEmpty(ids)) { | |
| 74 | + return ListUtil.empty(); | |
| 75 | + } | |
| 76 | + return diyPageMapper.selectBatchIds(ids); | |
| 77 | + } | |
| 78 | + | |
| 79 | + @Override | |
| 80 | + public PageResult<DiyPageDO> getDiyPagePage(DiyPagePageReqVO pageReqVO) { | |
| 81 | + return diyPageMapper.selectPage(pageReqVO); | |
| 82 | + } | |
| 83 | + | |
| 84 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | |
| 8 | + | |
| 9 | +import javax.validation.Valid; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 装修模板 Service 接口 | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +public interface DiyTemplateService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建装修模板 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createDiyTemplate(@Valid DiyTemplateCreateReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新装修模板 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateDiyTemplate(@Valid DiyTemplateUpdateReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除装修模板 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteDiyTemplate(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获得装修模板 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 装修模板 | |
| 45 | + */ | |
| 46 | + DiyTemplateDO getDiyTemplate(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 获得装修模板分页 | |
| 50 | + * | |
| 51 | + * @param pageReqVO 分页查询 | |
| 52 | + * @return 装修模板分页 | |
| 53 | + */ | |
| 54 | + PageResult<DiyTemplateDO> getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 使用装修模板 | |
| 58 | + * | |
| 59 | + * @param id 编号 | |
| 60 | + */ | |
| 61 | + void useDiyTemplate(Long id); | |
| 62 | + | |
| 63 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.diy; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.BooleanUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; | |
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | |
| 10 | +import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | +import java.time.LocalDateTime; | |
| 16 | + | |
| 17 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 18 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_TEMPLATE_NOT_EXISTS; | |
| 19 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_TEMPLATE_USED_CANNOT_DELETE; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 装修模板 Service 实现类 | |
| 23 | + * | |
| 24 | + * @author owen | |
| 25 | + */ | |
| 26 | +@Service | |
| 27 | +@Validated | |
| 28 | +public class DiyTemplateServiceImpl implements DiyTemplateService { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private DiyTemplateMapper diyTemplateMapper; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { | |
| 35 | + // 插入 | |
| 36 | + DiyTemplateDO diyTemplate = DiyTemplateConvert.INSTANCE.convert(createReqVO); | |
| 37 | + diyTemplateMapper.insert(diyTemplate); | |
| 38 | + // 返回 | |
| 39 | + return diyTemplate.getId(); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public void updateDiyTemplate(DiyTemplateUpdateReqVO updateReqVO) { | |
| 44 | + // 校验存在 | |
| 45 | + validateDiyTemplateExists(updateReqVO.getId()); | |
| 46 | + // 更新 | |
| 47 | + DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); | |
| 48 | + diyTemplateMapper.updateById(updateObj); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void deleteDiyTemplate(Long id) { | |
| 53 | + // 校验存在 | |
| 54 | + DiyTemplateDO diyTemplateDO = validateDiyTemplateExists(id); | |
| 55 | + // 校验使用中 | |
| 56 | + if (BooleanUtil.isTrue(diyTemplateDO.getUsed())) { | |
| 57 | + throw exception(DIY_TEMPLATE_USED_CANNOT_DELETE); | |
| 58 | + } | |
| 59 | + // 删除 | |
| 60 | + diyTemplateMapper.deleteById(id); | |
| 61 | + } | |
| 62 | + | |
| 63 | + private DiyTemplateDO validateDiyTemplateExists(Long id) { | |
| 64 | + DiyTemplateDO diyTemplateDO = diyTemplateMapper.selectById(id); | |
| 65 | + if (diyTemplateDO == null) { | |
| 66 | + throw exception(DIY_TEMPLATE_NOT_EXISTS); | |
| 67 | + } | |
| 68 | + return diyTemplateDO; | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public DiyTemplateDO getDiyTemplate(Long id) { | |
| 73 | + return diyTemplateMapper.selectById(id); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public PageResult<DiyTemplateDO> getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO) { | |
| 78 | + return diyTemplateMapper.selectPage(pageReqVO); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public void useDiyTemplate(Long id) { | |
| 83 | + // 校验存在 | |
| 84 | + validateDiyTemplateExists(id); | |
| 85 | + // 已使用的更新为未使用 | |
| 86 | + DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); | |
| 87 | + if (used != null) { | |
| 88 | + this.updateUsed(used.getId(), false, null); | |
| 89 | + } | |
| 90 | + // 更新为已使用 | |
| 91 | + this.updateUsed(id, true, LocalDateTime.now()); | |
| 92 | + } | |
| 93 | + | |
| 94 | + private void updateUsed(Long id, Boolean used, LocalDateTime usedTime) { | |
| 95 | + DiyTemplateDO updateObj = new DiyTemplateDO().setId(id) | |
| 96 | + .setUsed(used).setUsedTime(usedTime); | |
| 97 | + diyTemplateMapper.updateById(updateObj); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java
| ... | ... | @@ -18,7 +18,6 @@ import org.springframework.context.annotation.Import; |
| 18 | 18 | import javax.annotation.Resource; |
| 19 | 19 | import java.time.Duration; |
| 20 | 20 | import java.time.LocalDateTime; |
| 21 | -import java.util.Date; | |
| 22 | 21 | import java.util.List; |
| 23 | 22 | |
| 24 | 23 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper; | |
| 10 | +import org.junit.jupiter.api.Disabled; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 12 | +import org.springframework.context.annotation.Import; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 17 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 22 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; | |
| 23 | +import static org.junit.jupiter.api.Assertions.*; | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * {@link DiyPageServiceImpl} 的单元测试类 | |
| 27 | + * | |
| 28 | + * @author owen | |
| 29 | + */ | |
| 30 | +@Import(DiyPageServiceImpl.class) | |
| 31 | +public class DiyPageServiceImplTest extends BaseDbUnitTest { | |
| 32 | + | |
| 33 | + @Resource | |
| 34 | + private DiyPageServiceImpl diyPageService; | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private DiyPageMapper diyPageMapper; | |
| 38 | + | |
| 39 | + @Test | |
| 40 | + public void testCreateDiyPage_success() { | |
| 41 | + // 准备参数 | |
| 42 | + DiyPageCreateReqVO reqVO = randomPojo(DiyPageCreateReqVO.class); | |
| 43 | + | |
| 44 | + // 调用 | |
| 45 | + Long diyPageId = diyPageService.createDiyPage(reqVO); | |
| 46 | + // 断言 | |
| 47 | + assertNotNull(diyPageId); | |
| 48 | + // 校验记录的属性是否正确 | |
| 49 | + DiyPageDO diyPage = diyPageMapper.selectById(diyPageId); | |
| 50 | + assertPojoEquals(reqVO, diyPage); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Test | |
| 54 | + public void testUpdateDiyPage_success() { | |
| 55 | + // mock 数据 | |
| 56 | + DiyPageDO dbDiyPage = randomPojo(DiyPageDO.class); | |
| 57 | + diyPageMapper.insert(dbDiyPage);// @Sql: 先插入出一条存在的数据 | |
| 58 | + // 准备参数 | |
| 59 | + DiyPageUpdateReqVO reqVO = randomPojo(DiyPageUpdateReqVO.class, o -> { | |
| 60 | + o.setId(dbDiyPage.getId()); // 设置更新的 ID | |
| 61 | + }); | |
| 62 | + | |
| 63 | + // 调用 | |
| 64 | + diyPageService.updateDiyPage(reqVO); | |
| 65 | + // 校验是否更新正确 | |
| 66 | + DiyPageDO diyPage = diyPageMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 67 | + assertPojoEquals(reqVO, diyPage); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Test | |
| 71 | + public void testUpdateDiyPage_notExists() { | |
| 72 | + // 准备参数 | |
| 73 | + DiyPageUpdateReqVO reqVO = randomPojo(DiyPageUpdateReqVO.class); | |
| 74 | + | |
| 75 | + // 调用, 并断言异常 | |
| 76 | + assertServiceException(() -> diyPageService.updateDiyPage(reqVO), DIY_PAGE_NOT_EXISTS); | |
| 77 | + } | |
| 78 | + | |
| 79 | + @Test | |
| 80 | + public void testDeleteDiyPage_success() { | |
| 81 | + // mock 数据 | |
| 82 | + DiyPageDO dbDiyPage = randomPojo(DiyPageDO.class); | |
| 83 | + diyPageMapper.insert(dbDiyPage);// @Sql: 先插入出一条存在的数据 | |
| 84 | + // 准备参数 | |
| 85 | + Long id = dbDiyPage.getId(); | |
| 86 | + | |
| 87 | + // 调用 | |
| 88 | + diyPageService.deleteDiyPage(id); | |
| 89 | + // 校验数据不存在了 | |
| 90 | + assertNull(diyPageMapper.selectById(id)); | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Test | |
| 94 | + public void testDeleteDiyPage_notExists() { | |
| 95 | + // 准备参数 | |
| 96 | + Long id = randomLongId(); | |
| 97 | + | |
| 98 | + // 调用, 并断言异常 | |
| 99 | + assertServiceException(() -> diyPageService.deleteDiyPage(id), DIY_PAGE_NOT_EXISTS); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Test | |
| 103 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 104 | + public void testGetDiyPagePage() { | |
| 105 | + // mock 数据 | |
| 106 | + DiyPageDO dbDiyPage = randomPojo(DiyPageDO.class, o -> { // 等会查询到 | |
| 107 | + o.setName(null); | |
| 108 | + o.setCreateTime(null); | |
| 109 | + }); | |
| 110 | + diyPageMapper.insert(dbDiyPage); | |
| 111 | + // 测试 name 不匹配 | |
| 112 | + diyPageMapper.insert(cloneIgnoreId(dbDiyPage, o -> o.setName(null))); | |
| 113 | + // 测试 createTime 不匹配 | |
| 114 | + diyPageMapper.insert(cloneIgnoreId(dbDiyPage, o -> o.setCreateTime(null))); | |
| 115 | + // 准备参数 | |
| 116 | + DiyPagePageReqVO reqVO = new DiyPagePageReqVO(); | |
| 117 | + reqVO.setName(null); | |
| 118 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 119 | + | |
| 120 | + // 调用 | |
| 121 | + PageResult<DiyPageDO> pageResult = diyPageService.getDiyPagePage(reqVO); | |
| 122 | + // 断言 | |
| 123 | + assertEquals(1, pageResult.getTotal()); | |
| 124 | + assertEquals(1, pageResult.getList().size()); | |
| 125 | + assertPojoEquals(dbDiyPage, pageResult.getList().get(0)); | |
| 126 | + } | |
| 127 | + | |
| 128 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.diy; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; | |
| 10 | +import org.junit.jupiter.api.Disabled; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 12 | +import org.springframework.context.annotation.Import; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 17 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 22 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_TEMPLATE_NOT_EXISTS; | |
| 23 | +import static org.junit.jupiter.api.Assertions.*; | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * {@link DiyTemplateServiceImpl} 的单元测试类 | |
| 27 | + * | |
| 28 | + * @author owen | |
| 29 | + */ | |
| 30 | +@Import(DiyTemplateServiceImpl.class) | |
| 31 | +public class DiyTemplateServiceImplTest extends BaseDbUnitTest { | |
| 32 | + | |
| 33 | + @Resource | |
| 34 | + private DiyTemplateServiceImpl diyTemplateService; | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private DiyTemplateMapper diyTemplateMapper; | |
| 38 | + | |
| 39 | + @Test | |
| 40 | + public void testCreateDiyTemplate_success() { | |
| 41 | + // 准备参数 | |
| 42 | + DiyTemplateCreateReqVO reqVO = randomPojo(DiyTemplateCreateReqVO.class); | |
| 43 | + | |
| 44 | + // 调用 | |
| 45 | + Long diyTemplateId = diyTemplateService.createDiyTemplate(reqVO); | |
| 46 | + // 断言 | |
| 47 | + assertNotNull(diyTemplateId); | |
| 48 | + // 校验记录的属性是否正确 | |
| 49 | + DiyTemplateDO diyTemplate = diyTemplateMapper.selectById(diyTemplateId); | |
| 50 | + assertPojoEquals(reqVO, diyTemplate); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Test | |
| 54 | + public void testUpdateDiyTemplate_success() { | |
| 55 | + // mock 数据 | |
| 56 | + DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class); | |
| 57 | + diyTemplateMapper.insert(dbDiyTemplate);// @Sql: 先插入出一条存在的数据 | |
| 58 | + // 准备参数 | |
| 59 | + DiyTemplateUpdateReqVO reqVO = randomPojo(DiyTemplateUpdateReqVO.class, o -> { | |
| 60 | + o.setId(dbDiyTemplate.getId()); // 设置更新的 ID | |
| 61 | + }); | |
| 62 | + | |
| 63 | + // 调用 | |
| 64 | + diyTemplateService.updateDiyTemplate(reqVO); | |
| 65 | + // 校验是否更新正确 | |
| 66 | + DiyTemplateDO diyTemplate = diyTemplateMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 67 | + assertPojoEquals(reqVO, diyTemplate); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Test | |
| 71 | + public void testUpdateDiyTemplate_notExists() { | |
| 72 | + // 准备参数 | |
| 73 | + DiyTemplateUpdateReqVO reqVO = randomPojo(DiyTemplateUpdateReqVO.class); | |
| 74 | + | |
| 75 | + // 调用, 并断言异常 | |
| 76 | + assertServiceException(() -> diyTemplateService.updateDiyTemplate(reqVO), DIY_TEMPLATE_NOT_EXISTS); | |
| 77 | + } | |
| 78 | + | |
| 79 | + @Test | |
| 80 | + public void testDeleteDiyTemplate_success() { | |
| 81 | + // mock 数据 | |
| 82 | + DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class); | |
| 83 | + diyTemplateMapper.insert(dbDiyTemplate);// @Sql: 先插入出一条存在的数据 | |
| 84 | + // 准备参数 | |
| 85 | + Long id = dbDiyTemplate.getId(); | |
| 86 | + | |
| 87 | + // 调用 | |
| 88 | + diyTemplateService.deleteDiyTemplate(id); | |
| 89 | + // 校验数据不存在了 | |
| 90 | + assertNull(diyTemplateMapper.selectById(id)); | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Test | |
| 94 | + public void testDeleteDiyTemplate_notExists() { | |
| 95 | + // 准备参数 | |
| 96 | + Long id = randomLongId(); | |
| 97 | + | |
| 98 | + // 调用, 并断言异常 | |
| 99 | + assertServiceException(() -> diyTemplateService.deleteDiyTemplate(id), DIY_TEMPLATE_NOT_EXISTS); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Test | |
| 103 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 104 | + public void testGetDiyTemplatePage() { | |
| 105 | + // mock 数据 | |
| 106 | + DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class, o -> { // 等会查询到 | |
| 107 | + o.setName(null); | |
| 108 | + o.setUsed(null); | |
| 109 | + o.setUsedTime(null); | |
| 110 | + o.setRemark(null); | |
| 111 | + o.setPreviewImageUrls(null); | |
| 112 | + o.setProperty(null); | |
| 113 | + o.setCreateTime(null); | |
| 114 | + }); | |
| 115 | + diyTemplateMapper.insert(dbDiyTemplate); | |
| 116 | + // 测试 name 不匹配 | |
| 117 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setName(null))); | |
| 118 | + // 测试 used 不匹配 | |
| 119 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsed(null))); | |
| 120 | + // 测试 usedTime 不匹配 | |
| 121 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); | |
| 122 | + // 测试 remark 不匹配 | |
| 123 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); | |
| 124 | + // 测试 previewImageUrls 不匹配 | |
| 125 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); | |
| 126 | + // 测试 property 不匹配 | |
| 127 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); | |
| 128 | + // 测试 createTime 不匹配 | |
| 129 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setCreateTime(null))); | |
| 130 | + // 准备参数 | |
| 131 | + DiyTemplatePageReqVO reqVO = new DiyTemplatePageReqVO(); | |
| 132 | + reqVO.setName(null); | |
| 133 | + reqVO.setUsed(null); | |
| 134 | + reqVO.setUsedTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 135 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 136 | + | |
| 137 | + // 调用 | |
| 138 | + PageResult<DiyTemplateDO> pageResult = diyTemplateService.getDiyTemplatePage(reqVO); | |
| 139 | + // 断言 | |
| 140 | + assertEquals(1, pageResult.getTotal()); | |
| 141 | + assertEquals(1, pageResult.getList().size()); | |
| 142 | + assertPojoEquals(dbDiyTemplate, pageResult.getList().get(0)); | |
| 143 | + } | |
| 144 | + | |
| 145 | + @Test | |
| 146 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 147 | + public void testGetDiyTemplateList() { | |
| 148 | + // mock 数据 | |
| 149 | + DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class, o -> { // 等会查询到 | |
| 150 | + o.setName(null); | |
| 151 | + o.setUsed(null); | |
| 152 | + o.setUsedTime(null); | |
| 153 | + o.setRemark(null); | |
| 154 | + o.setPreviewImageUrls(null); | |
| 155 | + o.setProperty(null); | |
| 156 | + o.setCreateTime(null); | |
| 157 | + }); | |
| 158 | + diyTemplateMapper.insert(dbDiyTemplate); | |
| 159 | + // 测试 name 不匹配 | |
| 160 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setName(null))); | |
| 161 | + // 测试 used 不匹配 | |
| 162 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsed(null))); | |
| 163 | + // 测试 usedTime 不匹配 | |
| 164 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); | |
| 165 | + // 测试 remark 不匹配 | |
| 166 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); | |
| 167 | + // 测试 previewImageUrls 不匹配 | |
| 168 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); | |
| 169 | + // 测试 property 不匹配 | |
| 170 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); | |
| 171 | + // 测试 createTime 不匹配 | |
| 172 | + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setCreateTime(null))); | |
| 173 | + } | |
| 174 | + | |
| 175 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql
| ... | ... | @@ -6,7 +6,7 @@ DELETE FROM "promotion_discount_activity"; |
| 6 | 6 | DELETE FROM "promotion_discount_product"; |
| 7 | 7 | DELETE FROM "promotion_seckill_config"; |
| 8 | 8 | DELETE FROM "promotion_combination_activity"; |
| 9 | -DELETE | |
| 10 | -FROM "promotion_article_category"; | |
| 11 | -DELETE | |
| 12 | -FROM "promotion_article"; | |
| 9 | +DELETE FROM "promotion_article_category"; | |
| 10 | +DELETE FROM "promotion_article"; | |
| 11 | +DELETE FROM "promotion_diy_template"; | |
| 12 | +DELETE FROM "promotion_diy_page"; | |
| 13 | 13 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -112,7 +112,6 @@ CREATE TABLE IF NOT EXISTS "promotion_discount_activity" |
| 112 | 112 | PRIMARY KEY ("id") |
| 113 | 113 | ) COMMENT '限时折扣活动'; |
| 114 | 114 | |
| 115 | --- 将该建表 SQL 语句,添加到 yudao-module-promotion-biz 模块的 test/resources/sql/create_tables.sql 文件里 | |
| 116 | 115 | CREATE TABLE IF NOT EXISTS "promotion_seckill_activity" |
| 117 | 116 | ( |
| 118 | 117 | "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, |
| ... | ... | @@ -220,4 +219,38 @@ CREATE TABLE IF NOT EXISTS "promotion_article" |
| 220 | 219 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 221 | 220 | "tenant_id" bigint NOT NULL, |
| 222 | 221 | PRIMARY KEY ("id") |
| 223 | -) COMMENT '文章管理表'; | |
| 224 | 222 | \ No newline at end of file |
| 223 | +) COMMENT '文章管理表'; | |
| 224 | + | |
| 225 | +CREATE TABLE IF NOT EXISTS "promotion_diy_template" | |
| 226 | +( | |
| 227 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 228 | + "name" varchar NOT NULL, | |
| 229 | + "used" bit NOT NULL, | |
| 230 | + "used_time" varchar, | |
| 231 | + "remark" varchar, | |
| 232 | + "preview_image_urls" varchar, | |
| 233 | + "property" varchar NOT NULL, | |
| 234 | + "creator" varchar DEFAULT '', | |
| 235 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 236 | + "updater" varchar DEFAULT '', | |
| 237 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
| 238 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 239 | + "tenant_id" bigint NOT NULL DEFAULT 0, | |
| 240 | + PRIMARY KEY ("id") | |
| 241 | +) COMMENT '装修模板'; | |
| 242 | +CREATE TABLE IF NOT EXISTS "promotion_diy_page" | |
| 243 | +( | |
| 244 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 245 | + "template_id" bigint NOT NULL, | |
| 246 | + "name" varchar NOT NULL, | |
| 247 | + "remark" varchar, | |
| 248 | + "preview_image_urls" varchar, | |
| 249 | + "property" varchar, | |
| 250 | + "creator" varchar DEFAULT '', | |
| 251 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 252 | + "updater" varchar DEFAULT '', | |
| 253 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
| 254 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 255 | + "tenant_id" bigint NOT NULL, | |
| 256 | + PRIMARY KEY ("id") | |
| 257 | +) COMMENT '装修页面'; | |
| 225 | 258 | \ No newline at end of file | ... | ... |