新增- 商品分类更新,商品分类状态更新,商品分类删除接口
This commit is contained in:
@@ -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<Boolean> 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<Boolean> 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<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
// 创建 ProductCategoryDeleteDTO 对象
|
||||
ProductCategoryDeleteDTO productCategoryDeleteDTO = ProductCategoryConvert.INSTANCE.convertToDeleteDTO(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
// 删除商品分类
|
||||
return success(productCategoryService.deleteProductCategory(productCategoryDeleteDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user