mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-01 01:50:04 +08:00
营销:
1. 调整店铺装修接口
This commit is contained in:
parent
a159a983a2
commit
c3de25e760
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.enums.decorate;
|
package cn.iocoder.yudao.module.promotion.enums.decorate;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,11 +9,44 @@ import lombok.Getter;
|
|||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuppressWarnings("JavadocLinkAsPlainText")
|
||||||
public enum DecorateComponentEnum {
|
public enum DecorateComponentEnum {
|
||||||
|
|
||||||
NAV_MENU("nav-menu", "导航菜单"),
|
/**
|
||||||
ROLLING_BANNER("rolling-banner", "滚动横幅广告"),
|
* 格式:[{
|
||||||
PRODUCT_CATEGORY("product-category", "商品分类");
|
* "name": "标题"
|
||||||
|
* "picUrl": "https://www.iocoder.cn/xxx.png",
|
||||||
|
* "url": "/pages/users/index"
|
||||||
|
* }]
|
||||||
|
*
|
||||||
|
* 最多 10 个
|
||||||
|
*/
|
||||||
|
MENU("menu", "菜单"),
|
||||||
|
/**
|
||||||
|
* 格式:[{
|
||||||
|
* "name": "标题"
|
||||||
|
* "url": "/pages/users/index"
|
||||||
|
* }]
|
||||||
|
*/
|
||||||
|
ROLLING_NEWS("scrolling-news", "滚动新闻"),
|
||||||
|
/**
|
||||||
|
* 格式:[{
|
||||||
|
* "picUrl": "https://www.iocoder.cn/xxx.png",
|
||||||
|
* "url": "/pages/users/index"
|
||||||
|
* }]
|
||||||
|
*/
|
||||||
|
SLIDE_SHOW("slide-show", "轮播图"),
|
||||||
|
/**
|
||||||
|
* 格式:[{
|
||||||
|
* "name": "标题"
|
||||||
|
* "type": "类型", // best、hot、new、benefit、good
|
||||||
|
* "tag": "标签" // 例如说:多买多省
|
||||||
|
* }]
|
||||||
|
*
|
||||||
|
* 最多 4 个
|
||||||
|
*/
|
||||||
|
PRODUCT_RECOMMEND("product-recommend", "商品推荐");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面组件代码
|
* 页面组件代码
|
||||||
@ -24,9 +58,4 @@ public enum DecorateComponentEnum {
|
|||||||
*/
|
*/
|
||||||
private final String desc;
|
private final String desc;
|
||||||
|
|
||||||
DecorateComponentEnum(String code, String desc) {
|
|
||||||
this.code = code;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,13 @@ public enum DecoratePageEnum implements IntArrayValuable {
|
|||||||
|
|
||||||
INDEX(1, "首页");
|
INDEX(1, "首页");
|
||||||
|
|
||||||
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getId).toArray();
|
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面 id
|
* 页面编号
|
||||||
*/
|
*/
|
||||||
private final Integer id;
|
private final Integer page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面名称
|
* 页面名称
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
### /promotion/decorate/save 保存页面装修组件
|
||||||
|
POST {{baseUrl}}/promotion/decorate/save
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
tenant-id: {{adminTenentId}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"page": 1,
|
||||||
|
"code": "slide-show",
|
||||||
|
"status": 0,
|
||||||
|
"value": "null"
|
||||||
|
}
|
||||||
|
|
||||||
|
### /promotion/decorate/list 获取指定页面的组件列表
|
||||||
|
GET {{baseUrl}}/promotion/decorate/list?page=1
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
tenant-id: {{adminTenentId}}
|
@ -2,45 +2,49 @@ package cn.iocoder.yudao.module.promotion.controller.admin.decorate;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
|
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService;
|
import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
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.module.promotion.convert.decorate.DecorateComponentConvert.INSTANCE;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 店铺页面装修")
|
@Tag(name = "管理后台 - 店铺页面装修")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/promotion/decorate")
|
@RequestMapping("/promotion/decorate")
|
||||||
@Validated
|
@Validated
|
||||||
public class DecorateComponentController {
|
public class DecorateComponentController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DecorateComponentService decorateComponentService;
|
private DecorateComponentService decorateComponentService;
|
||||||
|
|
||||||
@PostMapping("/page-save")
|
@PostMapping("/save")
|
||||||
@Operation(summary = "保存页面装修")
|
@Operation(summary = "保存页面装修组件")
|
||||||
// TODO 加权限
|
@PreAuthorize("@ss.hasPermission('promotion:decorate:save')")
|
||||||
public CommonResult<Boolean> savePageComponents(@Valid @RequestBody DecorateComponentSaveReqVO reqVO) {
|
public CommonResult<Boolean> saveDecorateComponent(@Valid @RequestBody DecorateComponentSaveReqVO reqVO) {
|
||||||
decorateComponentService.savePageComponents(reqVO);
|
decorateComponentService.saveDecorateComponent(reqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-page-components")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获取装修页面组件")
|
@Operation(summary = "获取指定页面的组件列表")
|
||||||
@Parameter(name = "pageId", description = "页面 id", required = true)
|
@Parameter(name = "page", description = "页面 id", required = true)
|
||||||
// TODO 加权限
|
@PreAuthorize("@ss.hasPermission('promotion:decorate:query')")
|
||||||
public CommonResult<DecorateComponentRespVO> getPageComponents(
|
public CommonResult<List<DecorateComponentRespVO>> getDecorateComponentListByPage(
|
||||||
@RequestParam("pageId") @InEnum(DecoratePageEnum.class) Integer pageId) {
|
@RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) {
|
||||||
return success(INSTANCE.convert2(pageId, decorateComponentService.getPageComponents(pageId)));
|
return success(DecorateComponentConvert.INSTANCE.convertList02(
|
||||||
|
decorateComponentService.getDecorateComponentListByPage(page, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,31 +3,17 @@ package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 页面装修 Resp VO")
|
@Schema(description = "管理后台 - 页面装修 Resp VO")
|
||||||
@Data
|
@Data
|
||||||
public class DecorateComponentRespVO {
|
public class DecorateComponentRespVO {
|
||||||
|
|
||||||
@Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
|
||||||
private Integer pageId;
|
private String code;
|
||||||
|
|
||||||
@Schema(description = "页面组件", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO")
|
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
|
||||||
private List<ComponentRespVO> components;
|
private String value;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 页面组件 Resp VO")
|
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@Data
|
private Integer status;
|
||||||
public static class ComponentRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,8 @@ import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 页面装修的保存 Request VO ")
|
@Schema(description = "管理后台 - 页面装修的保存 Request VO ")
|
||||||
@Data
|
@Data
|
||||||
@ -17,28 +15,17 @@ public class DecorateComponentSaveReqVO {
|
|||||||
@Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "页面 id 不能为空")
|
@NotNull(message = "页面 id 不能为空")
|
||||||
@InEnum(DecoratePageEnum.class)
|
@InEnum(DecoratePageEnum.class)
|
||||||
private Integer pageId;
|
private Integer page;
|
||||||
|
|
||||||
@Schema(description = "页面组件列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO")
|
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
|
||||||
@NotEmpty(message = "页面组件列表不能为空")
|
@NotEmpty(message = "组件编码不能为空")
|
||||||
@Valid
|
private String code;
|
||||||
private List<ComponentReqVO> components;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 页面装修组件 Request VO")
|
@Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@Data
|
@NotEmpty(message = "组件值为空")
|
||||||
public static class ComponentReqVO {
|
private String value;
|
||||||
|
|
||||||
@Schema(description = "组件编码", example = "1")
|
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Long id;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
|
|
||||||
@NotEmpty(message = "组件编码不能为空")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO")
|
|
||||||
@NotEmpty(message = "组件值为空")
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.app.decorate;
|
package cn.iocoder.yudao.module.promotion.controller.app.decorate;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
|
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService;
|
import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -15,9 +17,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
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.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert.INSTANCE;
|
|
||||||
|
|
||||||
@Tag(name = "用户 APP - 店铺装修")
|
@Tag(name = "用户 APP - 店铺装修")
|
||||||
@RestController
|
@RestController
|
||||||
@ -28,12 +30,13 @@ public class AppDecorateController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DecorateComponentService decorateComponentService;
|
private DecorateComponentService decorateComponentService;
|
||||||
|
|
||||||
@GetMapping("/get-page-components")
|
@GetMapping("/get-component-list")
|
||||||
@Operation(summary = "获取装修页面组件")
|
@Operation(summary = "获取指定页面的组件列表")
|
||||||
@Parameter(name = "pageId", description = "页面 id", required = true)
|
@Parameter(name = "page", description = "页面编号", required = true)
|
||||||
public CommonResult<AppDecorateComponentRespVO> getPageComponents(
|
public CommonResult<List<AppDecorateComponentRespVO>> getDecorateComponentListByPage(
|
||||||
@RequestParam("pageId") @InEnum(DecoratePageEnum.class) Integer pageId) {
|
@RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) {
|
||||||
return success(INSTANCE.appConvert(pageId, decorateComponentService.getPageComponents(pageId)));
|
return success(DecorateComponentConvert.INSTANCE.convertList(
|
||||||
|
decorateComponentService.getDecorateComponentListByPage(page, CommonStatusEnum.ENABLE.getStatus())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,28 +3,14 @@ package cn.iocoder.yudao.module.promotion.controller.app.decorate.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
@Schema(description = "用户 App - 页面组件 Resp VO")
|
||||||
|
|
||||||
@Schema(description = "用户 App - 页面装修 Resp VO")
|
|
||||||
@Data
|
@Data
|
||||||
public class AppDecorateComponentRespVO {
|
public class AppDecorateComponentRespVO {
|
||||||
|
|
||||||
@Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
|
||||||
private Integer pageId;
|
private String code;
|
||||||
|
|
||||||
@Schema(description = "页面组件", requiredMode = Schema.RequiredMode.REQUIRED, example = "TODO")
|
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
|
||||||
private List<AppComponentRespVO> components;
|
private String value;
|
||||||
|
|
||||||
@Schema(description = "用户 App - 页面组件 Resp VO")
|
|
||||||
@Data
|
|
||||||
public static class AppComponentRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.convert.decorate;
|
package cn.iocoder.yudao.module.promotion.convert.decorate;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
@ -10,33 +9,15 @@ import org.mapstruct.factory.Mappers;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO.*;
|
|
||||||
import static cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO.*;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DecorateComponentConvert {
|
public interface DecorateComponentConvert {
|
||||||
|
|
||||||
DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class);
|
DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class);
|
||||||
|
|
||||||
default List<DecorateComponentDO> convertList(Integer pageId, List<DecorateComponentSaveReqVO.ComponentReqVO> components) {
|
List<DecorateComponentRespVO> convertList02(List<DecorateComponentDO> list);
|
||||||
return CollectionUtils.convertList(components, c -> convert(pageId, c));
|
|
||||||
}
|
|
||||||
|
|
||||||
default DecorateComponentRespVO convert2(Integer pageId, List<DecorateComponentDO> list) {
|
DecorateComponentDO convert(DecorateComponentSaveReqVO bean);
|
||||||
List<ComponentRespVO> components = CollectionUtils.convertList(list, this::convert3);
|
|
||||||
return new DecorateComponentRespVO().setPageId(pageId).setComponents(components);
|
|
||||||
}
|
|
||||||
|
|
||||||
DecorateComponentDO convert(Integer pageId, DecorateComponentSaveReqVO.ComponentReqVO reqVO);
|
List<AppDecorateComponentRespVO> convertList(List<DecorateComponentDO> list);
|
||||||
|
|
||||||
ComponentRespVO convert3(DecorateComponentDO componentDO);
|
|
||||||
|
|
||||||
// ========== App convert ==========
|
|
||||||
default AppDecorateComponentRespVO appConvert(Integer pageId, List<DecorateComponentDO> list) {
|
|
||||||
List<AppComponentRespVO> components = CollectionUtils.convertList(list, this::appConvert2);
|
|
||||||
return new AppDecorateComponentRespVO().setPageId(pageId).setComponents(components);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppComponentRespVO appConvert2(DecorateComponentDO bean);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,14 @@ public class DecorateComponentDO extends BaseDO {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属页面 id
|
* 所属页面 id
|
||||||
* 枚举 {@link DecoratePageEnum#getId()}
|
*
|
||||||
|
* 枚举 {@link DecoratePageEnum#getPage()}
|
||||||
*/
|
*/
|
||||||
private Integer pageId;
|
private Integer page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件编码
|
* 组件编码
|
||||||
* 枚举 {@link DecorateComponentEnum#getCode()}
|
* 枚举 {@link DecorateComponentEnum#getCode()}
|
||||||
*/
|
*/
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@ -47,4 +48,5 @@ public class DecorateComponentDO extends BaseDO {
|
|||||||
* 枚举 {@link CommonStatusEnum}
|
* 枚举 {@link CommonStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.dal.mysql.decorate;
|
package cn.iocoder.yudao.module.promotion.dal.mysql.decorate;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,8 +10,15 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface DecorateComponentMapper extends BaseMapperX<DecorateComponentDO> {
|
public interface DecorateComponentMapper extends BaseMapperX<DecorateComponentDO> {
|
||||||
|
|
||||||
default List<DecorateComponentDO> selectByPage(Integer pageId){
|
default List<DecorateComponentDO> selectListByPageAndStatus(Integer page, Integer status) {
|
||||||
return selectList(DecorateComponentDO::getPageId, pageId);
|
return selectList(new LambdaQueryWrapperX<DecorateComponentDO>()
|
||||||
|
.eq(DecorateComponentDO::getPage, page)
|
||||||
|
.eqIfPresent(DecorateComponentDO::getStatus, status));
|
||||||
|
}
|
||||||
|
|
||||||
|
default DecorateComponentDO selectByPageAndCode(Integer page, String code) {
|
||||||
|
return selectOne(DecorateComponentDO::getPage, page,
|
||||||
|
DecorateComponentDO::getCode, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,18 @@ import java.util.List;
|
|||||||
public interface DecorateComponentService {
|
public interface DecorateComponentService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺装修页面保存
|
* 保存页面的组件信息
|
||||||
*
|
*
|
||||||
* @param reqVO 请求 VO
|
* @param reqVO 请求 VO
|
||||||
*/
|
*/
|
||||||
void savePageComponents(DecorateComponentSaveReqVO reqVO);
|
void saveDecorateComponent(DecorateComponentSaveReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据页面 id。获取页面的组件信息
|
* 根据页面 id,获取页面的组件信息
|
||||||
*
|
*
|
||||||
* @param pageId 页面类型 {@link DecoratePageEnum#getId()}
|
* @param page 页面编号 {@link DecoratePageEnum#getPage()}
|
||||||
|
* @param status 状态
|
||||||
*/
|
*/
|
||||||
List<DecorateComponentDO> getPageComponents(Integer pageId);
|
List<DecorateComponentDO> getDecorateComponentListByPage(Integer page, Integer status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.service.decorate;
|
package cn.iocoder.yudao.module.promotion.service.decorate;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO.ComponentReqVO;
|
import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
|
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
||||||
import static cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert.INSTANCE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装修组件 Service 实现
|
* 装修组件 Service 实现
|
||||||
@ -27,22 +21,20 @@ public class DecorateComponentServiceImpl implements DecorateComponentService {
|
|||||||
private DecorateComponentMapper decorateComponentMapper;
|
private DecorateComponentMapper decorateComponentMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void savePageComponents(DecorateComponentSaveReqVO reqVO) {
|
public void saveDecorateComponent(DecorateComponentSaveReqVO reqVO) {
|
||||||
// 1.新增或修改页面组件
|
// 1. 如果存在,则进行更新
|
||||||
List<DecorateComponentDO> oldList = decorateComponentMapper.selectByPage(reqVO.getPageId());
|
DecorateComponentDO dbComponent = decorateComponentMapper.selectByPageAndCode(reqVO.getPage(), reqVO.getCode());
|
||||||
|
if (dbComponent != null) {
|
||||||
decorateComponentMapper.saveOrUpdateBatch(INSTANCE.convertList(reqVO.getPageId(), reqVO.getComponents()));
|
decorateComponentMapper.updateById(DecorateComponentConvert.INSTANCE.convert(reqVO).setId(dbComponent.getId()));
|
||||||
// 2.删除相关组件
|
return;
|
||||||
Set<Long> deleteIds = convertSet(oldList, DecorateComponentDO::getId);
|
|
||||||
deleteIds.removeAll(convertSet(reqVO.getComponents(), ComponentReqVO::getId, vo->Objects.nonNull(vo.getId())));
|
|
||||||
if (CollUtil.isNotEmpty(deleteIds)) {
|
|
||||||
decorateComponentMapper.deleteBatchIds(deleteIds);
|
|
||||||
}
|
}
|
||||||
|
// 2. 不存在,则进行新增
|
||||||
|
decorateComponentMapper.insert(DecorateComponentConvert.INSTANCE.convert(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DecorateComponentDO> getPageComponents(Integer pageId) {
|
public List<DecorateComponentDO> getDecorateComponentListByPage(Integer page, Integer status) {
|
||||||
return decorateComponentMapper.selectByPage(pageId);
|
return decorateComponentMapper.selectListByPageAndStatus(page, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import org.mockito.Mockito;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum.ROLLING_BANNER;
|
import static cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum.ROLLING_NEWS;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum.INDEX;
|
import static cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum.INDEX;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest {
|
|||||||
void testResp(){
|
void testResp(){
|
||||||
List<DecorateComponentDO> list = new ArrayList<>(1);
|
List<DecorateComponentDO> list = new ArrayList<>(1);
|
||||||
DecorateComponentDO decorateDO = new DecorateComponentDO()
|
DecorateComponentDO decorateDO = new DecorateComponentDO()
|
||||||
.setPageId(INDEX.getId()).setValue("")
|
.setPage(INDEX.getPage()).setValue("")
|
||||||
.setCode(ROLLING_BANNER.getCode()).setId(1L);
|
.setCode(ROLLING_NEWS.getCode()).setId(1L);
|
||||||
list.add(decorateDO);
|
list.add(decorateDO);
|
||||||
//mock 方法
|
//mock 方法
|
||||||
Mockito.when(decorateComponentMapper.selectByPage(eq(1))).thenReturn(list);
|
Mockito.when(decorateComponentMapper.selectListByPageAndStatus(eq(1))).thenReturn(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user