mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
营销:装修页面适配
This commit is contained in:
parent
9996608da6
commit
bdfb5b8894
@ -223,10 +223,14 @@ public class CollectionUtils {
|
||||
}
|
||||
|
||||
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)) {
|
||||
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) {
|
||||
|
@ -20,6 +20,7 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
|
||||
|
||||
@Tag(name = "用户 APP - 装修模板")
|
||||
@RestController
|
||||
@ -34,8 +35,8 @@ public class AppDiyTemplateController {
|
||||
|
||||
@GetMapping("/used")
|
||||
@Operation(summary = "使用中的装修模板")
|
||||
public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplateProperty() {
|
||||
DiyTemplateDO diyTemplate = diyTemplateService.getUsedTemplate();
|
||||
public CommonResult<AppDiyTemplatePropertyRespVO> getUsedDiyTemplate() {
|
||||
DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate();
|
||||
return success(buildVo(diyTemplate));
|
||||
}
|
||||
|
||||
@ -53,8 +54,10 @@ public class AppDiyTemplateController {
|
||||
}
|
||||
// 查询模板下的页面
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
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 lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 装修模板属性 Response VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@ -18,10 +16,16 @@ public class AppDiyTemplatePropertyRespVO {
|
||||
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
|
||||
@Schema(description = "模板属性", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
|
||||
@JsonRawValue
|
||||
private String property;
|
||||
|
||||
@Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]")
|
||||
private List<DiyPagePropertyRespVO> pages;
|
||||
@Schema(description = "首页", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
|
||||
@JsonRawValue
|
||||
private String home;
|
||||
|
||||
@Schema(description = "我的", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
|
||||
@JsonRawValue
|
||||
private String user;
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public interface DiyTemplateConvert {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -73,6 +73,6 @@ public interface DiyTemplateService {
|
||||
*
|
||||
* @return 装修模板
|
||||
*/
|
||||
DiyTemplateDO getUsedTemplate();
|
||||
DiyTemplateDO getUsedDiyTemplate();
|
||||
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiyTemplateDO getUsedTemplate() {
|
||||
public DiyTemplateDO getUsedDiyTemplate() {
|
||||
return diyTemplateMapper.selectByUsed(true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user