Commit 9996608da6bb2dd835788d9fa3092874a0a87405
1 parent
32499be9
营销:装修模板APP接口
Showing
6 changed files
with
123 additions
and
0 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.diy; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; | ||
| 10 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 11 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 13 | +import org.springframework.validation.annotation.Validated; | ||
| 14 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 15 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 16 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 17 | +import org.springframework.web.bind.annotation.RestController; | ||
| 18 | + | ||
| 19 | +import javax.annotation.Resource; | ||
| 20 | +import java.util.List; | ||
| 21 | + | ||
| 22 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 23 | + | ||
| 24 | +@Tag(name = "用户 APP - 装修模板") | ||
| 25 | +@RestController | ||
| 26 | +@RequestMapping("/promotion/diy-template") | ||
| 27 | +@Validated | ||
| 28 | +public class AppDiyTemplateController { | ||
| 29 | + | ||
| 30 | + @Resource | ||
| 31 | + private DiyTemplateService diyTemplateService; | ||
| 32 | + @Resource | ||
| 33 | + private DiyPageService diyPageService; | ||
| 34 | + | ||
| 35 | + @GetMapping("/used") | ||
| 36 | + @Operation(summary = "使用中的装修模板") | ||
| 37 | + public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplateProperty() { | ||
| 38 | + DiyTemplateDO diyTemplate = diyTemplateService.getUsedTemplate(); | ||
| 39 | + return success(buildVo(diyTemplate)); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @GetMapping("/get") | ||
| 43 | + @Operation(summary = "获得装修模板") | ||
| 44 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 45 | + public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplate(@RequestParam("id") Long id) { | ||
| 46 | + DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); | ||
| 47 | + return success(buildVo(diyTemplate)); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + private AppDiyTemplatePropertyRespVO buildVo(DiyTemplateDO diyTemplate) { | ||
| 51 | + if (diyTemplate == null) { | ||
| 52 | + return null; | ||
| 53 | + } | ||
| 54 | + // 查询模板下的页面 | ||
| 55 | + List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); | ||
| 56 | + // 拼接返回 | ||
| 57 | + return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, pages); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.ToString; | ||
| 6 | + | ||
| 7 | +@Schema(description = "用户 App - 装修页面属性 Response VO") | ||
| 8 | +@Data | ||
| 9 | +@ToString(callSuper = true) | ||
| 10 | +public class AppDiyPagePropertyRespVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @Schema(description = "页面属性", example = "[]") | ||
| 19 | + private String property; | ||
| 20 | + | ||
| 21 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; | ||
| 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.ToString; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Schema(description = "用户 App - 装修模板属性 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ToString(callSuper = true) | ||
| 13 | +public class AppDiyTemplatePropertyRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") | ||
| 19 | + private String name; | ||
| 20 | + | ||
| 21 | + @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 22 | + private String property; | ||
| 23 | + | ||
| 24 | + @Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") | ||
| 25 | + private List<DiyPagePropertyRespVO> pages; | ||
| 26 | + | ||
| 27 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.diy; | @@ -2,6 +2,7 @@ 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.*; | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; | ||
| 5 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 7 | import org.mapstruct.Mapper; | 8 | import org.mapstruct.Mapper; |
| @@ -31,6 +32,8 @@ public interface DiyTemplateConvert { | @@ -31,6 +32,8 @@ public interface DiyTemplateConvert { | ||
| 31 | 32 | ||
| 32 | DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages); | 33 | DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages); |
| 33 | 34 | ||
| 35 | + AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, List<DiyPageDO> pages); | ||
| 36 | + | ||
| 34 | DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); | 37 | DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); |
| 35 | 38 | ||
| 36 | } | 39 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java
| @@ -68,4 +68,11 @@ public interface DiyTemplateService { | @@ -68,4 +68,11 @@ public interface DiyTemplateService { | ||
| 68 | */ | 68 | */ |
| 69 | void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO); | 69 | void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO); |
| 70 | 70 | ||
| 71 | + /** | ||
| 72 | + * 获取使用中的装修模板 | ||
| 73 | + * | ||
| 74 | + * @return 装修模板 | ||
| 75 | + */ | ||
| 76 | + DiyTemplateDO getUsedTemplate(); | ||
| 77 | + | ||
| 71 | } | 78 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
| @@ -146,6 +146,11 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { | @@ -146,6 +146,11 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { | ||
| 146 | diyTemplateMapper.updateById(updateObj); | 146 | diyTemplateMapper.updateById(updateObj); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | + @Override | ||
| 150 | + public DiyTemplateDO getUsedTemplate() { | ||
| 151 | + return diyTemplateMapper.selectByUsed(true); | ||
| 152 | + } | ||
| 153 | + | ||
| 149 | /** | 154 | /** |
| 150 | * 更新模板是否使用 | 155 | * 更新模板是否使用 |
| 151 | * | 156 | * |