营销:装修页面适配

This commit is contained in:
owen 2023-11-03 09:18:04 +08:00
parent 9996608da6
commit bdfb5b8894
6 changed files with 24 additions and 13 deletions

View File

@ -223,10 +223,14 @@ public class CollectionUtils {
} }
public static <T> T findFirst(List<T> from, Predicate<T> predicate) { public static <T> T findFirst(List<T> from, Predicate<T> predicate) {
return findFirst(from, predicate, Function.identity());
}
public static <T, U> U findFirst(List<T> from, Predicate<T> predicate, Function<T, U> func) {
if (CollUtil.isEmpty(from)) { if (CollUtil.isEmpty(from)) {
return null; return null;
} }
return from.stream().filter(predicate).findFirst().orElse(null); return from.stream().filter(predicate).findFirst().map(func).orElse(null);
} }
public static <T, V extends Comparable<? super V>> V getMaxValue(Collection<T> from, Function<T, V> valueFunc) { public static <T, V extends Comparable<? super V>> V getMaxValue(Collection<T> from, Function<T, V> valueFunc) {

View File

@ -20,6 +20,7 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
@Tag(name = "用户 APP - 装修模板") @Tag(name = "用户 APP - 装修模板")
@RestController @RestController
@ -34,8 +35,8 @@ public class AppDiyTemplateController {
@GetMapping("/used") @GetMapping("/used")
@Operation(summary = "使用中的装修模板") @Operation(summary = "使用中的装修模板")
public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplateProperty() { public CommonResult<AppDiyTemplatePropertyRespVO> getUsedDiyTemplate() {
DiyTemplateDO diyTemplate = diyTemplateService.getUsedTemplate(); DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate();
return success(buildVo(diyTemplate)); return success(buildVo(diyTemplate));
} }
@ -53,8 +54,10 @@ public class AppDiyTemplateController {
} }
// 查询模板下的页面 // 查询模板下的页面
List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
String home = findFirst(pages, page -> "首页".equals(page.getName()), DiyPageDO::getProperty);
String user = findFirst(pages, page -> "我的".equals(page.getName()), DiyPageDO::getProperty);
// 拼接返回 // 拼接返回
return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, pages); return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
} }
} }

View File

@ -1,12 +1,10 @@
package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; package cn.iocoder.yudao.module.promotion.controller.app.diy.vo;
import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO; import com.fasterxml.jackson.annotation.JsonRawValue;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import java.util.List;
@Schema(description = "用户 App - 装修模板属性 Response VO") @Schema(description = "用户 App - 装修模板属性 Response VO")
@Data @Data
@ToString(callSuper = true) @ToString(callSuper = true)
@ -18,10 +16,16 @@ public class AppDiyTemplatePropertyRespVO {
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题")
private String name; private String name;
@Schema(description = "模板属性JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") @Schema(description = "模板属性", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
@JsonRawValue
private String property; private String property;
@Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") @Schema(description = "首页", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
private List<DiyPagePropertyRespVO> pages; @JsonRawValue
private String home;
@Schema(description = "我的", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
@JsonRawValue
private String user;
} }

View File

@ -32,7 +32,7 @@ public interface DiyTemplateConvert {
DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages); DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages);
AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, List<DiyPageDO> pages); AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, String home, String user);
DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO);

View File

@ -73,6 +73,6 @@ public interface DiyTemplateService {
* *
* @return 装修模板 * @return 装修模板
*/ */
DiyTemplateDO getUsedTemplate(); DiyTemplateDO getUsedDiyTemplate();
} }

View File

@ -147,7 +147,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
} }
@Override @Override
public DiyTemplateDO getUsedTemplate() { public DiyTemplateDO getUsedDiyTemplate() {
return diyTemplateMapper.selectByUsed(true); return diyTemplateMapper.selectByUsed(true);
} }