mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
code review 店铺装修
This commit is contained in:
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -14,7 +14,7 @@ import java.util.List;
|
||||
public class DiyTemplateBaseVO {
|
||||
|
||||
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题")
|
||||
@NotNull(message = "模板名称不能为空")
|
||||
@NotEmpty(message = "模板名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", example = "默认主题")
|
||||
|
@ -32,6 +32,8 @@ public class DiyPageDO extends BaseDO {
|
||||
private Long id;
|
||||
/**
|
||||
* 装修模板编号
|
||||
*
|
||||
* 关联 {@link DiyTemplateDO#getId()}
|
||||
*/
|
||||
private Long templateId;
|
||||
/**
|
||||
|
@ -14,6 +14,9 @@ import java.util.List;
|
||||
/**
|
||||
* 装修模板 DO
|
||||
*
|
||||
* 1. 新建一个模版,下面可以包含多个 {@link DiyPageDO} 页面,例如说首页、我的
|
||||
* 2. 如果需要使用某个模版,则将 {@link #used} 设置为 true,表示已使用,有且仅有一个
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@TableName(value = "promotion_diy_template", autoResultMap = true)
|
||||
|
@ -42,7 +42,6 @@ public class DiyPageServiceImpl implements DiyPageService {
|
||||
DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO);
|
||||
diyPage.setProperty("{}");
|
||||
diyPageMapper.insert(diyPage);
|
||||
// 返回
|
||||
return diyPage.getId();
|
||||
}
|
||||
|
||||
@ -57,6 +56,13 @@ public class DiyPageServiceImpl implements DiyPageService {
|
||||
diyPageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验 Page 页面,在一个 template 模版下的名字是唯一的
|
||||
*
|
||||
* @param id Page 编号
|
||||
* @param templateId 模版编号
|
||||
* @param name Page 名字
|
||||
*/
|
||||
void validateNameUnique(Long id, Long templateId, String name) {
|
||||
if (templateId != null || StrUtil.isBlank(name)) {
|
||||
return;
|
||||
|
@ -32,9 +32,11 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
|
||||
|
||||
@Resource
|
||||
private DiyTemplateMapper diyTemplateMapper;
|
||||
|
||||
@Resource
|
||||
private DiyPageService diyPageService;
|
||||
|
||||
// TODO @疯狂:事务;
|
||||
@Override
|
||||
public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) {
|
||||
// 校验名称唯一
|
||||
@ -120,9 +122,11 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @疯狂:事务;
|
||||
public void useDiyTemplate(Long id) {
|
||||
// 校验存在
|
||||
validateDiyTemplateExists(id);
|
||||
// TODO @疯狂:要不已使用的情况,抛个业务异常?
|
||||
// 已使用的更新为未使用
|
||||
DiyTemplateDO used = diyTemplateMapper.selectByUsed(true);
|
||||
if (used != null) {
|
||||
@ -136,8 +140,8 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
|
||||
this.updateUsed(id, true, LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDiyTemplateExists(updateReqVO.getId());
|
||||
@ -151,6 +155,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
|
||||
return diyTemplateMapper.selectByUsed(true);
|
||||
}
|
||||
|
||||
// TODO @疯狂:挪到 useDiyTemplate 下面,改名 updateTemplateUsed 会不会好点哈;
|
||||
/**
|
||||
* 更新模板是否使用
|
||||
*
|
||||
|
Reference in New Issue
Block a user