Commit bdfb5b88942eb3fa10f885a06a1f53ca19778d8d

Authored by owen
1 parent 9996608d

营销:装修页面适配

yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
... ... @@ -223,10 +223,14 @@ public class CollectionUtils {
223 223 }
224 224  
225 225 public static <T> T findFirst(List<T> from, Predicate<T> predicate) {
  226 + return findFirst(from, predicate, Function.identity());
  227 + }
  228 +
  229 + public static <T, U> U findFirst(List<T> from, Predicate<T> predicate, Function<T, U> func) {
226 230 if (CollUtil.isEmpty(from)) {
227 231 return null;
228 232 }
229   - return from.stream().filter(predicate).findFirst().orElse(null);
  233 + return from.stream().filter(predicate).findFirst().map(func).orElse(null);
230 234 }
231 235  
232 236 public static <T, V extends Comparable<? super V>> V getMaxValue(Collection<T> from, Function<T, V> valueFunc) {
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java
... ... @@ -20,6 +20,7 @@ import javax.annotation.Resource;
20 20 import java.util.List;
21 21  
22 22 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  23 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
23 24  
24 25 @Tag(name = "用户 APP - 装修模板")
25 26 @RestController
... ... @@ -34,8 +35,8 @@ public class AppDiyTemplateController {
34 35  
35 36 @GetMapping("/used")
36 37 @Operation(summary = "使用中的装修模板")
37   - public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplateProperty() {
38   - DiyTemplateDO diyTemplate = diyTemplateService.getUsedTemplate();
  38 + public CommonResult<AppDiyTemplatePropertyRespVO> getUsedDiyTemplate() {
  39 + DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate();
39 40 return success(buildVo(diyTemplate));
40 41 }
41 42  
... ... @@ -53,8 +54,10 @@ public class AppDiyTemplateController {
53 54 }
54 55 // 查询模板下的页面
55 56 List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
  57 + String home = findFirst(pages, page -> "首页".equals(page.getName()), DiyPageDO::getProperty);
  58 + String user = findFirst(pages, page -> "我的".equals(page.getName()), DiyPageDO::getProperty);
56 59 // 拼接返回
57   - return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, pages);
  60 + return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
58 61 }
59 62  
60 63 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java
1 1 package cn.iocoder.yudao.module.promotion.controller.app.diy.vo;
2 2  
3   -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO;
  3 +import com.fasterxml.jackson.annotation.JsonRawValue;
4 4 import io.swagger.v3.oas.annotations.media.Schema;
5 5 import lombok.Data;
6 6 import lombok.ToString;
7 7  
8   -import java.util.List;
9   -
10 8 @Schema(description = "用户 App - 装修模板属性 Response VO")
11 9 @Data
12 10 @ToString(callSuper = true)
... ... @@ -18,10 +16,16 @@ public class AppDiyTemplatePropertyRespVO {
18 16 @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题")
19 17 private String name;
20 18  
21   - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
  19 + @Schema(description = "模板属性", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
  20 + @JsonRawValue
22 21 private String property;
23 22  
24   - @Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]")
25   - private List<DiyPagePropertyRespVO> pages;
  23 + @Schema(description = "首页", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
  24 + @JsonRawValue
  25 + private String home;
  26 +
  27 + @Schema(description = "我的", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
  28 + @JsonRawValue
  29 + private String user;
26 30  
27 31 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java
... ... @@ -32,7 +32,7 @@ public interface DiyTemplateConvert {
32 32  
33 33 DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages);
34 34  
35   - AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, List<DiyPageDO> pages);
  35 + AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, String home, String user);
36 36  
37 37 DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO);
38 38  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java
... ... @@ -73,6 +73,6 @@ public interface DiyTemplateService {
73 73 *
74 74 * @return 装修模板
75 75 */
76   - DiyTemplateDO getUsedTemplate();
  76 + DiyTemplateDO getUsedDiyTemplate();
77 77  
78 78 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
... ... @@ -147,7 +147,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
147 147 }
148 148  
149 149 @Override
150   - public DiyTemplateDO getUsedTemplate() {
  150 + public DiyTemplateDO getUsedDiyTemplate() {
151 151 return diyTemplateMapper.selectByUsed(true);
152 152 }
153 153  
... ...