MALL:清理多余的 decorate 类

This commit is contained in:
YunaiV 2024-01-17 19:45:57 +08:00
parent 6dbc942cdd
commit dd0a2b73e8
16 changed files with 9 additions and 456 deletions

View File

@ -1,61 +0,0 @@
package cn.iocoder.yudao.module.promotion.enums.decorate;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 页面组件枚举
*
* @author jason
*/
@Getter
@AllArgsConstructor
@SuppressWarnings("JavadocLinkAsPlainText")
public enum DecorateComponentEnum {
/**
* 格式[{
* "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": "类型", // besthotnewbenefitgood
* "tag": "标签" // 例如说多买多省
* }]
*
* 最多 4
*/
PRODUCT_RECOMMEND("product-recommend", "商品推荐");
/**
* 页面组件代码
*/
private final String code;
/**
* 页面组件说明
*/
private final String desc;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.enums.decorate;
package cn.iocoder.yudao.module.promotion.enums.diy;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
@ -13,13 +13,13 @@ import java.util.Arrays;
*/
@AllArgsConstructor
@Getter
public enum DecoratePageEnum implements IntArrayValuable {
public enum DiyPageEnum implements IntArrayValuable {
INDEX(1, "首页"),
MY(2, "我的"),
;
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DiyPageEnum::getPage).toArray();
/**
* 页面编号

View File

@ -43,7 +43,8 @@ public class CombinationRecordController {
@GetMapping("/page")
@Operation(summary = "获得拼团记录分页")
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getCombinationRecordPage(
@Valid CombinationRecordReqPageVO pageVO) {
PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO);
// 拼接数据
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(

View File

@ -1,18 +0,0 @@
### /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}}

View File

@ -1,50 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.admin.decorate;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.validation.InEnum;
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.service.decorate.DecorateComponentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 店铺页面装修")
@RestController
@RequestMapping("/promotion/decorate")
@Validated
public class DecorateComponentController {
@Resource
private DecorateComponentService decorateComponentService;
@PostMapping("/save")
@Operation(summary = "保存页面装修组件")
@PreAuthorize("@ss.hasPermission('promotion:decorate:save')")
public CommonResult<Boolean> saveDecorateComponent(@Valid @RequestBody DecorateComponentSaveReqVO reqVO) {
decorateComponentService.saveDecorateComponent(reqVO);
return success(true);
}
@GetMapping("/list")
@Operation(summary = "获取指定页面的组件列表")
@Parameter(name = "page", description = "页面 id", required = true)
@PreAuthorize("@ss.hasPermission('promotion:decorate:query')")
public CommonResult<List<DecorateComponentRespVO>> getDecorateComponentListByPage(
@RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) {
return success(DecorateComponentConvert.INSTANCE.convertList02(
decorateComponentService.getDecorateComponentListByPage(page, null)));
}
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 页面装修 Resp VO")
@Data
public class DecorateComponentRespVO {
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
private String code;
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
private String value;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@Schema(description = "管理后台 - 页面装修的保存 Request VO ")
@Data
public class DecorateComponentSaveReqVO {
@Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "页面 id 不能为空")
@InEnum(DecoratePageEnum.class)
private Integer page;
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
@NotEmpty(message = "组件编码不能为空")
private String code;
@Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "组件值为空")
private String value;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
}

View File

@ -1,43 +0,0 @@
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.validation.InEnum;
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.service.decorate.DecorateComponentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "用户 APP - 店铺装修")
@RestController
@RequestMapping("/promotion/decorate")
@Validated
@Deprecated // 废弃
public class AppDecorateController {
@Resource
private DecorateComponentService decorateComponentService;
@GetMapping("/list")
@Operation(summary = "获取指定页面的组件列表")
@Parameter(name = "page", description = "页面编号", required = true)
public CommonResult<List<AppDecorateComponentRespVO>> getDecorateComponentListByPage(
@RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) {
return success(DecorateComponentConvert.INSTANCE.convertList(
decorateComponentService.getDecorateComponentListByPage(page, CommonStatusEnum.ENABLE.getStatus())));
}
}

View File

@ -1,16 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.app.decorate.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 App - 页面组件 Resp VO")
@Data
public class AppDecorateComponentRespVO {
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
private String code;
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
private String value;
}

View File

@ -5,19 +5,19 @@ import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePro
import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.enums.diy.DiyPageEnum;
import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService;
import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -56,8 +56,8 @@ public class AppDiyTemplateController {
}
// 查询模板下的页面
List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
String home = findFirst(pages, page -> DecoratePageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
String user = findFirst(pages, page -> DecoratePageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
String home = findFirst(pages, page -> DiyPageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
String user = findFirst(pages, page -> DiyPageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
// 拼接返回
return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.promotion.convert.decorate;
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.dal.dataobject.decorate.DecorateComponentDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DecorateComponentConvert {
DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class);
List<DecorateComponentRespVO> convertList02(List<DecorateComponentDO> list);
DecorateComponentDO convert(DecorateComponentSaveReqVO bean);
List<AppDecorateComponentRespVO> convertList(List<DecorateComponentDO> list);
}

View File

@ -1,52 +0,0 @@
package cn.iocoder.yudao.module.promotion.dal.dataobject.decorate;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 页面装修组件 DO, 一个页面由多个组件构成
*
* @author jason
*/
@TableName(value ="promotion_decorate_component")
@KeySequence("promotion_decorate_component_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
public class DecorateComponentDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 所属页面 id
*
* 枚举 {@link DecoratePageEnum#getPage()}
*/
private Integer page;
/**
* 组件编码
* 枚举 {@link DecorateComponentEnum#getCode()}
*/
private String code;
/**
* 组件值json 格式包含配置和数据
*/
private String value;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.yudao.module.promotion.dal.mysql.decorate;
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 java.util.List;
@Mapper
public interface DecorateComponentMapper extends BaseMapperX<DecorateComponentDO> {
default List<DecorateComponentDO> selectListByPageAndStatus(Integer page, Integer status) {
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);
}
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.promotion.service.decorate;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import java.util.List;
/**
* 装修组件 Service 接口
*
* @author jason
*/
public interface DecorateComponentService {
/**
* 保存页面的组件信息
*
* @param reqVO 请求 VO
*/
void saveDecorateComponent(DecorateComponentSaveReqVO reqVO);
/**
* 根据页面 id获取页面的组件信息
*
* @param page 页面编号 {@link DecoratePageEnum#getPage()}
* @param status 状态
*/
List<DecorateComponentDO> getDecorateComponentListByPage(Integer page, Integer status);
}

View File

@ -1,40 +0,0 @@
package cn.iocoder.yudao.module.promotion.service.decorate;
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.dal.dataobject.decorate.DecorateComponentDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.List;
/**
* 装修组件 Service 实现
*
* @author jason
*/
@Service
public class DecorateComponentServiceImpl implements DecorateComponentService {
@Resource
private DecorateComponentMapper decorateComponentMapper;
@Override
public void saveDecorateComponent(DecorateComponentSaveReqVO reqVO) {
// 1. 如果存在则进行更新
DecorateComponentDO dbComponent = decorateComponentMapper.selectByPageAndCode(reqVO.getPage(), reqVO.getCode());
if (dbComponent != null) {
decorateComponentMapper.updateById(DecorateComponentConvert.INSTANCE.convert(reqVO).setId(dbComponent.getId()));
return;
}
// 2. 不存在则进行新增
decorateComponentMapper.insert(DecorateComponentConvert.INSTANCE.convert(reqVO));
}
@Override
public List<DecorateComponentDO> getDecorateComponentListByPage(Integer page, Integer status) {
return decorateComponentMapper.selectListByPageAndStatus(page, status);
}
}

View File

@ -1,36 +0,0 @@
package cn.iocoder.yudao.module.promotion.service.decorate;
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.InjectMocks;
import org.mockito.Mock;
// TODO @芋艿后续 review
/**
* @author jason
*/
public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest {
@InjectMocks
private DecorateComponentServiceImpl decoratePageService;
@Mock
private DecorateComponentMapper decorateComponentMapper;
@BeforeEach
public void init(){
}
// @Test
// void testResp(){
// List<DecorateComponentDO> list = new ArrayList<>(1);
// DecorateComponentDO decorateDO = new DecorateComponentDO()
// .setPage(INDEX.getPage()).setValue("")
// .setCode(ROLLING_NEWS.getCode()).setId(1L);
// list.add(decorateDO);
// //mock 方法
// Mockito.when(decorateComponentMapper.selectListByPageAndStatus(eq(1))).thenReturn(list);
// }
}