mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
页面装修数据结构定义
This commit is contained in:
@ -28,6 +28,13 @@
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类中使用了 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.promotion.api.decorate.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 通用的样式 DTO. 由于每个组件的样式配置可能会不一样。 样式配置暂时没想好如何做。 暂时使用一个通用的DTO, 没有任何属性
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class CommonStyle {
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.promotion.api.decorate.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 导航菜单组件的内容配置,数据结构 定义
|
||||
* 不知道放哪里比较好 // TODO @芋艿 貌似放 api 这里不太合适。有什么建议没有?
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class NavMenuComponent {
|
||||
|
||||
/**
|
||||
* 导航菜单组件对内容的配置项
|
||||
*/
|
||||
@Data
|
||||
public static class Config {
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航菜单组件的数据结构
|
||||
*/
|
||||
@Data
|
||||
public static class DataStructure {
|
||||
/**
|
||||
* 显示名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 显示图片
|
||||
*/
|
||||
private String img;
|
||||
|
||||
/**
|
||||
* 连接路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 状态, 是否显示
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.promotion.api.decorate.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 页面组件通用模板结构 DTO
|
||||
* 每个组件都有自己对应的内容配置, 样式配置, 具体数据,和其他组件不同的。但这个三个配置是必须的, 所以定义通用的模板结构
|
||||
* 内容配置, 样式配置, 具体数据的结构 需要每个组件单独定义。
|
||||
* 1. 内容配置 (不包括具体的内容) 例如是否启用,是否显示, 商品分类页的排版方式等
|
||||
* 2. 样式设置,对应 crmeb php 版组件的样式配置。 暂时可能用不。 所以使用通用 CommonStyleDTO,后续可能用上
|
||||
* 3. 具体数据, 有些组件(导航菜单组件)数据是通过装修配置, 需要定制数据。有些组件(如商品分类),数据从接口获取,不需要该项
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class PageComponentDTO<Config, Style, Content> {
|
||||
|
||||
/**
|
||||
* 组件标题, 每个组件都有的
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 组件的内容配置项
|
||||
*/
|
||||
private Config config;
|
||||
|
||||
/**
|
||||
* 组件的样式配置
|
||||
*/
|
||||
private Style style;
|
||||
|
||||
/**
|
||||
* 组件的具体数据
|
||||
*
|
||||
*/
|
||||
private Content data;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.promotion.api.decorate.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品分类组件的内容配置, 无数据结构定义。数据从接口获取
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public class ProductCategoryComponent {
|
||||
|
||||
/**
|
||||
* 商品分类组件组件的内容配置项
|
||||
*/
|
||||
@Data
|
||||
public static class Config {
|
||||
|
||||
/**
|
||||
* 页面风格类型
|
||||
*/
|
||||
private Integer layoutStyle;
|
||||
|
||||
// TODO 其它
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.promotion.api.decorate.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 滚动横幅广告组件的内容配置,数据结构定义
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public class RollingBannerComponent {
|
||||
/**
|
||||
* 滚动横幅广告组件的内容配置项
|
||||
*/
|
||||
@Data
|
||||
public static class Config {
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航菜单组件的数据结构
|
||||
*/
|
||||
@Data
|
||||
public static class DataStructure {
|
||||
/**
|
||||
* 显示图片
|
||||
*/
|
||||
private String img;
|
||||
|
||||
/**
|
||||
* 连接路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 状态, 是否显示
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.promotion.enums.decorate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 装修页面枚举
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DecoratePageTypeEnum {
|
||||
INDEX(1, "首页");
|
||||
|
||||
private final Integer type;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.promotion.enums.decorate;
|
||||
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.module.promotion.api.decorate.dto.*;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 页面组件枚举
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Getter
|
||||
public enum PageComponentEnum {
|
||||
NAV_MENU("nav-menu", "导航菜单",
|
||||
new TypeReference<PageComponentDTO<NavMenuComponent.Config, CommonStyle, List<NavMenuComponent.DataStructure>>>() {}.getType()),
|
||||
ROLLING_BANNER("rolling-banner", "滚动横幅广告",
|
||||
new TypeReference<PageComponentDTO<RollingBannerComponent.Config, CommonStyle, List<RollingBannerComponent.DataStructure>>>() {}.getType()),
|
||||
PRODUCT_CATEGORY("product-category", "商品分类",
|
||||
new TypeReference<PageComponentDTO<ProductCategoryComponent.Config, CommonStyle, Object>>() {}.getType()); // data 会为null 用 object 代替
|
||||
|
||||
/**
|
||||
* 页面组件代码
|
||||
*/
|
||||
private final String code;
|
||||
|
||||
/**
|
||||
* 页面组件说明
|
||||
*/
|
||||
private final String desc;
|
||||
|
||||
/**
|
||||
* 具体组件的类型
|
||||
*/
|
||||
private final Type componentType;
|
||||
|
||||
PageComponentEnum(String code, String desc, Type componentType) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
public static PageComponentEnum getOfCode(String code) {
|
||||
return ArrayUtil.firstMatch(component -> component.getCode().equals(code), PageComponentEnum.values());
|
||||
}
|
||||
|
||||
public <C, S, D> PageComponentDTO<C, S, D> parsePageComponent(String text) {
|
||||
return JsonUtils.parseObject(text, componentType);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user