Commit cf114409b00ccea8a81754315aa0faaacdd9902e
Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
Showing
17 changed files
with
295 additions
and
23 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| @@ -118,9 +118,11 @@ public interface ErrorCodeConstants { | @@ -118,9 +118,11 @@ public interface ErrorCodeConstants { | ||
| 118 | 118 | ||
| 119 | // ========== 装修模板 1-013-017-000 ========== | 119 | // ========== 装修模板 1-013-017-000 ========== |
| 120 | ErrorCode DIY_TEMPLATE_NOT_EXISTS = new ErrorCode(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, "不能删除正在使用的装修模板"); | 121 | + ErrorCode DIY_TEMPLATE_NAME_USED = new ErrorCode(1_013_017_001, "装修模板名称({})已经被使用"); |
| 122 | + ErrorCode DIY_TEMPLATE_USED_CANNOT_DELETE = new ErrorCode(1_013_017_002, "不能删除正在使用的装修模板"); | ||
| 122 | 123 | ||
| 123 | // ========== 装修页面 1-013-018-000 ========== | 124 | // ========== 装修页面 1-013-018-000 ========== |
| 124 | ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); | 125 | ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); |
| 126 | + ErrorCode DIY_PAGE_NAME_USED = new ErrorCode(1_013_018_001, "装修页面名称({})已经被使用"); | ||
| 125 | 127 | ||
| 126 | } | 128 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java
| @@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.diy; | @@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.diy; | ||
| 2 | 2 | ||
| 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.pojo.PageResult; | 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; | 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; |
| 9 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; | 6 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| 11 | import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; | 8 | import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; |
| @@ -82,4 +79,21 @@ public class DiyPageController { | @@ -82,4 +79,21 @@ public class DiyPageController { | ||
| 82 | return success(DiyPageConvert.INSTANCE.convertPage(pageResult)); | 79 | return success(DiyPageConvert.INSTANCE.convertPage(pageResult)); |
| 83 | } | 80 | } |
| 84 | 81 | ||
| 82 | + @GetMapping("/get-property") | ||
| 83 | + @Operation(summary = "获得装修页面属性") | ||
| 84 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 85 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") | ||
| 86 | + public CommonResult<DiyPagePropertyRespVO> getDiyPageProperty(@RequestParam("id") Long id) { | ||
| 87 | + DiyPageDO diyPage = diyPageService.getDiyPage(id); | ||
| 88 | + return success(DiyPageConvert.INSTANCE.convertPropertyVo(diyPage)); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @PutMapping("/update-property") | ||
| 92 | + @Operation(summary = "更新装修页面属性") | ||
| 93 | + @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") | ||
| 94 | + public CommonResult<Boolean> updateDiyPageProperty(@Valid @RequestBody DiyPagePropertyUpdateRequestVO updateReqVO) { | ||
| 95 | + diyPageService.updateDiyPageProperty(updateReqVO); | ||
| 96 | + return success(true); | ||
| 97 | + } | ||
| 98 | + | ||
| 85 | } | 99 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java
| @@ -2,12 +2,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.diy; | @@ -2,12 +2,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.diy; | ||
| 2 | 2 | ||
| 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.pojo.PageResult; | 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; | 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; |
| 9 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; | 6 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | ||
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 9 | +import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; | ||
| 11 | import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; | 10 | import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; |
| 12 | import io.swagger.v3.oas.annotations.Operation; | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 12 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -19,6 +18,8 @@ import org.springframework.web.bind.annotation.*; | @@ -19,6 +18,8 @@ import org.springframework.web.bind.annotation.*; | ||
| 19 | import javax.annotation.Resource; | 18 | import javax.annotation.Resource; |
| 20 | import javax.validation.Valid; | 19 | import javax.validation.Valid; |
| 21 | 20 | ||
| 21 | +import java.util.List; | ||
| 22 | + | ||
| 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | 24 | ||
| 24 | @Tag(name = "管理后台 - 装修模板") | 25 | @Tag(name = "管理后台 - 装修模板") |
| @@ -29,6 +30,8 @@ public class DiyTemplateController { | @@ -29,6 +30,8 @@ public class DiyTemplateController { | ||
| 29 | 30 | ||
| 30 | @Resource | 31 | @Resource |
| 31 | private DiyTemplateService diyTemplateService; | 32 | private DiyTemplateService diyTemplateService; |
| 33 | + @Resource | ||
| 34 | + private DiyPageService diyPageService; | ||
| 32 | 35 | ||
| 33 | @PostMapping("/create") | 36 | @PostMapping("/create") |
| 34 | @Operation(summary = "创建装修模板") | 37 | @Operation(summary = "创建装修模板") |
| @@ -79,4 +82,22 @@ public class DiyTemplateController { | @@ -79,4 +82,22 @@ public class DiyTemplateController { | ||
| 79 | return success(DiyTemplateConvert.INSTANCE.convertPage(pageResult)); | 82 | return success(DiyTemplateConvert.INSTANCE.convertPage(pageResult)); |
| 80 | } | 83 | } |
| 81 | 84 | ||
| 85 | + @GetMapping("/get-property") | ||
| 86 | + @Operation(summary = "获得装修模板属性") | ||
| 87 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 88 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") | ||
| 89 | + public CommonResult<DiyTemplatePropertyRespVO> getDiyTemplateProperty(@RequestParam("id") Long id) { | ||
| 90 | + DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); | ||
| 91 | + List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(id); | ||
| 92 | + return success(DiyTemplateConvert.INSTANCE.convertPropertyVo(diyTemplate, pages)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @PutMapping("/update-property") | ||
| 96 | + @Operation(summary = "更新装修模板属性") | ||
| 97 | + @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") | ||
| 98 | + public CommonResult<Boolean> updateDiyTemplateProperty(@Valid @RequestBody DiyTemplatePropertyUpdateRequestVO updateReqVO) { | ||
| 99 | + diyTemplateService.updateDiyTemplateProperty(updateReqVO); | ||
| 100 | + return success(true); | ||
| 101 | + } | ||
| 102 | + | ||
| 82 | } | 103 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java
| @@ -26,7 +26,4 @@ public class DiyPageBaseVO { | @@ -26,7 +26,4 @@ public class DiyPageBaseVO { | ||
| 26 | @Schema(description = "预览图") | 26 | @Schema(description = "预览图") |
| 27 | private List<String> previewImageUrls; | 27 | private List<String> previewImageUrls; |
| 28 | 28 | ||
| 29 | - @Schema(description = "页面属性", example = "[]") | ||
| 30 | - private String property; | ||
| 31 | - | ||
| 32 | } | 29 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.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 = "管理后台 - 装修页面属性 Response VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class DiyPagePropertyRespVO extends DiyPageBaseVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + @Schema(description = "页面属性", example = "[]") | ||
| 18 | + private String property; | ||
| 19 | + | ||
| 20 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.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.ToString; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotBlank; | ||
| 8 | +import javax.validation.constraints.NotNull; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 装修页面属性更新 Request VO") | ||
| 11 | +@Data | ||
| 12 | +@ToString(callSuper = true) | ||
| 13 | +public class DiyPagePropertyUpdateRequestVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | ||
| 16 | + @NotNull(message = "装修页面编号不能为空") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "页面属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 20 | + @NotBlank(message = "页面属性不能为空") | ||
| 21 | + private String property; | ||
| 22 | + | ||
| 23 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java
| @@ -23,7 +23,4 @@ public class DiyTemplateBaseVO { | @@ -23,7 +23,4 @@ public class DiyTemplateBaseVO { | ||
| 23 | @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") | 23 | @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") |
| 24 | private List<String> previewImageUrls; | 24 | private List<String> previewImageUrls; |
| 25 | 25 | ||
| 26 | - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 27 | - private String property; | ||
| 28 | - | ||
| 29 | } | 26 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 装修模板属性 Response VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class DiyTemplatePropertyRespVO extends DiyTemplateBaseVO { | ||
| 16 | + | ||
| 17 | + @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 21 | + private String property; | ||
| 22 | + | ||
| 23 | + @Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") | ||
| 24 | + private List<DiyPagePropertyRespVO> pages; | ||
| 25 | + | ||
| 26 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.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.ToString; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotBlank; | ||
| 8 | +import javax.validation.constraints.NotNull; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 装修模板属性更新 Request VO") | ||
| 11 | +@Data | ||
| 12 | +@ToString(callSuper = true) | ||
| 13 | +public class DiyTemplatePropertyUpdateRequestVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | ||
| 16 | + @NotNull(message = "装修模板编号不能为空") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 20 | + @NotBlank(message = "模板属性不能为空") | ||
| 21 | + private String property; | ||
| 22 | + | ||
| 23 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java
| 1 | package cn.iocoder.yudao.module.promotion.convert.diy; | 1 | package cn.iocoder.yudao.module.promotion.convert.diy; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 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; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; |
| 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | 5 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| 8 | import org.mapstruct.Mapper; | 6 | import org.mapstruct.Mapper; |
| 9 | import org.mapstruct.factory.Mappers; | 7 | import org.mapstruct.factory.Mappers; |
| @@ -30,4 +28,10 @@ public interface DiyPageConvert { | @@ -30,4 +28,10 @@ public interface DiyPageConvert { | ||
| 30 | 28 | ||
| 31 | PageResult<DiyPageRespVO> convertPage(PageResult<DiyPageDO> page); | 29 | PageResult<DiyPageRespVO> convertPage(PageResult<DiyPageDO> page); |
| 32 | 30 | ||
| 31 | + DiyPageCreateReqVO convertCreateVo(Long templateId, String name, String remark); | ||
| 32 | + | ||
| 33 | + DiyPagePropertyRespVO convertPropertyVo(DiyPageDO diyPage); | ||
| 34 | + | ||
| 35 | + DiyPageDO convert(DiyPagePropertyUpdateRequestVO updateReqVO); | ||
| 36 | + | ||
| 33 | } | 37 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java
| 1 | package cn.iocoder.yudao.module.promotion.convert.diy; | 1 | package cn.iocoder.yudao.module.promotion.convert.diy; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 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; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; |
| 5 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | ||
| 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 8 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 9 | import org.mapstruct.factory.Mappers; | 8 | import org.mapstruct.factory.Mappers; |
| @@ -30,4 +29,8 @@ public interface DiyTemplateConvert { | @@ -30,4 +29,8 @@ public interface DiyTemplateConvert { | ||
| 30 | 29 | ||
| 31 | PageResult<DiyTemplateRespVO> convertPage(PageResult<DiyTemplateDO> page); | 30 | PageResult<DiyTemplateRespVO> convertPage(PageResult<DiyTemplateDO> page); |
| 32 | 31 | ||
| 32 | + DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages); | ||
| 33 | + | ||
| 34 | + DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); | ||
| 35 | + | ||
| 33 | } | 36 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java
| @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePag | @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePag | ||
| 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 10 | /** | 12 | /** |
| 11 | * 装修页面 Mapper | 13 | * 装修页面 Mapper |
| 12 | * | 14 | * |
| @@ -19,8 +21,19 @@ public interface DiyPageMapper extends BaseMapperX<DiyPageDO> { | @@ -19,8 +21,19 @@ public interface DiyPageMapper extends BaseMapperX<DiyPageDO> { | ||
| 19 | return selectPage(reqVO, new LambdaQueryWrapperX<DiyPageDO>() | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<DiyPageDO>() |
| 20 | .likeIfPresent(DiyPageDO::getName, reqVO.getName()) | 22 | .likeIfPresent(DiyPageDO::getName, reqVO.getName()) |
| 21 | .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime()) | 23 | .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime()) |
| 24 | + // 模板下面的页面,在模板中管理 | ||
| 22 | .isNull(DiyPageDO::getTemplateId) | 25 | .isNull(DiyPageDO::getTemplateId) |
| 23 | .orderByDesc(DiyPageDO::getId)); | 26 | .orderByDesc(DiyPageDO::getId)); |
| 24 | } | 27 | } |
| 25 | 28 | ||
| 29 | + default List<DiyPageDO> selectListByTemplateId(Long templateId) { | ||
| 30 | + return selectList(DiyPageDO::getTemplateId, templateId); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default DiyPageDO selectByNameAndTemplateIdIsNull(String name) { | ||
| 34 | + return selectOne(new LambdaQueryWrapperX<DiyPageDO>() | ||
| 35 | + .eq(DiyPageDO::getName, name) | ||
| 36 | + .isNull(DiyPageDO::getTemplateId)); | ||
| 37 | + } | ||
| 38 | + | ||
| 26 | } | 39 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java
| @@ -29,4 +29,8 @@ public interface DiyTemplateMapper extends BaseMapperX<DiyTemplateDO> { | @@ -29,4 +29,8 @@ public interface DiyTemplateMapper extends BaseMapperX<DiyTemplateDO> { | ||
| 29 | return selectOne(DiyTemplateDO::getUsed, used); | 29 | return selectOne(DiyTemplateDO::getUsed, used); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | + default DiyTemplateDO selectByName(String name) { | ||
| 33 | + return selectOne(DiyTemplateDO::getName, name); | ||
| 34 | + } | ||
| 35 | + | ||
| 32 | } | 36 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.diy; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.diy; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; | 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; | 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.DiyPagePropertyUpdateRequestVO; | ||
| 6 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | 7 | 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 cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| 8 | 9 | ||
| @@ -63,4 +64,19 @@ public interface DiyPageService { | @@ -63,4 +64,19 @@ public interface DiyPageService { | ||
| 63 | */ | 64 | */ |
| 64 | PageResult<DiyPageDO> getDiyPagePage(DiyPagePageReqVO pageReqVO); | 65 | PageResult<DiyPageDO> getDiyPagePage(DiyPagePageReqVO pageReqVO); |
| 65 | 66 | ||
| 67 | + /** | ||
| 68 | + * 更新装修页面属性 | ||
| 69 | + * | ||
| 70 | + * @param updateReqVO 更新信息 | ||
| 71 | + */ | ||
| 72 | + void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO); | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 获得模板所属的页面列表 | ||
| 76 | + * | ||
| 77 | + * @param templateId 模板编号 | ||
| 78 | + * @return 装修页面列表 | ||
| 79 | + */ | ||
| 80 | + List<DiyPageDO> getDiyPageByTemplateId(Long templateId); | ||
| 81 | + | ||
| 66 | } | 82 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java
| @@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.promotion.service.diy; | @@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.promotion.service.diy; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.collection.ListUtil; | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | +import cn.hutool.core.util.StrUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | 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.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.DiyPagePageReqVO; |
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; | ||
| 8 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; | 10 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; |
| 9 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; | 11 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| @@ -17,6 +19,7 @@ import java.util.Collection; | @@ -17,6 +19,7 @@ import java.util.Collection; | ||
| 17 | import java.util.List; | 19 | import java.util.List; |
| 18 | 20 | ||
| 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 21 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 22 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NAME_USED; | ||
| 20 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; | 23 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; |
| 21 | 24 | ||
| 22 | /** | 25 | /** |
| @@ -33,8 +36,11 @@ public class DiyPageServiceImpl implements DiyPageService { | @@ -33,8 +36,11 @@ public class DiyPageServiceImpl implements DiyPageService { | ||
| 33 | 36 | ||
| 34 | @Override | 37 | @Override |
| 35 | public Long createDiyPage(DiyPageCreateReqVO createReqVO) { | 38 | public Long createDiyPage(DiyPageCreateReqVO createReqVO) { |
| 39 | + // 校验名称唯一 | ||
| 40 | + validateNameUnique(null, createReqVO.getTemplateId(), createReqVO.getName()); | ||
| 36 | // 插入 | 41 | // 插入 |
| 37 | DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); | 42 | DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); |
| 43 | + diyPage.setProperty("{}"); | ||
| 38 | diyPageMapper.insert(diyPage); | 44 | diyPageMapper.insert(diyPage); |
| 39 | // 返回 | 45 | // 返回 |
| 40 | return diyPage.getId(); | 46 | return diyPage.getId(); |
| @@ -44,11 +50,30 @@ public class DiyPageServiceImpl implements DiyPageService { | @@ -44,11 +50,30 @@ public class DiyPageServiceImpl implements DiyPageService { | ||
| 44 | public void updateDiyPage(DiyPageUpdateReqVO updateReqVO) { | 50 | public void updateDiyPage(DiyPageUpdateReqVO updateReqVO) { |
| 45 | // 校验存在 | 51 | // 校验存在 |
| 46 | validateDiyPageExists(updateReqVO.getId()); | 52 | validateDiyPageExists(updateReqVO.getId()); |
| 53 | + // 校验名称唯一 | ||
| 54 | + validateNameUnique(updateReqVO.getId(), updateReqVO.getTemplateId(), updateReqVO.getName()); | ||
| 47 | // 更新 | 55 | // 更新 |
| 48 | DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); | 56 | DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); |
| 49 | diyPageMapper.updateById(updateObj); | 57 | diyPageMapper.updateById(updateObj); |
| 50 | } | 58 | } |
| 51 | 59 | ||
| 60 | + void validateNameUnique(Long id, Long templateId, String name) { | ||
| 61 | + if (templateId != null || StrUtil.isBlank(name)) { | ||
| 62 | + return; | ||
| 63 | + } | ||
| 64 | + DiyPageDO page = diyPageMapper.selectByNameAndTemplateIdIsNull(name); | ||
| 65 | + if (page == null) { | ||
| 66 | + return; | ||
| 67 | + } | ||
| 68 | + // 如果 id 为空,说明不用比较是否为相同 id 的页面 | ||
| 69 | + if (id == null) { | ||
| 70 | + throw exception(DIY_PAGE_NAME_USED, name); | ||
| 71 | + } | ||
| 72 | + if (!page.getId().equals(id)) { | ||
| 73 | + throw exception(DIY_PAGE_NAME_USED, name); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 52 | @Override | 77 | @Override |
| 53 | public void deleteDiyPage(Long id) { | 78 | public void deleteDiyPage(Long id) { |
| 54 | // 校验存在 | 79 | // 校验存在 |
| @@ -81,4 +106,18 @@ public class DiyPageServiceImpl implements DiyPageService { | @@ -81,4 +106,18 @@ public class DiyPageServiceImpl implements DiyPageService { | ||
| 81 | return diyPageMapper.selectPage(pageReqVO); | 106 | return diyPageMapper.selectPage(pageReqVO); |
| 82 | } | 107 | } |
| 83 | 108 | ||
| 109 | + @Override | ||
| 110 | + public List<DiyPageDO> getDiyPageByTemplateId(Long templateId) { | ||
| 111 | + return diyPageMapper.selectListByTemplateId(templateId); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @Override | ||
| 115 | + public void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO) { | ||
| 116 | + // 校验存在 | ||
| 117 | + validateDiyPageExists(updateReqVO.getId()); | ||
| 118 | + // 更新 | ||
| 119 | + DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); | ||
| 120 | + diyPageMapper.updateById(updateObj); | ||
| 121 | + } | ||
| 122 | + | ||
| 84 | } | 123 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.diy; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.diy; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; | 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; | 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.DiyTemplatePropertyUpdateRequestVO; | ||
| 6 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | 7 | 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 cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 8 | 9 | ||
| @@ -60,4 +61,11 @@ public interface DiyTemplateService { | @@ -60,4 +61,11 @@ public interface DiyTemplateService { | ||
| 60 | */ | 61 | */ |
| 61 | void useDiyTemplate(Long id); | 62 | void useDiyTemplate(Long id); |
| 62 | 63 | ||
| 64 | + /** | ||
| 65 | + * 更新装修模板属性 | ||
| 66 | + * | ||
| 67 | + * @param updateReqVO 更新信息 | ||
| 68 | + */ | ||
| 69 | + void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO); | ||
| 70 | + | ||
| 63 | } | 71 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
| 1 | package cn.iocoder.yudao.module.promotion.service.diy; | 1 | package cn.iocoder.yudao.module.promotion.service.diy; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.BooleanUtil; | 3 | import cn.hutool.core.util.BooleanUtil; |
| 4 | +import cn.hutool.core.util.StrUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | 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.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.DiyTemplatePageReqVO; |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; | ||
| 7 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; | 9 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; |
| 10 | +import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; | ||
| 8 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; | 11 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; |
| 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; | 13 | import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; |
| 11 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 15 | +import org.springframework.transaction.annotation.Transactional; | ||
| 12 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
| 13 | 17 | ||
| 14 | import javax.annotation.Resource; | 18 | import javax.annotation.Resource; |
| 15 | import java.time.LocalDateTime; | 19 | import java.time.LocalDateTime; |
| 16 | 20 | ||
| 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 21 | 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; | 22 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 20 | 23 | ||
| 21 | /** | 24 | /** |
| 22 | * 装修模板 Service 实现类 | 25 | * 装修模板 Service 实现类 |
| @@ -29,25 +32,63 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { | @@ -29,25 +32,63 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { | ||
| 29 | 32 | ||
| 30 | @Resource | 33 | @Resource |
| 31 | private DiyTemplateMapper diyTemplateMapper; | 34 | private DiyTemplateMapper diyTemplateMapper; |
| 35 | + @Resource | ||
| 36 | + private DiyPageService diyPageService; | ||
| 32 | 37 | ||
| 33 | @Override | 38 | @Override |
| 34 | public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { | 39 | public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { |
| 40 | + // 校验名称唯一 | ||
| 41 | + validateNameUnique(null, createReqVO.getName()); | ||
| 35 | // 插入 | 42 | // 插入 |
| 36 | DiyTemplateDO diyTemplate = DiyTemplateConvert.INSTANCE.convert(createReqVO); | 43 | DiyTemplateDO diyTemplate = DiyTemplateConvert.INSTANCE.convert(createReqVO); |
| 44 | + diyTemplate.setProperty("{}"); | ||
| 37 | diyTemplateMapper.insert(diyTemplate); | 45 | diyTemplateMapper.insert(diyTemplate); |
| 46 | + // 创建默认页面 | ||
| 47 | + createDefaultPage(diyTemplate); | ||
| 38 | // 返回 | 48 | // 返回 |
| 39 | return diyTemplate.getId(); | 49 | return diyTemplate.getId(); |
| 40 | } | 50 | } |
| 41 | 51 | ||
| 52 | + /** | ||
| 53 | + * 创建模板下面的默认页面 | ||
| 54 | + * 默认创建两个页面:首页、我的 | ||
| 55 | + * | ||
| 56 | + * @param diyTemplate 模板对象 | ||
| 57 | + */ | ||
| 58 | + private void createDefaultPage(DiyTemplateDO diyTemplate) { | ||
| 59 | + String remark = String.format("模板【%s】自动创建", diyTemplate.getName()); | ||
| 60 | + diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "首页", remark)); | ||
| 61 | + diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "我的", remark)); | ||
| 62 | + } | ||
| 63 | + | ||
| 42 | @Override | 64 | @Override |
| 43 | public void updateDiyTemplate(DiyTemplateUpdateReqVO updateReqVO) { | 65 | public void updateDiyTemplate(DiyTemplateUpdateReqVO updateReqVO) { |
| 44 | // 校验存在 | 66 | // 校验存在 |
| 45 | validateDiyTemplateExists(updateReqVO.getId()); | 67 | validateDiyTemplateExists(updateReqVO.getId()); |
| 68 | + // 校验名称唯一 | ||
| 69 | + validateNameUnique(updateReqVO.getId(), updateReqVO.getName()); | ||
| 46 | // 更新 | 70 | // 更新 |
| 47 | DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); | 71 | DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); |
| 48 | diyTemplateMapper.updateById(updateObj); | 72 | diyTemplateMapper.updateById(updateObj); |
| 49 | } | 73 | } |
| 50 | 74 | ||
| 75 | + void validateNameUnique(Long id, String name) { | ||
| 76 | + if (StrUtil.isBlank(name)) { | ||
| 77 | + return; | ||
| 78 | + } | ||
| 79 | + DiyTemplateDO template = diyTemplateMapper.selectByName(name); | ||
| 80 | + if (template == null) { | ||
| 81 | + return; | ||
| 82 | + } | ||
| 83 | + // 如果 id 为空,说明不用比较是否为相同 id 的模板 | ||
| 84 | + if (id == null) { | ||
| 85 | + throw exception(DIY_TEMPLATE_NAME_USED, name); | ||
| 86 | + } | ||
| 87 | + if (!template.getId().equals(id)) { | ||
| 88 | + throw exception(DIY_TEMPLATE_NAME_USED, name); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 51 | @Override | 92 | @Override |
| 52 | public void deleteDiyTemplate(Long id) { | 93 | public void deleteDiyTemplate(Long id) { |
| 53 | // 校验存在 | 94 | // 校验存在 |
| @@ -85,12 +126,33 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { | @@ -85,12 +126,33 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { | ||
| 85 | // 已使用的更新为未使用 | 126 | // 已使用的更新为未使用 |
| 86 | DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); | 127 | DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); |
| 87 | if (used != null) { | 128 | if (used != null) { |
| 129 | + // 如果 id 相同,说明未发生变化 | ||
| 130 | + if (used.getId().equals(id)) { | ||
| 131 | + return; | ||
| 132 | + } | ||
| 88 | this.updateUsed(used.getId(), false, null); | 133 | this.updateUsed(used.getId(), false, null); |
| 89 | } | 134 | } |
| 90 | // 更新为已使用 | 135 | // 更新为已使用 |
| 91 | this.updateUsed(id, true, LocalDateTime.now()); | 136 | this.updateUsed(id, true, LocalDateTime.now()); |
| 92 | } | 137 | } |
| 93 | 138 | ||
| 139 | + @Transactional(rollbackFor = Exception.class) | ||
| 140 | + @Override | ||
| 141 | + public void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO) { | ||
| 142 | + // 校验存在 | ||
| 143 | + validateDiyTemplateExists(updateReqVO.getId()); | ||
| 144 | + // 更新模板属性 | ||
| 145 | + DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); | ||
| 146 | + diyTemplateMapper.updateById(updateObj); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * 更新模板是否使用 | ||
| 151 | + * | ||
| 152 | + * @param id 模板编号 | ||
| 153 | + * @param used 是否使用 | ||
| 154 | + * @param usedTime 使用时间 | ||
| 155 | + */ | ||
| 94 | private void updateUsed(Long id, Boolean used, LocalDateTime usedTime) { | 156 | private void updateUsed(Long id, Boolean used, LocalDateTime usedTime) { |
| 95 | DiyTemplateDO updateObj = new DiyTemplateDO().setId(id) | 157 | DiyTemplateDO updateObj = new DiyTemplateDO().setId(id) |
| 96 | .setUsed(used).setUsedTime(usedTime); | 158 | .setUsed(used).setUsedTime(usedTime); |