商品分类review修改

This commit is contained in:
jiangweifan 2020-05-08 12:07:18 +08:00
parent a3cbccecd6
commit 0c328605b7
17 changed files with 106 additions and 172 deletions

View File

@ -1,11 +1,13 @@
package cn.iocoder.mall.product.biz.enums;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
/**
* 错误码枚举类
*
* 商品系统使用 1-003-000-000
*/
public enum ProductErrorCodeEnum {
public enum ProductErrorCodeEnum implements ServiceExceptionUtil.Enumerable {
// ========== PRODUCT CATEGORY 模块 ==========
PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"),
@ -45,12 +47,12 @@ public enum ProductErrorCodeEnum {
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
@Override
public int getCode() {
return code;
}
}

View File

@ -1,56 +0,0 @@
package cn.iocoder.mall.product.biz.bo.category;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 商品分类列表BO
*/
@Data
@Accessors(chain = true)
// TODO FROM 芋艿 to 伟帆
public class ProductCategoryAllListBO implements Serializable {
/**
* 分类编号
*/
private Integer id;
/**
* 父分类编号
*
* 如果不存在父级 pid = 0
*/
private Integer pid;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 排序值
*/
private Integer sort;
/**
* 状态
*
* 1-开启
* 2-关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -8,12 +8,12 @@ import java.util.Date;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 创建商品分类BO
* @Description: 商品分类 - 商品分类统一BO
*/
@Data
@Accessors(chain = true)
// TODO FROM 芋艿 to 伟帆BO 可以不加 Serializable 接口因为没序列化的诉求哈一般 BO 可以创建一个统一的 ProductCategory可以把 ProductCategoryAllListBO 合并过来
public class ProductCategoryAddBO implements Serializable {
// TODO FROM 芋艿 to 伟帆BO 可以不加 Serializable 接口因为没序列化的诉求哈一般 BO 可以创建一个统一的 ProductCategory可以把 ProductCategoryAllListBO 合并过来 [DONE]
public class ProductCategoryBO {
/**
* 分类编号

View File

@ -1,12 +1,10 @@
package cn.iocoder.mall.product.biz.convert.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@ -21,19 +19,19 @@ public interface ProductCategoryConvert {
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
/**
* 商品分类列表 - DO转换BO 单实体
* 商品分类统一DO转BO
* @param category
* @return
*/
ProductCategoryAllListBO convertToAllListBO(ProductCategoryDO category);
ProductCategoryBO convertToBO(ProductCategoryDO category);
/**
* 商品分类列表 - DO转换BO {@link #convertToAllListBO(ProductCategoryDO)}
* 商品分类列表 - DO转换BO {@link #convertToBO(ProductCategoryDO)}
* @param category
* @return
*/
List<ProductCategoryAllListBO> convertToAllListBO(List<ProductCategoryDO> category);
List<ProductCategoryBO> convertToAllListBO(List<ProductCategoryDO> category);
/**
* 新增商品分类 - DTO转换DO
@ -42,13 +40,6 @@ public interface ProductCategoryConvert {
*/
ProductCategoryDO convertToDO(ProductCategoryAddDTO productCategoryAddDTO);
/**
* 新增商品分类 - DO转换BO
* @param category
* @return
*/
ProductCategoryAddBO convertToAddBO(ProductCategoryDO category);
/**
* 更新商品分类 - DTO转换DO
* @param productCategoryUpdateDTO

View File

@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
@ -15,20 +17,24 @@ public class ProductCategoryAddDTO {
/**
* 管理员id
*/
// TODO FROM 芋艿 to 伟帆传入 Service 要加下 Validation 的注解虽然 Controller 那也添加了 Validation但是相比来说Service 更应该被保护嘿嘿因为一些时候Service 也会被别人所调用所以要保护好自己
// TODO FROM 芋艿 to 伟帆传入 Service 要加下 Validation 的注解虽然 Controller 那也添加了 Validation但是相比来说Service 更应该被保护嘿嘿因为一些时候Service 也会被别人所调用所以要保护好自己[DONE]
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 父分类编号
*/
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 名称
*/
@NotNull(message = "名称不能为空")
private String name;
/**
* 描述
*/
@NotNull(message = "描述不能为空")
private String description;
/**
* 分类图片
@ -37,6 +43,7 @@ public class ProductCategoryAddDTO {
/**
* 排序值
*/
@NotNull(message = "排序值不能为空")
private Integer sort;
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
@ -15,10 +17,12 @@ public class ProductCategoryDeleteDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 商品分类编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
@ -15,22 +17,27 @@ public class ProductCategoryUpdateDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 父分类编号
*/
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 名称
*/
@NotNull(message = "名称不能为空")
private String name;
/**
* 描述
*/
@NotNull(message = "描述不能为空")
private String description;
/**
* 分类图片
@ -39,6 +46,7 @@ public class ProductCategoryUpdateDTO {
/**
* 排序值
*/
@NotNull(message = "描述不能为空")
private Integer sort;
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
@ -15,14 +17,17 @@ public class ProductCategoryUpdateStatusDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 商品分类编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
private Integer status;
}

View File

@ -1,12 +1,10 @@
package cn.iocoder.mall.product.biz.service.product;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO;
import java.util.List;
@ -21,14 +19,14 @@ public interface ProductCategoryService {
* 获取所有商品分类
* @return
*/
List<ProductCategoryAllListBO> getAllProductCategory();
List<ProductCategoryBO> getAllProductCategory();
/**
* 新增商品分类
* @param productCategoryAddDTO
* @return
*/
ProductCategoryAddBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO);
ProductCategoryBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO);
/**
* 更新商品分类

View File

@ -2,8 +2,7 @@ package cn.iocoder.mall.product.biz.service.product.impl;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.convert.category.ProductCategoryConvert;
import cn.iocoder.mall.product.biz.dao.product.ProductCategoryMapper;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
@ -11,13 +10,14 @@ import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO;
import cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum;
import cn.iocoder.mall.product.biz.enums.product.ProductCategoryConstants;
import cn.iocoder.mall.product.biz.service.product.ProductCategoryService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import static cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum.*;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@ -27,6 +27,7 @@ import java.util.List;
* @Description: 商品分类 - 服务实现层
*/
@Service
@Validated
public class ProductCategoryServiceImpl implements ProductCategoryService {
@Autowired
@ -37,7 +38,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
* @return
*/
@Override
public List<ProductCategoryAllListBO> getAllProductCategory() {
public List<ProductCategoryBO> getAllProductCategory() {
List<ProductCategoryDO> categoryList = productCategoryMapper.selectList(null);
return ProductCategoryConvert.INSTANCE.convertToAllListBO(categoryList);
}
@ -48,7 +49,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
* @return
*/
@Override
public ProductCategoryAddBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO) {
public ProductCategoryBO addProductCategory(@Valid ProductCategoryAddDTO productCategoryAddDTO) {
// 校验父分类
validParent(productCategoryAddDTO.getPid());
// 保存到数据库
@ -57,9 +58,9 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
productCategory.setCreateTime(new Date());
productCategory.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
productCategoryMapper.insert(productCategory);
// TODO jiangweifan 操作日志
// TODO 伟帆 操作日志
// 返回成功
return ProductCategoryConvert.INSTANCE.convertToAddBO(productCategory);
return ProductCategoryConvert.INSTANCE.convertToBO(productCategory);
}
/**
@ -68,26 +69,26 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
* @return
*/
@Override
public Boolean updateProductCategory(ProductCategoryUpdateDTO productCategoryUpdateDTO) {
public Boolean updateProductCategory(@Valid ProductCategoryUpdateDTO productCategoryUpdateDTO) {
// 校验当前分类是否存在
if (productCategoryMapper.selectById(productCategoryUpdateDTO.getId()) == null) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 校验父分类
validParent(productCategoryUpdateDTO.getPid());
// 校验不能设置自己为父分类
if (productCategoryUpdateDTO.getId().equals(productCategoryUpdateDTO.getPid())) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_SELF.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_SELF);
}
// 校验父分类是否存在
if (!ProductCategoryConstants.PID_ROOT.equals(productCategoryUpdateDTO.getPid())
&& productCategoryMapper.selectById(productCategoryUpdateDTO.getPid()) == null) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
}
// 更新到数据库
ProductCategoryDO productCategoryDO = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateDTO);
productCategoryMapper.updateById(productCategoryDO);
// TODO jiangweifan 操作日志
// TODO 伟帆 操作日志
return true;
}
@ -97,27 +98,27 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
* @return
*/
@Override
public Boolean updateProductCategoryStatus(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO) {
public Boolean updateProductCategoryStatus(@Valid ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO) {
Integer productCategoryId = productCategoryUpdateStatusDTO.getId();
Integer status = productCategoryUpdateStatusDTO.getStatus();
// 校验商品分类是否存在
ProductCategoryDO productCategoryDO = productCategoryMapper.selectById(productCategoryId);
if (productCategoryDO == null) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 判断更新状态是否存在
if (!ProductCategoryConstants.STATUS_ENABLE.equals(status)
&& !ProductCategoryConstants.STATUS_DISABLE.equals(status)) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_NOT_EXISTS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_STATUS_NOT_EXISTS);
}
// 如果状态相同则返回错误
if (productCategoryDO.getStatus().equals(status)) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_EQUALS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_STATUS_EQUALS);
}
// 更新商品分类
productCategoryDO.setId(productCategoryId).setStatus(status);
productCategoryMapper.updateById(productCategoryDO);
// TODO jiangweifan 操作日志
// TODO 伟帆 操作日志
return true;
}
@ -127,31 +128,31 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
* @return
*/
@Override
public Boolean deleteProductCategory(ProductCategoryDeleteDTO productCategoryDeleteDTO) {
public Boolean deleteProductCategory(@Valid ProductCategoryDeleteDTO productCategoryDeleteDTO) {
Integer productCategoryId = productCategoryDeleteDTO.getId();
// 校验分类是否存在
ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId);
if (productCategory == null) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 只有禁用的商品分类才可以删除
if (ProductCategoryConstants.STATUS_ENABLE.equals(productCategory.getStatus())) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_DELETE_ONLY_DISABLE.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_DISABLE);
}
// 只有不存在子分类才可以删除
Integer childCount = productCategoryMapper.selectCount(
Wrappers.<ProductCategoryDO>lambdaQuery().eq(ProductCategoryDO::getPid, productCategoryId)
);
if (childCount > 0) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD);
}
// TODO jiangweifan 补充只有不存在商品才可以删除
// TODO 伟帆 补充只有不存在商品才可以删除
// 标记删除商品分类
ProductCategoryDO updateProductCategory = new ProductCategoryDO()
.setId(productCategoryId);
updateProductCategory.setDeleted(DeletedStatusEnum.DELETED_YES.getValue());
productCategoryMapper.updateById(updateProductCategory);
// TODO jiangweifan 操作日志
// TODO 伟帆 操作日志
return true;
}
@ -164,12 +165,12 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
ProductCategoryDO parentCategory = productCategoryMapper.selectById(pid);
// 校验父分类是否存在
if (parentCategory == null) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode());
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
}
// 父分类必须是一级分类
if (!ProductCategoryConstants.PID_ROOT.equals(parentCategory.getPid())) {
// TODO FROM 芋艿 to 伟帆ProductErrorCodeEnum 去实现下 ServiceExceptionUtil.Enumerable 接口酱紫就不用 .getCode() 方法代码会更简洁同时可以把 ProductErrorCodeEnum static import
throw ServiceExceptionUtil.exception((ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2.getCode()));
// TODO FROM 芋艿 to 伟帆ProductErrorCodeEnum 去实现下 ServiceExceptionUtil.Enumerable 接口酱紫就不用 .getCode() 方法代码会更简洁同时可以把 ProductErrorCodeEnum static import [DONE]
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2);
}
}
}

View File

@ -2,8 +2,7 @@ package cn.iocoder.mall.product.rest.controller.admins;
import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
@ -45,9 +44,9 @@ public class AdminsProductCategoryController {
@GetMapping("/tree")
@ApiOperation("获取分类树结构")
public CommonResult<List<AdminsProductCategoryTreeNodeResponse>> tree() {
List<ProductCategoryAllListBO> productCategories = productCategoryService.getAllProductCategory();
List<ProductCategoryBO> productCategories = productCategoryService.getAllProductCategory();
// 创建 ProductCategoryTreeNodeVO Map
Map<Integer, AdminsProductCategoryTreeNodeResponse> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryAllListBO::getId, ProductCategoryConvert.INSTANCE::convertToTreeNodeResponse));
Map<Integer, AdminsProductCategoryTreeNodeResponse> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, ProductCategoryConvert.INSTANCE::convertToTreeNodeResponse));
// 处理父子关系
treeNodeMap.values().stream()
.filter(node -> !node.getPid().equals(ProductCategoryConstants.PID_ROOT))
@ -74,7 +73,7 @@ public class AdminsProductCategoryController {
// 转换 ProductCategoryAddDTO 对象
ProductCategoryAddDTO productCategoryAddDTO = ProductCategoryConvert.INSTANCE.convertToAddDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryAddRequest);
// 创建商品分类
ProductCategoryAddBO addProductCategoryBO = productCategoryService.addProductCategory(productCategoryAddDTO);
ProductCategoryBO addProductCategoryBO = productCategoryService.addProductCategory(productCategoryAddDTO);
// 返回结果
return success(ProductCategoryConvert.INSTANCE.convertToAddResponse(addProductCategoryBO));
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.mall.product.rest.convert.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
@ -12,7 +11,6 @@ import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdate
import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryAddResponse;
import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryTreeNodeResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
/**
@ -30,7 +28,7 @@ public interface ProductCategoryConvert {
* @param productCategoryAllListBO
* @return
*/
AdminsProductCategoryTreeNodeResponse convertToTreeNodeResponse(ProductCategoryAllListBO productCategoryAllListBO);
AdminsProductCategoryTreeNodeResponse convertToTreeNodeResponse(ProductCategoryBO productCategoryAllListBO);
/**
@ -45,7 +43,7 @@ public interface ProductCategoryConvert {
* @param productCategoryAddBO
* @return
*/
AdminsProductCategoryAddResponse convertToAddResponse(ProductCategoryAddBO productCategoryAddBO);
AdminsProductCategoryAddResponse convertToAddResponse(ProductCategoryBO productCategoryAddBO);
/**
* 更新商品分类 - Request转DTO

View File

@ -17,34 +17,19 @@ import javax.validation.constraints.NotNull;
@Accessors(chain = true)
public class AdminsProductCategoryAddRequest {
// TODO FROM 芋艿 to 伟帆写了 swagger 注解我们可以少写一份 Java 注释
/**
* 父分类编号
*/
// TODO FROM 芋艿 to 伟帆写了 swagger 注解我们可以少写一份 Java 注释[DONE]
@ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 名称
*/
@ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info")
@NotNull(message = "名称不能为空")
private String name;
/**
* 描述
*/
@ApiModelProperty(name = "description", value = "描述", required = true, example = "1")
@NotNull(message = "描述不能为空")
private String description;
/**
* 分类图片
*/
@ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/")
private String picUrl;
/**
* 排序值
*/
@ApiModelProperty(name = "sort", value = "排序", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
}

View File

@ -16,39 +16,22 @@ import javax.validation.constraints.NotNull;
@Data
@Accessors(chain = true)
public class AdminsProductCategoryUpdateRequest {
/**
* 编号
*/
@ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 父分类编号
*/
@ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 名称
*/
@ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info")
@NotNull(message = "名称不能为空")
private String name;
/**
* 描述
*/
@ApiModelProperty(name = "description", value = "描述", required = true, example = "1")
@NotNull(message = "描述不能为空")
private String description;
/**
* 分类图片
*/
@ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/")
private String picUrl;
/**
* 排序值
*/
@ApiModelProperty(name = "sort", value = "排序", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
}

View File

@ -16,16 +16,10 @@ import javax.validation.constraints.NotNull;
@Data
@Accessors(chain = true)
public class AdminsProductCategoryUpdateStatusRequest {
/**
* 商品分类编号
*/
@ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 更新状态
*/
@ApiModelProperty(name = "status", value = "状态。1 - 开启2 - 禁用", required = true, example = "1")
@NotNull(message = "状态不能为空")
private Integer status;
}

View File

@ -18,18 +18,25 @@ public class AdminsProductCategoryAddResponse {
@ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "父分类编号", required = true, example = "0")
private Integer pid;
@ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name;
@ApiModelProperty(value = "描述", required = true, example = "这个商品很吊")
private String description;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl;
@ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, notes = "1-开启2-关闭", example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;

View File

@ -20,20 +20,28 @@ public class AdminsProductCategoryTreeNodeResponse {
@ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "父分类编号", required = true, example = "0")
private Integer pid;
@ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name;
@ApiModelProperty(value = "描述", required = true, example = "这个商品很吊")
private String description;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl;
@ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, notes = "1-开启2-关闭", example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
@ApiModelProperty(value = "子节点数组")
private List<AdminsProductCategoryTreeNodeResponse> children;