From 016600ab2ee06676b72c36b4e341ca9915d7e2c1 Mon Sep 17 00:00:00 2001 From: jiangweifan <1553713823@qq.com> Date: Thu, 7 May 2020 19:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E-=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E6=9B=B4=E6=96=B0=EF=BC=8C=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB=E5=88=A0=E9=99=A4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/enums/ProductErrorCodeEnum.java | 2 + .../category/ProductCategoryConvert.java | 15 +-- .../category/ProductCategoryDeleteDTO.java | 24 +++++ .../ProductCategoryUpdateDTO.java | 18 ++-- .../ProductCategoryUpdateStatusDTO.java | 28 ++++++ .../product/ProductCategoryService.java | 25 +++++ .../impl/ProductCategoryServiceImpl.java | 99 +++++++++++++++++++ .../AdminsProductCategoryController.java | 37 ++++++- .../category/ProductCategoryConvert.java | 30 +++++- .../AdminsProductCategoryUpdateRequest.java | 54 ++++++++++ ...insProductCategoryUpdateStatusRequest.java | 31 ++++++ 11 files changed, 342 insertions(+), 21 deletions(-) create mode 100644 product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryDeleteDTO.java rename product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/{product => category}/ProductCategoryUpdateDTO.java (54%) create mode 100644 product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateStatusDTO.java create mode 100644 product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateRequest.java create mode 100644 product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateStatusRequest.java diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java index d4a9697a4..e5ad307c8 100644 --- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java +++ b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java @@ -10,9 +10,11 @@ public enum ProductErrorCodeEnum { // ========== PRODUCT CATEGORY 模块 ========== PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"), PRODUCT_CATEGORY_NOT_EXISTS(1003001001, "商品分类不存在"), + PRODUCT_CATEGORY_STATUS_NOT_EXISTS(1003001001, "商品分类状态不存在"), PRODUCT_CATEGORY_PARENT_NOT_SELF(1003001002, "不能设置自己为父分类"), PRODUCT_CATEGORY_STATUS_EQUALS(1002001003, "商品分类已经是该状态"), PRODUCT_CATEGORY_DELETE_ONLY_DISABLE(1002001004, "只有关闭的商品分类才可以删除"), + PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD(1002001004, "只有无子分类的商品分类才可以删除"), PRODUCT_CATEGORY_MUST_ENABLE(1002001005, "只有开启的商品分类,才可以使用"), PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2(1002001005, "父分类必须是一级分类"), diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/category/ProductCategoryConvert.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/category/ProductCategoryConvert.java index f71f38a9b..e19de6c07 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/category/ProductCategoryConvert.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/category/ProductCategoryConvert.java @@ -4,6 +4,7 @@ import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO; import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO; 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; @@ -24,7 +25,6 @@ public interface ProductCategoryConvert { * @param category * @return */ - @Mappings({}) ProductCategoryAllListBO convertToAllListBO(ProductCategoryDO category); @@ -33,24 +33,27 @@ public interface ProductCategoryConvert { * @param category * @return */ - @Mappings({}) List convertToAllListBO(List category); /** - * 商品分类新增 - DTO转换DO + * 新增商品分类 - DTO转换DO * @param productCategoryAddDTO * @return */ - @Mappings({}) ProductCategoryDO convertToDO(ProductCategoryAddDTO productCategoryAddDTO); /** - * 商品分类新增 - DO转换BO + * 新增商品分类 - DO转换BO * @param category * @return */ - @Mappings({}) ProductCategoryAddBO convertToAddBO(ProductCategoryDO category); + /** + * 更新商品分类 - DTO转换DO + * @param productCategoryUpdateDTO + * @return + */ + ProductCategoryDO convertToDO(ProductCategoryUpdateDTO productCategoryUpdateDTO); } \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryDeleteDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryDeleteDTO.java new file mode 100644 index 000000000..d594f0afc --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryDeleteDTO.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.product.biz.dto.category; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @Author: jiangweifan + * @Date: 2020/5/6 + * @Description: 商品分类 - 删除商品分类DTO + */ +@Data +@Accessors(chain = true) +public class ProductCategoryDeleteDTO { + + /** + * 管理员id + */ + private Integer adminId; + /** + * 商品分类编号 + */ + private Integer id; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateDTO.java similarity index 54% rename from product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryUpdateDTO.java rename to product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateDTO.java index 726c6e89f..66310170d 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryUpdateDTO.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateDTO.java @@ -1,46 +1,44 @@ -package cn.iocoder.mall.product.biz.dto.product; +package cn.iocoder.mall.product.biz.dto.category; import lombok.Data; import lombok.experimental.Accessors; -import javax.validation.constraints.NotNull; - /** - * 商品分类更新 DTO + * @Author: jiangweifan + * @Date: 2020/5/6 + * @Description: 商品分类 - 更新商品分类DTO */ @Data @Accessors(chain = true) public class ProductCategoryUpdateDTO { + /** + * 管理员id + */ + private Integer adminId; /** * 编号 */ - @NotNull(message = "编号不能为空") private Integer id; /** * 父分类编号 */ - @NotNull(message = "父分类编号不能为空") private Integer pid; /** * 名称 */ - @NotNull(message = "名称不能为空") private String name; /** * 描述 */ - @NotNull(message = "描述不能为空") private String description; /** * 分类图片 */ -// @NotNull(message = "分类图片不能为空") private String picUrl; /** * 排序值 */ - @NotNull(message = "排序值不能为空") private Integer sort; } diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateStatusDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateStatusDTO.java new file mode 100644 index 000000000..1f7a68bac --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/category/ProductCategoryUpdateStatusDTO.java @@ -0,0 +1,28 @@ +package cn.iocoder.mall.product.biz.dto.category; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @Author: jiangweifan + * @Date: 2020/5/6 + * @Description: 商品分类 - 更新商品分类状态DTO + */ +@Data +@Accessors(chain = true) +public class ProductCategoryUpdateStatusDTO { + + /** + * 管理员id + */ + private Integer adminId; + /** + * 商品分类编号 + */ + private Integer id; + /** + * 状态 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java index 988c30397..e08b680e5 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java @@ -3,6 +3,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.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; @@ -25,4 +29,25 @@ public interface ProductCategoryService { * @return */ ProductCategoryAddBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO); + + /** + * 更新商品分类 + * @param productCategoryUpdateDTO + * @return + */ + Boolean updateProductCategory(ProductCategoryUpdateDTO productCategoryUpdateDTO); + + /** + * 更新商品分类状态 + * @param productCategoryUpdateStatusDTO + * @return + */ + Boolean updateProductCategoryStatus(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO); + + /** + * 删除商品分类 + * @param productCategoryDeleteDTO + * @return + */ + Boolean deleteProductCategory(ProductCategoryDeleteDTO productCategoryDeleteDTO); } diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java index c973f1239..ca377b6cf 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java @@ -8,11 +8,17 @@ 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; 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 java.sql.Wrapper; import java.util.*; /** @@ -56,6 +62,99 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { return ProductCategoryConvert.INSTANCE.convertToAddBO(productCategory); } + /** + * 更新商品分类 + * @param productCategoryUpdateDTO + * @return + */ + @Override + public Boolean updateProductCategory(ProductCategoryUpdateDTO productCategoryUpdateDTO) { + // 校验当前分类是否存在 + if (productCategoryMapper.selectById(productCategoryUpdateDTO.getId()) == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode()); + } + // 校验父分类 + validParent(productCategoryUpdateDTO.getPid()); + // 校验不能设置自己为父分类 + if (productCategoryUpdateDTO.getId().equals(productCategoryUpdateDTO.getPid())) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_SELF.getCode()); + } + // 校验父分类是否存在 + if (!ProductCategoryConstants.PID_ROOT.equals(productCategoryUpdateDTO.getPid()) + && productCategoryMapper.selectById(productCategoryUpdateDTO.getPid()) == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode()); + } + // 更新到数据库 + ProductCategoryDO productCategoryDO = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateDTO); + productCategoryMapper.updateById(productCategoryDO); + // TODO jiangweifan 操作日志 + return true; + } + + /** + * 更新商品分类状态 + * @param productCategoryUpdateStatusDTO + * @return + */ + @Override + public Boolean updateProductCategoryStatus(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()); + } + // 判断更新状态是否存在 + if (!ProductCategoryConstants.STATUS_ENABLE.equals(status) + && !ProductCategoryConstants.STATUS_DISABLE.equals(status)) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_NOT_EXISTS.getCode()); + } + // 如果状态相同,则返回错误 + if (productCategoryDO.getStatus().equals(status)) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_EQUALS.getCode()); + } + // 更新商品分类 + productCategoryDO.setId(productCategoryId).setStatus(status); + productCategoryMapper.updateById(productCategoryDO); + // TODO jiangweifan 操作日志 + return true; + } + + /** + * 删除商品分类 + * @param productCategoryDeleteDTO + * @return + */ + @Override + public Boolean deleteProductCategory(ProductCategoryDeleteDTO productCategoryDeleteDTO) { + Integer productCategoryId = productCategoryDeleteDTO.getId(); + // 校验分类是否存在 + ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId); + if (productCategory == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode()); + } + // 只有禁用的商品分类才可以删除 + if (ProductCategoryConstants.STATUS_ENABLE.equals(productCategory.getStatus())) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_DELETE_ONLY_DISABLE.getCode()); + } + // 只有不存在子分类才可以删除 + Integer childCount = productCategoryMapper.selectCount( + Wrappers.lambdaQuery().eq(ProductCategoryDO::getPid, productCategoryId) + ); + if (childCount > 0) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD.getCode()); + } + // TODO jiangweifan 补充只有不存在商品才可以删除 + // 标记删除商品分类 + ProductCategoryDO updateProductCategory = new ProductCategoryDO() + .setId(productCategoryId); + updateProductCategory.setDeleted(DeletedStatusEnum.DELETED_YES.getValue()); + productCategoryMapper.updateById(updateProductCategory); + // TODO jiangweifan 操作日志 + return true; + } + /** * 校验商品分类的父分类 * @param pid diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java index 1911caaa1..658b5a0ac 100644 --- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java @@ -5,24 +5,28 @@ 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.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.product.ProductCategoryConstants; import cn.iocoder.mall.product.biz.service.product.ProductCategoryService; import cn.iocoder.mall.product.rest.convert.category.ProductCategoryConvert; import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryAddRequest; +import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdateRequest; +import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdateStatusRequest; import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryAddResponse; import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryTreeNodeResponse; import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; - import static cn.iocoder.common.framework.vo.CommonResult.success; /** @@ -75,4 +79,33 @@ public class AdminsProductCategoryController { return success(ProductCategoryConvert.INSTANCE.convertToAddResponse(addProductCategoryBO)); } + @PostMapping("/update") + @ApiOperation(value = "更新商品分类") + public CommonResult update(@RequestBody AdminsProductCategoryUpdateRequest adminsProductCategoryUpdateRequest) { + // 创建 ProductCategoryUpdateDTO 对象 + ProductCategoryUpdateDTO productCategoryUpdateDTO = ProductCategoryConvert.INSTANCE.convertToUpdateDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryUpdateRequest); + // 更新商品分类 + return success(productCategoryService.updateProductCategory(productCategoryUpdateDTO)); + } + + @PostMapping("/update_status") + @ApiOperation(value = "更新商品分类状态") + public CommonResult updateStatus(@RequestBody AdminsProductCategoryUpdateStatusRequest adminsProductCategoryUpdateStatusRequest) { + // 创建 ProductCategoryUpdateStatusDTO 对象 + ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO = ProductCategoryConvert.INSTANCE.convertToUpdateStatusDTO(AdminSecurityContextHolder.getContext().getAdminId(), + adminsProductCategoryUpdateStatusRequest); + // 更新商品分类状态 + return success(productCategoryService.updateProductCategoryStatus(productCategoryUpdateStatusDTO)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除商品分类") + @ApiImplicitParam(name = "id", value = "商品分类编号", required = true, example = "1") + public CommonResult delete(@RequestParam("id") Integer id) { + // 创建 ProductCategoryDeleteDTO 对象 + ProductCategoryDeleteDTO productCategoryDeleteDTO = ProductCategoryConvert.INSTANCE.convertToDeleteDTO(AdminSecurityContextHolder.getContext().getAdminId(), id); + // 删除商品分类 + return success(productCategoryService.deleteProductCategory(productCategoryDeleteDTO)); + } + } diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/category/ProductCategoryConvert.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/category/ProductCategoryConvert.java index 44f27e0a2..a300108bf 100644 --- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/category/ProductCategoryConvert.java +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/category/ProductCategoryConvert.java @@ -3,7 +3,12 @@ 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.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.rest.request.category.AdminsProductCategoryAddRequest; +import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdateRequest; +import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdateStatusRequest; import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryAddResponse; import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryTreeNodeResponse; import org.mapstruct.Mapper; @@ -25,7 +30,6 @@ public interface ProductCategoryConvert { * @param productCategoryAllListBO * @return */ - @Mappings({}) AdminsProductCategoryTreeNodeResponse convertToTreeNodeResponse(ProductCategoryAllListBO productCategoryAllListBO); @@ -34,7 +38,6 @@ public interface ProductCategoryConvert { * @param adminsProductCategoryAddRequest * @return */ - @Mappings({}) ProductCategoryAddDTO convertToAddDTO(Integer adminId, AdminsProductCategoryAddRequest adminsProductCategoryAddRequest); /** @@ -42,6 +45,27 @@ public interface ProductCategoryConvert { * @param productCategoryAddBO * @return */ - @Mappings({}) AdminsProductCategoryAddResponse convertToAddResponse(ProductCategoryAddBO productCategoryAddBO); + + /** + * 更新商品分类 - Request转DTO + * @param adminsProductCategoryUpdateRequest + * @return + */ + ProductCategoryUpdateDTO convertToUpdateDTO(Integer adminId, AdminsProductCategoryUpdateRequest adminsProductCategoryUpdateRequest); + + /** + * 更新商品分类状态 - Request转DTO + * @param adminsProductCategoryUpdateStatusRequest + * @return + */ + ProductCategoryUpdateStatusDTO convertToUpdateStatusDTO(Integer adminId, AdminsProductCategoryUpdateStatusRequest adminsProductCategoryUpdateStatusRequest); + + /** + * 删除商品分类 - Request转DTO + * @param adminId 管理员id + * @param id 商品分类id + * @return + */ + ProductCategoryDeleteDTO convertToDeleteDTO(Integer adminId, Integer id); } diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateRequest.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateRequest.java new file mode 100644 index 000000000..e96799935 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateRequest.java @@ -0,0 +1,54 @@ +package cn.iocoder.mall.product.rest.request.category; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * @Author: jiangweifan + * @Date: 2020/5/6 + * @Description: 商品分类 - 更新商品分类Request + */ +@ApiModel("更新商品分类Request") +@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; +} diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateStatusRequest.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateStatusRequest.java new file mode 100644 index 000000000..8777902a1 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/category/AdminsProductCategoryUpdateStatusRequest.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.product.rest.request.category; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * @Author: jiangweifan + * @Date: 2020/5/6 + * @Description: 商品分类 - 更新商品分类状态Request + */ +@ApiModel("更新商品分类状态Request") +@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; +}