商品品牌的迁移,准备和前端管理后台对接
This commit is contained in:
parent
2b8459680b
commit
24f3e697b8
|
@ -0,0 +1,82 @@
|
|||
package cn.iocoder.mall.managementweb.controller.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.manager.product.ProductBrandManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 商品品牌 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/product-brand")
|
||||
@Api(tags = "商品品牌")
|
||||
@Validated
|
||||
public class ProductBrandController {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandManager productBrandManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建商品品牌")
|
||||
@RequiresPermissions("product:brand:create")
|
||||
public CommonResult<Integer> createProductBrand(@Valid ProductBrandCreateReqVO createVO) {
|
||||
return success(productBrandManager.createProductBrand(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新商品品牌")
|
||||
@RequiresPermissions("product:brand:update")
|
||||
public CommonResult<Boolean> updateProductBrand(@Valid ProductBrandUpdateReqVO updateVO) {
|
||||
productBrandManager.updateProductBrand(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除商品品牌")
|
||||
@ApiImplicitParam(name = "productBrandId", value = "商品品牌编号", required = true)
|
||||
@RequiresPermissions("product:brand:delete")
|
||||
public CommonResult<Boolean> deleteProductBrand(@RequestParam("productBrandId") Integer productBrandId) {
|
||||
productBrandManager.deleteProductBrand(productBrandId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得商品品牌")
|
||||
@ApiImplicitParam(name = "productBrandId", value = "商品品牌编号", required = true)
|
||||
@RequiresPermissions("product:brand:page")
|
||||
public CommonResult<ProductBrandRespVO> getProductBrand(@RequestParam("productBrandId") Integer productBrandId) {
|
||||
return success(productBrandManager.getProductBrand(productBrandId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得商品品牌列表")
|
||||
@ApiImplicitParam(name = "productBrandIds", value = "商品品牌编号列表", required = true)
|
||||
@RequiresPermissions("product:brand:page")
|
||||
public CommonResult<List<ProductBrandRespVO>> listProductBrands(@RequestParam("productBrandIds") List<Integer> productBrandIds) {
|
||||
return success(productBrandManager.listProductBrands(productBrandIds));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得商品品牌分页")
|
||||
@RequiresPermissions("product:brand:page")
|
||||
public CommonResult<PageResult<ProductBrandRespVO>> pageProductBrand(ProductBrandPageReqVO pageVO) {
|
||||
return success(productBrandManager.pageProductBrand(pageVO));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package cn.iocoder.mall.managementweb.controller.product.vo.brand;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("商品品牌创建 Request VO")
|
||||
@Data
|
||||
public class ProductBrandCreateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "品牌名称", required = true, example = "这个商品品牌很吊")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "品牌描述", example = "这个商品描述很吊")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "品牌名图片", example = "http://www.iocoder.cn/xx.jpg")
|
||||
private String picUrl;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.iocoder.mall.managementweb.controller.product.vo.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("商品品牌分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProductBrandPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "品牌名称", required = true, notes = "模糊匹配", example = "这个商品品牌很吊")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package cn.iocoder.mall.managementweb.controller.product.vo.brand;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("商品品牌 Response VO")
|
||||
@Data
|
||||
public class ProductBrandRespVO {
|
||||
|
||||
@ApiModelProperty(value = "品牌编号", required = true, example = "1024")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "品牌名称", required = true, example = "这个商品品牌很吊")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "品牌描述", example = "这个商品描述很吊")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "品牌名图片", example = "http://www.iocoder.cn/xx.jpg")
|
||||
private String picUrl;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package cn.iocoder.mall.managementweb.controller.product.vo.brand;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("商品品牌更新 Request VO")
|
||||
@Data
|
||||
public class ProductBrandUpdateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "品牌编号", required = true, example = "1024")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "品牌名称", required = true, example = "这个商品品牌很吊")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "品牌描述", example = "这个商品描述很吊")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "品牌名图片", example = "http://www.iocoder.cn/xx.jpg")
|
||||
private String picUrl;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ public class ProductCategoryRespVO {
|
|||
private Integer pid;
|
||||
@ApiModelProperty(value = "分类名称", required = true, example = "手机")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "分类描述", required = true, example = "这个商品很吊")
|
||||
@ApiModelProperty(value = "分类描述", required = true, example = "这个商品分类很吊")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/xx.jpg")
|
||||
private String picUrl;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package cn.iocoder.mall.managementweb.convert.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandUpdateReqVO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductBrandConvert {
|
||||
|
||||
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
|
||||
|
||||
ProductBrandCreateReqDTO convert(ProductBrandCreateReqVO bean);
|
||||
|
||||
ProductBrandUpdateReqDTO convert(ProductBrandUpdateReqVO bean);
|
||||
|
||||
ProductBrandRespVO convert(ProductBrandRespDTO bean);
|
||||
|
||||
List<ProductBrandRespVO> convertList(List<ProductBrandRespDTO> list);
|
||||
|
||||
PageResult<ProductBrandRespVO> convertPage(PageResult<ProductBrandRespDTO> page);
|
||||
|
||||
ProductBrandPageReqDTO convert(ProductBrandPageReqVO bean);
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package cn.iocoder.mall.managementweb.manager.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.product.ProductBrandConvert;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.ProductBrandRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品品牌 Manager
|
||||
*/
|
||||
@Service
|
||||
public class ProductBrandManager {
|
||||
|
||||
@Reference(version = "${dubbo.consumer.ProductBrandRpc.version}")
|
||||
private ProductBrandRpc productBrandRpc;
|
||||
|
||||
/**
|
||||
* 创建商品品牌
|
||||
*
|
||||
* @param createVO 创建商品品牌 VO
|
||||
* @return 商品品牌
|
||||
*/
|
||||
public Integer createProductBrand(ProductBrandCreateReqVO createVO) {
|
||||
CommonResult<Integer> createProductBrandResult = productBrandRpc.createProductBrand(ProductBrandConvert.INSTANCE.convert(createVO));
|
||||
createProductBrandResult.checkError();
|
||||
return createProductBrandResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品品牌
|
||||
*
|
||||
* @param updateVO 更新商品品牌 VO
|
||||
*/
|
||||
public void updateProductBrand(ProductBrandUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateProductBrandResult = productBrandRpc.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateVO));
|
||||
updateProductBrandResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
*/
|
||||
public void deleteProductBrand(Integer productBrandId) {
|
||||
CommonResult<Boolean> deleteProductBrandResult = productBrandRpc.deleteProductBrand(productBrandId);
|
||||
deleteProductBrandResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
* @return 商品品牌
|
||||
*/
|
||||
public ProductBrandRespVO getProductBrand(Integer productBrandId) {
|
||||
CommonResult<ProductBrandRespDTO> getProductBrandResult = productBrandRpc.getProductBrand(productBrandId);
|
||||
getProductBrandResult.checkError();
|
||||
return ProductBrandConvert.INSTANCE.convert(getProductBrandResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌列表
|
||||
*
|
||||
* @param productBrandIds 商品品牌编号列表
|
||||
* @return 商品品牌列表
|
||||
*/
|
||||
public List<ProductBrandRespVO> listProductBrands(List<Integer> productBrandIds) {
|
||||
CommonResult<List<ProductBrandRespDTO>> listProductBrandResult = productBrandRpc.listProductBrands(productBrandIds);
|
||||
listProductBrandResult.checkError();
|
||||
return ProductBrandConvert.INSTANCE.convertList(listProductBrandResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌分页
|
||||
*
|
||||
* @param pageVO 商品品牌分页查询
|
||||
* @return 商品品牌分页结果
|
||||
*/
|
||||
public PageResult<ProductBrandRespVO> pageProductBrand(ProductBrandPageReqVO pageVO) {
|
||||
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrandResult = productBrandRpc.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageVO));
|
||||
pageProductBrandResult.checkError();
|
||||
return ProductBrandConvert.INSTANCE.convertPage(pageProductBrandResult.getData());
|
||||
}
|
||||
|
||||
}
|
|
@ -51,6 +51,8 @@ dubbo:
|
|||
version: 1.0.0
|
||||
ProductCategoryRpc:
|
||||
version: 1.0.0
|
||||
ProductBrandRpc:
|
||||
version: 1.0.0
|
||||
|
||||
# Swagger 配置项
|
||||
swagger:
|
||||
|
|
|
@ -12,10 +12,7 @@ public interface ProductErrorCodeConstants {
|
|||
// ========== PRODUCT CATEGORY 模块 ==========
|
||||
ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1003001000, "父分类不存在");
|
||||
ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1003001001, "商品分类不存在");
|
||||
ErrorCode PRODUCT_CATEGORY_STATUS_NOT_EXISTS = new ErrorCode(1003001001, "商品分类状态不存在");
|
||||
ErrorCode PRODUCT_CATEGORY_PARENT_NOT_SELF = new ErrorCode(1003001002, "不能设置自己为父分类");
|
||||
ErrorCode PRODUCT_CATEGORY_STATUS_EQUALS = new ErrorCode(1002001003, "商品分类已经是该状态");
|
||||
ErrorCode PRODUCT_CATEGORY_DELETE_ONLY_DISABLE = new ErrorCode(1002001004, "只有关闭的商品分类才可以删除");
|
||||
ErrorCode PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD = new ErrorCode(1002001004, "只有无子分类的商品分类才可以删除");
|
||||
ErrorCode PRODUCT_CATEGORY_MUST_ENABLE = new ErrorCode(1002001005, "只有开启的商品分类,才可以使用");
|
||||
ErrorCode PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2 = new ErrorCode(1002001005, "父分类必须是一级分类");
|
||||
|
@ -36,6 +33,7 @@ public interface ProductErrorCodeConstants {
|
|||
ErrorCode PRODUCT_ATTR_VALUE_STATUS_EQUALS = new ErrorCode(1003003005, "商品规格值已经是该状态");
|
||||
|
||||
// ========== PRODUCT BRAND模块 ==========
|
||||
ErrorCode PRODUCT_BRAND_EXIST = new ErrorCode(1003004000,"品牌值已经存在");
|
||||
ErrorCode PRODUCT_BRAND_NAME_EXIST = new ErrorCode(1003004000,"商品品牌的名字已经存在");
|
||||
ErrorCode PRODUCT_BRAND_NOT_FOUND = new ErrorCode(1003004001, "商品品牌不粗糙你在");
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package cn.iocoder.mall.productservice.rpc.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品品牌 Rpc 接口
|
||||
*/
|
||||
public interface ProductBrandRpc {
|
||||
|
||||
/**
|
||||
* 创建商品品牌
|
||||
*
|
||||
* @param createDTO 创建商品品牌 DTO
|
||||
* @return 商品品牌编号
|
||||
*/
|
||||
CommonResult<Integer> createProductBrand(ProductBrandCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 更新商品品牌
|
||||
*
|
||||
* @param updateDTO 更新商品品牌 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateProductBrand(ProductBrandUpdateReqDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 删除商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteProductBrand(Integer productBrandId);
|
||||
|
||||
/**
|
||||
* 获得商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
* @return 商品品牌
|
||||
*/
|
||||
CommonResult<ProductBrandRespDTO> getProductBrand(Integer productBrandId);
|
||||
|
||||
/**
|
||||
* 获得商品品牌列表
|
||||
*
|
||||
* @param productBrandIds 商品品牌编号列表
|
||||
* @return 商品品牌列表
|
||||
*/
|
||||
CommonResult<List<ProductBrandRespDTO>> listProductBrands(List<Integer> productBrandIds);
|
||||
|
||||
/**
|
||||
* 获得商品品牌分页
|
||||
*
|
||||
* @param pageDTO 商品品牌分页查询
|
||||
* @return 商品品牌分页结果
|
||||
*/
|
||||
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(ProductBrandPageReqDTO pageDTO);
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.iocoder.mall.productservice.rpc.brand.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品品牌创建 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandCreateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 品牌名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 品牌描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 品牌名图片
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.mall.product.biz.dto.brand;
|
||||
package cn.iocoder.mall.productservice.rpc.brand.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
|
@ -6,26 +6,20 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 商品品牌分页 DTO
|
||||
*/
|
||||
* 商品品牌分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandPageDTO extends PageParam {
|
||||
public class ProductBrandPageReqDTO extends PageParam {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
* 品牌名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态 1-开启 2-禁用
|
||||
*/
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.mall.product.api.bo;
|
||||
package cn.iocoder.mall.productservice.rpc.brand.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -7,43 +7,30 @@ import java.io.Serializable;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品分类 BO
|
||||
*/
|
||||
* 商品品牌 Response DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductCategoryBO implements Serializable {
|
||||
public class ProductBrandRespDTO 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;
|
||||
/**
|
|
@ -0,0 +1,41 @@
|
|||
package cn.iocoder.mall.productservice.rpc.brand.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品品牌更新 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandUpdateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 品牌编号
|
||||
*/
|
||||
@NotNull(message = "品牌编号不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 品牌名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 品牌描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 品牌名图片
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package cn.iocoder.mall.productservice.convert.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.dal.mysql.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandCreateBO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandPageBO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductBrandConvert {
|
||||
|
||||
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
|
||||
|
||||
ProductBrandDO convert(ProductBrandCreateBO bean);
|
||||
|
||||
ProductBrandBO convert(ProductBrandDO bean);
|
||||
|
||||
ProductBrandDO convert(ProductBrandUpdateBO bean);
|
||||
|
||||
List<ProductBrandBO> convertList(List<ProductBrandDO> list);
|
||||
|
||||
PageResult<ProductBrandBO> convertPage(IPage<ProductBrandDO> page);
|
||||
|
||||
ProductBrandCreateBO convert(ProductBrandCreateReqDTO bean);
|
||||
|
||||
ProductBrandUpdateBO convert(ProductBrandUpdateReqDTO bean);
|
||||
|
||||
ProductBrandRespDTO convert(ProductBrandBO bean);
|
||||
|
||||
List<ProductBrandRespDTO> convertList02(List<ProductBrandBO> list);
|
||||
|
||||
ProductBrandPageBO convert(ProductBrandPageReqDTO bean);
|
||||
|
||||
PageResult<ProductBrandRespDTO> convertPage(PageResult<ProductBrandBO> page);
|
||||
}
|
|
@ -1,42 +1,40 @@
|
|||
package cn.iocoder.mall.product.biz.dataobject.brand;
|
||||
package cn.iocoder.mall.productservice.dal.mysql.dataobject.brand;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Product 品牌
|
||||
*/
|
||||
* 商品品牌
|
||||
*/
|
||||
@TableName("product_brand")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandDO extends DeletableDO {
|
||||
|
||||
/**
|
||||
* 规格编号
|
||||
* 品牌编号(主键)
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 名称
|
||||
* 品牌名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* 品牌描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
* 品牌名图片
|
||||
*/
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* <p>
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.iocoder.mall.productservice.dal.mysql.dataobject.category;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductCategoryDO extends BaseDO {
|
||||
public class ProductCategoryDO extends DeletableDO {
|
||||
|
||||
/**
|
||||
* 分类编号
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package cn.iocoder.mall.productservice.dal.mysql.mapper.brand;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.productservice.dal.mysql.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandPageBO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ProductBrandMapper extends BaseMapper<ProductBrandDO> {
|
||||
|
||||
default IPage<ProductBrandDO> selectPage(ProductBrandPageBO pageBO) {
|
||||
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
|
||||
new QueryWrapperX<ProductBrandDO>().likeIfPresent("name", pageBO.getName())
|
||||
.eqIfPresent("status", pageBO.getStatus()));
|
||||
}
|
||||
|
||||
default ProductBrandDO selectByName(String name) {
|
||||
return selectOne(new QueryWrapper<ProductBrandDO>().eq("name", name));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package cn.iocoder.mall.productservice.manager.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.convert.brand.ProductBrandConvert;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
import cn.iocoder.mall.productservice.service.brand.ProductBrandService;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandBO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品品牌 Manager
|
||||
*/
|
||||
@Service
|
||||
public class ProductBrandManager {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandService productBrandService;
|
||||
|
||||
/**
|
||||
* 创建商品品牌
|
||||
*
|
||||
* @param createDTO 创建商品品牌 DTO
|
||||
* @return 商品品牌
|
||||
*/
|
||||
public Integer createProductBrand(ProductBrandCreateReqDTO createDTO) {
|
||||
ProductBrandBO productBrandBO = productBrandService.createProductBrand(ProductBrandConvert.INSTANCE.convert(createDTO));
|
||||
return productBrandBO.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品品牌
|
||||
*
|
||||
* @param updateDTO 更新商品品牌 DTO
|
||||
*/
|
||||
public void updateProductBrand(ProductBrandUpdateReqDTO updateDTO) {
|
||||
productBrandService.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
*/
|
||||
public void deleteProductBrand(Integer productBrandId) {
|
||||
productBrandService.deleteProductBrand(productBrandId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
* @return 商品品牌
|
||||
*/
|
||||
public ProductBrandRespDTO getProductBrand(Integer productBrandId) {
|
||||
ProductBrandBO productBrandBO = productBrandService.getProductBrand(productBrandId);
|
||||
return ProductBrandConvert.INSTANCE.convert(productBrandBO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌列表
|
||||
*
|
||||
* @param productBrandIds 商品品牌编号列表
|
||||
* @return 商品品牌列表
|
||||
*/
|
||||
public List<ProductBrandRespDTO> listProductBrands(List<Integer> productBrandIds) {
|
||||
List<ProductBrandBO> productBrandBOs = productBrandService.listProductBrands(productBrandIds);
|
||||
return ProductBrandConvert.INSTANCE.convertList02(productBrandBOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌分页
|
||||
*
|
||||
* @param pageDTO 商品品牌分页查询
|
||||
* @return 商品品牌分页结果
|
||||
*/
|
||||
public PageResult<ProductBrandRespDTO> pageProductBrand(ProductBrandPageReqDTO pageDTO) {
|
||||
PageResult<ProductBrandBO> pageResultBO = productBrandService.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageDTO));
|
||||
return ProductBrandConvert.INSTANCE.convertPage(pageResultBO);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package cn.iocoder.mall.productservice.rpc.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 商品品牌 Rpc 实现类
|
||||
*/
|
||||
@Service(version = "${dubbo.provider.ProductBrandRpc.version}")
|
||||
public class ProductBrandRpcImpl implements ProductBrandRpc {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandManager productBrandManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createProductBrand(ProductBrandCreateReqDTO createDTO) {
|
||||
return success(productBrandManager.createProductBrand(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateProductBrand(ProductBrandUpdateReqDTO updateDTO) {
|
||||
productBrandManager.updateProductBrand(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteProductBrand(Integer productBrandId) {
|
||||
productBrandManager.deleteProductBrand(productBrandId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<ProductBrandRespDTO> getProductBrand(Integer productBrandId) {
|
||||
return success(productBrandManager.getProductBrand(productBrandId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<ProductBrandRespDTO>> listProductBrands(List<Integer> productBrandIds) {
|
||||
return success(productBrandManager.listProductBrands(productBrandIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(ProductBrandPageReqDTO pageDTO) {
|
||||
return success(productBrandManager.pageProductBrand(pageDTO));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package cn.iocoder.mall.productservice.service.brand;
|
||||
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.convert.brand.ProductBrandConvert;
|
||||
import cn.iocoder.mall.productservice.dal.mysql.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.mall.productservice.dal.mysql.mapper.brand.ProductBrandMapper;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandCreateBO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandPageBO;
|
||||
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.PRODUCT_BRAND_NAME_EXIST;
|
||||
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.PRODUCT_BRAND_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* 商品品牌 Service
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductBrandService {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandMapper productBrandMapper;
|
||||
|
||||
/**
|
||||
* 创建商品品牌
|
||||
*
|
||||
* @param createBO 创建商品品牌 BO
|
||||
* @return 商品品牌
|
||||
*/
|
||||
public ProductBrandBO createProductBrand(@Valid ProductBrandCreateBO createBO) {
|
||||
// 校验商品品牌的名字是否已经使用
|
||||
if (productBrandMapper.selectByName(createBO.getName()) != null) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NAME_EXIST);
|
||||
}
|
||||
// 插入到数据库
|
||||
ProductBrandDO productBrandDO = ProductBrandConvert.INSTANCE.convert(createBO);
|
||||
productBrandMapper.insert(productBrandDO);
|
||||
// 返回
|
||||
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品品牌
|
||||
*
|
||||
* @param updateBO 更新商品品牌 BO
|
||||
*/
|
||||
public void updateProductBrand(@Valid ProductBrandUpdateBO updateBO) {
|
||||
// 校验更新的商品品牌是否存在
|
||||
if (productBrandMapper.selectById(updateBO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NOT_FOUND);
|
||||
}
|
||||
// 校验商品品牌的名字是否已经使用
|
||||
ProductBrandDO productBrandDOByName = productBrandMapper.selectByName(updateBO.getName());
|
||||
if (productBrandDOByName != null && !updateBO.getId().equals(productBrandDOByName.getId())) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NAME_EXIST);
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductBrandDO updateObject = ProductBrandConvert.INSTANCE.convert(updateBO);
|
||||
productBrandMapper.updateById(updateObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
*/
|
||||
public void deleteProductBrand(Integer productBrandId) {
|
||||
// 校验删除的商品品牌是否存在
|
||||
if (productBrandMapper.selectById(productBrandId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NOT_FOUND);
|
||||
}
|
||||
// TODO 功能点:需要品牌下没有分类
|
||||
// 标记删除
|
||||
productBrandMapper.deleteById(productBrandId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
* @return 商品品牌
|
||||
*/
|
||||
public ProductBrandBO getProductBrand(Integer productBrandId) {
|
||||
ProductBrandDO productBrandDO = productBrandMapper.selectById(productBrandId);
|
||||
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌列表
|
||||
*
|
||||
* @param productBrandIds 商品品牌编号列表
|
||||
* @return 商品品牌列表
|
||||
*/
|
||||
public List<ProductBrandBO> listProductBrands(List<Integer> productBrandIds) {
|
||||
List<ProductBrandDO> productBrandDOs = productBrandMapper.selectBatchIds(productBrandIds);
|
||||
return ProductBrandConvert.INSTANCE.convertList(productBrandDOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品品牌分页
|
||||
*
|
||||
* @param pageBO 商品品牌分页查询
|
||||
* @return 商品品牌分页结果
|
||||
*/
|
||||
public PageResult<ProductBrandBO> pageProductBrand(ProductBrandPageBO pageBO) {
|
||||
IPage<ProductBrandDO> productBrandDOPage = productBrandMapper.selectPage(pageBO);
|
||||
return ProductBrandConvert.INSTANCE.convertPage(productBrandDOPage);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +1,40 @@
|
|||
package cn.iocoder.mall.product.api.bo;
|
||||
package cn.iocoder.mall.productservice.service.brand.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品品牌 VO
|
||||
*/
|
||||
* 商品品牌 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandBO implements Serializable {
|
||||
public class ProductBrandBO {
|
||||
|
||||
/**
|
||||
* 规格编号
|
||||
* 品牌编号(主键)
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 名称
|
||||
* 品牌名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* 品牌描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
* 品牌名图片
|
||||
*/
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cn.iocoder.mall.productservice.service.brand.bo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 商品品牌创建 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandCreateBO {
|
||||
|
||||
/**
|
||||
* 品牌名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 品牌描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 品牌名图片
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package cn.iocoder.mall.productservice.service.brand.bo;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 商品品牌分页 BO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandPageBO extends PageParam {
|
||||
|
||||
/**
|
||||
* 品牌名称
|
||||
*
|
||||
* 模糊匹配
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package cn.iocoder.mall.productservice.service.brand.bo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 商品品牌更新 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandUpdateBO {
|
||||
|
||||
/**
|
||||
* 品牌编号(主键)
|
||||
*/
|
||||
@NotNull(message = "品牌编号(主键)不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 品牌名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 品牌描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 品牌名图片
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package cn.iocoder.mall.productservice.service.category.bo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
@ -40,6 +42,7 @@ public class ProductCategoryCreateBO {
|
|||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cn.iocoder.mall.productservice.service.category.bo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
@ -45,6 +47,7 @@ public class ProductCategoryUpdateBO {
|
|||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ dubbo:
|
|||
validation: true # 开启 Provider 参数校验
|
||||
ProductCategoryRpc:
|
||||
version: 1.0.0
|
||||
ProductBrandRpc:
|
||||
verion: 1.0.0
|
||||
# Dubbo 服务消费者的配置
|
||||
consumer:
|
||||
ErrorCodeRpc:
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package cn.iocoder.mall.product.biz.convert.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.biz.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductBrandConvert {
|
||||
|
||||
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<ProductBrandBO> convertPage(IPage<ProductBrandDO> bean);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductBrandBO> convert(List<ProductBrandDO> brands);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandBO convert(ProductBrandDO brand);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandDO convert(ProductBrandUpdateDTO brand);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandDO convert(ProductBrandAddDTO brand);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.mall.product.biz.dao.brand;
|
||||
|
||||
import cn.iocoder.mall.product.biz.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ProductBrandMapper extends BaseMapper<ProductBrandDO> {
|
||||
|
||||
default IPage<ProductBrandDO> selectPageByParams(ProductBrandPageDTO productBrandPageDTO) {
|
||||
Page<ProductBrandDO> page = new Page<>(productBrandPageDTO.getPageNo(), productBrandPageDTO.getPageSize());
|
||||
LambdaQueryWrapper<ProductBrandDO> queryWrapper = Wrappers.<ProductBrandDO>query().lambda()
|
||||
.like(StringUtils.isNotBlank(productBrandPageDTO.getName()), ProductBrandDO::getName, productBrandPageDTO.getName())
|
||||
.like(StringUtils.isNotBlank(productBrandPageDTO.getDescription()), ProductBrandDO::getName, productBrandPageDTO.getDescription())
|
||||
.eq(null != productBrandPageDTO.getStatus(), ProductBrandDO::getName, productBrandPageDTO.getStatus())
|
||||
.eq(ProductBrandDO::getDeleted, false);
|
||||
return selectPage(page, queryWrapper);
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package cn.iocoder.mall.product.biz.dto.brand;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 品牌添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandAddDTO {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@NotEmpty(message = "品牌描述不能为空")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
@NotEmpty(message = "品牌图片地址不能为空")
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
@NotNull(message = "品牌状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package cn.iocoder.mall.product.biz.dto.brand;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 品牌添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandUpdateDTO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "品牌主键不能为空")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@NotEmpty(message = "品牌描述不能为空")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
@NotEmpty(message = "品牌图片地址不能为空")
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
@NotNull(message = "品牌状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package cn.iocoder.mall.product.biz.service.brand;
|
||||
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
|
||||
|
||||
public interface ProductBrandService {
|
||||
|
||||
/**
|
||||
* 获取品牌分页数据
|
||||
*
|
||||
* @param productBrandPageDTO 翻页参数
|
||||
* @return
|
||||
*/
|
||||
PageResult<ProductBrandBO> getProductBrandPage(ProductBrandPageDTO productBrandPageDTO);
|
||||
|
||||
/**
|
||||
* 获取品牌明细
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
ProductBrandBO getProductBrand(Integer id);
|
||||
|
||||
/**
|
||||
* 添加品牌
|
||||
*
|
||||
* @param productBrandAddDTO 添加参数
|
||||
* @return
|
||||
*/
|
||||
ProductBrandBO addProductBrand(Integer adminId, ProductBrandAddDTO productBrandAddDTO);
|
||||
|
||||
/**
|
||||
* 更新品牌
|
||||
*
|
||||
* @param productBrandUpdateDTO 更新参数
|
||||
* @return
|
||||
*/
|
||||
Boolean updateProductBrand(Integer adminId, ProductBrandUpdateDTO productBrandUpdateDTO);
|
||||
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package cn.iocoder.mall.product.biz.service.brand;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.mybatis.core.enums.DeletedStatusEnum;
|
||||
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.biz.convert.brand.ProductBrandConvert;
|
||||
import cn.iocoder.mall.product.biz.dao.brand.ProductBrandMapper;
|
||||
import cn.iocoder.mall.product.biz.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
|
||||
import cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品规格 Service 实现类
|
||||
*
|
||||
* @see ProductBrandDO
|
||||
*/
|
||||
@Service
|
||||
public class ProductBrandServiceImpl implements ProductBrandService {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandMapper productBrandMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<ProductBrandBO> getProductBrandPage(ProductBrandPageDTO productBrandPageDTO) {
|
||||
IPage<ProductBrandDO> brandPage = productBrandMapper.selectPageByParams(productBrandPageDTO);
|
||||
return ProductBrandConvert.INSTANCE.convertPage(brandPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductBrandBO getProductBrand(Integer brandId) {
|
||||
return ProductBrandConvert.INSTANCE.convert(productBrandMapper.selectById(brandId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductBrandBO addProductBrand(Integer adminId, ProductBrandAddDTO productBrandAddDTO) {
|
||||
// 校验品牌名不重复
|
||||
int count = productBrandMapper.selectCount(Wrappers.<ProductBrandDO>query().lambda()
|
||||
.eq(ProductBrandDO::getName, productBrandAddDTO.getName())
|
||||
.eq(ProductBrandDO::getDeleted, false));
|
||||
if (count > 0) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_BRAND_EXIST.getCode());
|
||||
}
|
||||
ProductBrandDO productBrandDO = ProductBrandConvert.INSTANCE.convert(productBrandAddDTO);
|
||||
productBrandDO.setCreateTime(new Date());
|
||||
productBrandDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
|
||||
productBrandMapper.insert(productBrandDO);
|
||||
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateProductBrand(Integer adminId, ProductBrandUpdateDTO productBrandUpdateDTO) {
|
||||
ProductBrandDO productBrandDO = ProductBrandConvert.INSTANCE.convert(productBrandUpdateDTO);
|
||||
productBrandDO.setUpdateTime(new Date());
|
||||
productBrandMapper.updateById(productBrandDO);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package cn.iocoder.mall.product.rest.controller.category;
|
||||
|
||||
import cn.iocoder.common.framework.enums.MallConstants;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
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 cn.iocoder.mall.product.biz.enums.category.ProductCategoryNodeEnum;
|
||||
import cn.iocoder.mall.product.biz.service.category.ProductCategoryService;
|
||||
import cn.iocoder.mall.product.rest.convert.category.AdminsProductCategoryConvert;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author: jiangweifan
|
||||
* @Date: 2020/5/6
|
||||
* @Description: 商品分类 - API
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/category")
|
||||
@Api(tags = "管理员 - 商品分类 API")
|
||||
public class AdminsProductCategoryController {
|
||||
|
||||
@Autowired
|
||||
private ProductCategoryService productCategoryService;
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation("获取分类树结构")
|
||||
public CommonResult<List<AdminsProductCategoryTreeNodeResponse>> tree() {
|
||||
List<ProductCategoryBO> productCategories = productCategoryService.getAllProductCategory();
|
||||
// 创建 ProductCategoryTreeNodeVO Map
|
||||
Map<Integer, AdminsProductCategoryTreeNodeResponse> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, AdminsProductCategoryConvert.INSTANCE::convertToTreeNodeResponse));
|
||||
// 处理父子关系
|
||||
treeNodeMap.values().stream()
|
||||
.filter(node -> !node.getPid().equals(ProductCategoryNodeEnum.ROOT.getId()))
|
||||
.forEach((childNode) -> {
|
||||
// 获得父节点
|
||||
AdminsProductCategoryTreeNodeResponse parentNode = treeNodeMap.get(childNode.getPid());
|
||||
if (parentNode.getChildren() == null) { // 初始化 children 数组
|
||||
parentNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
// 将自己添加到父节点中
|
||||
parentNode.getChildren().add(childNode);
|
||||
});
|
||||
// 获得到所有的根节点
|
||||
List<AdminsProductCategoryTreeNodeResponse> rootNodes = treeNodeMap.values().stream()
|
||||
.filter(node -> node.getPid().equals(ProductCategoryNodeEnum.ROOT.getId()))
|
||||
.sorted(Comparator.comparing(AdminsProductCategoryTreeNodeResponse::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return success(rootNodes);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建商品分类")
|
||||
public CommonResult<AdminsProductCategoryAddResponse> add(AdminsProductCategoryAddRequest adminsProductCategoryAddRequest) {
|
||||
// 转换 ProductCategoryAddDTO 对象
|
||||
ProductCategoryAddDTO productCategoryAddDTO = AdminsProductCategoryConvert.INSTANCE.convertToAddDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryAddRequest);
|
||||
// 创建商品分类
|
||||
ProductCategoryBO addProductCategoryBO = productCategoryService.addProductCategory(productCategoryAddDTO);
|
||||
// 返回结果
|
||||
return success(AdminsProductCategoryConvert.INSTANCE.convertToAddResponse(addProductCategoryBO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新商品分类")
|
||||
public CommonResult<Boolean> update(AdminsProductCategoryUpdateRequest adminsProductCategoryUpdateRequest) {
|
||||
// 创建 ProductCategoryUpdateDTO 对象
|
||||
ProductCategoryUpdateDTO productCategoryUpdateDTO = AdminsProductCategoryConvert.INSTANCE.convertToUpdateDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryUpdateRequest);
|
||||
// 更新商品分类
|
||||
return success(productCategoryService.updateProductCategory(productCategoryUpdateDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@ApiOperation(value = "更新商品分类状态")
|
||||
public CommonResult<Boolean> updateStatus(AdminsProductCategoryUpdateStatusRequest adminsProductCategoryUpdateStatusRequest) {
|
||||
// 创建 ProductCategoryUpdateStatusDTO 对象
|
||||
ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO = AdminsProductCategoryConvert.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 = AdminsProductCategoryConvert.INSTANCE.convertToDeleteDTO(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
// 删除商品分类
|
||||
return success(productCategoryService.deleteProductCategory(productCategoryDeleteDTO));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cn.iocoder.mall.product.rest.request.brand;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("商品 - 品牌模块 - 商品品牌新增 Request")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandAddRequest {
|
||||
|
||||
@ApiModelProperty(name = "name", value = "品牌名称", required = true, example = "安踏")
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@ApiModelProperty(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
private Integer status;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package cn.iocoder.mall.product.rest.request.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("商品 - 品牌模块 - 品牌分页 Request")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandPageRequest extends PageParam {
|
||||
|
||||
@ApiModelProperty(name = "name", value = "品牌名称", required = true, example = "安踏")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "name", value = "品牌描述", required = true, example = "安踏拖鞋")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(name = "name", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
private String status;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package cn.iocoder.mall.product.rest.request.brand;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品 - 品牌模块 - 商品品牌更新 Request")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandUpdateRequest {
|
||||
|
||||
@ApiModelProperty(name = "id", value = "规格编号", required = true, example = "1")
|
||||
@NotNull(message = "品牌编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(name = "name", value = "品牌名称", required = true, example = "安踏")
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@ApiModelProperty(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
private Integer status;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package cn.iocoder.mall.product.rest.response.category;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: jiangweifan
|
||||
* @Date: 2020/5/6
|
||||
* @Description: 管理员 - 商品分类 - 新增商品分类Response
|
||||
*/
|
||||
@ApiModel("创建商品分类Response")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
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;
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package cn.iocoder.mall.product.rest.response.category;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: jiangweifan
|
||||
* @Date: 2020/5/6
|
||||
* @Description: 管理员 - 商品分类 - 分类树Response
|
||||
*/
|
||||
@ApiModel("商品分类树节点")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
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;
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
# 服务器的配置项
|
||||
server:
|
||||
port: 18081
|
||||
servlet:
|
||||
context-path: /product-api/
|
||||
|
||||
# Swagger 配置项
|
||||
swagger:
|
||||
title: 商品子系统
|
||||
description: 商品子系统
|
||||
version: 1.0.0
|
||||
base-package: cn.iocoder.mall.system.rest.controller
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* 提供 system 服务的 RPC 接口的定义,提供内部调用
|
||||
*/
|
||||
package cn.iocoder.mall.product.rpc;
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* 提供 product 服务的 RPC 接口的实现,提供内部调用
|
||||
*/
|
||||
package cn.iocoder.mall.product.rpc;
|
|
@ -1,14 +0,0 @@
|
|||
spring:
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
namespace: local # Nacos 命名空间
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
|
@ -1,14 +0,0 @@
|
|||
spring:
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
namespace: test # Nacos 命名空间
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
|
@ -1,22 +0,0 @@
|
|||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Spring Cloud Alibaba Dubbo 专属配置
|
||||
cloud:
|
||||
subscribed-services: 'product-application' # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||
# Dubbo 提供者的协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
# Dubbo 提供服务的扫描基础包
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.product.rpc.rpc
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
filter: -exception
|
||||
ProductSpuService:
|
||||
version: 1.0.0
|
||||
|
||||
# Dubbo 服务消费者的配置
|
||||
consumer:
|
||||
ProductSpuService:
|
||||
version: 1.0.0
|
|
@ -1,40 +0,0 @@
|
|||
package cn.iocoder.mall.product.api;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrangPageBO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandUpdateDTO;
|
||||
|
||||
public interface ProductBrandService {
|
||||
|
||||
/**
|
||||
* 获取品牌分页数据
|
||||
* @param productBrandPageDTO 翻页参数
|
||||
* @return
|
||||
*/
|
||||
ProductBrangPageBO getProductBrandPage(ProductBrandPageDTO productBrandPageDTO);
|
||||
|
||||
/**
|
||||
* 获取品牌明细
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
ProductBrandBO getProductBrand(Integer id);
|
||||
|
||||
/**
|
||||
* 添加品牌
|
||||
* @param productBrandAddDTO 添加参数
|
||||
* @return
|
||||
*/
|
||||
ProductBrandBO addProductBrand(Integer adminId, ProductBrandAddDTO productBrandAddDTO);
|
||||
|
||||
/**
|
||||
* 更新品牌
|
||||
* @param productBrandUpdateDTO 更新参数
|
||||
* @return
|
||||
*/
|
||||
Boolean updateProductBrand(Integer adminId, ProductBrandUpdateDTO productBrandUpdateDTO);
|
||||
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package cn.iocoder.mall.product.api;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductCategoryAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductCategoryUpdateDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProductCategoryService {
|
||||
|
||||
/**
|
||||
* @param pid 指定父分类编号
|
||||
* @return 返回指定分类编号的子产品分类们
|
||||
*/
|
||||
List<ProductCategoryBO> getListByPid(Integer pid);
|
||||
|
||||
/**
|
||||
* 获得商品分类数组
|
||||
*
|
||||
* @param ids 商品分类编号
|
||||
* @return 数组
|
||||
*/
|
||||
List<ProductCategoryBO> getListByIds(Collection<Integer> ids);
|
||||
|
||||
/**
|
||||
* @return 返回所有产品分类们
|
||||
*/
|
||||
List<ProductCategoryBO> getAll();
|
||||
|
||||
ProductCategoryBO addProductCategory(Integer adminId, ProductCategoryAddDTO productCategoryAddDTO);
|
||||
|
||||
Boolean updateProductCategory(Integer adminId, ProductCategoryUpdateDTO productCategoryUpdateDTO);
|
||||
|
||||
Boolean updateProductCategoryStatus(Integer adminId, Integer productCategoryId,
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status);
|
||||
|
||||
Boolean deleteProductCategory(Integer admin, Integer productCategoryId);
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品品牌分页 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrangPageBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 品牌数组
|
||||
*/
|
||||
private List<ProductBrandBO> brands;
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
private Integer count;
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.constant;
|
||||
|
||||
public class ProductAttrConstants {
|
||||
|
||||
/**
|
||||
* ATTR 状态 - 开启
|
||||
*/
|
||||
public static final Integer ATTR_STATUS_ENABLE = 1;
|
||||
/**
|
||||
* ATTR 状态 - 关闭
|
||||
*/
|
||||
public static final Integer ATTR_STATUS_DISABLE = 2;
|
||||
|
||||
/**
|
||||
* ATTR_VALUE 状态 - 开启
|
||||
*/
|
||||
public static final Integer ATTR_VALUE_STATUS_ENABLE = 1;
|
||||
/**
|
||||
* ATTR_VALUE 状态 - 关闭
|
||||
*/
|
||||
public static final Integer ATTR_VALUE_STATUS_DISABLE = 2;
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.constant;
|
||||
|
||||
public class ProductCategoryConstants {
|
||||
|
||||
/**
|
||||
* 状态 - 开启
|
||||
*/
|
||||
public static final Integer STATUS_ENABLE = 1;
|
||||
/**
|
||||
* 状态 - 关闭
|
||||
*/
|
||||
public static final Integer STATUS_DISABLE = 2;
|
||||
|
||||
/**
|
||||
* 父分类编号 - 根节点
|
||||
*/
|
||||
public static final Integer PID_ROOT = 0;
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.constant;
|
||||
|
||||
/**
|
||||
* 错误码枚举类
|
||||
*
|
||||
* 商品系统,使用 1-003-000-000 段
|
||||
*/
|
||||
public enum ProductErrorCodeEnum {
|
||||
|
||||
// ========== PRODUCT CATEGORY 模块 ==========
|
||||
PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"),
|
||||
PRODUCT_CATEGORY_NOT_EXISTS(1003001001, "商品分类不存在"),
|
||||
PRODUCT_CATEGORY_PARENT_NOT_SELF(1003001002, "不能设置自己为父分类"),
|
||||
PRODUCT_CATEGORY_STATUS_EQUALS(1002001003, "商品分类已经是该状态"),
|
||||
PRODUCT_CATEGORY_DELETE_ONLY_DISABLE(1002001004, "只有关闭的商品分类才可以删除"),
|
||||
PRODUCT_CATEGORY_MUST_ENABLE(1002001005, "只有开启的商品分类,才可以使用"),
|
||||
PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2(1002001005, "父分类必须是一级分类"),
|
||||
|
||||
// ========== PRODUCT SPU + SKU 模块 ==========
|
||||
PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE(1003002000, "一个 Sku 下,不能有重复的规格"),
|
||||
PRODUCT_SPU_ATTR_NUMBERS_MUST_BE_EQUALS(1003002001, "一个 Spu 下的每个 Sku ,其规格数必须一致"),
|
||||
PRODUCT_SPU_SKU__NOT_DUPLICATE(1003002002, "一个 Spu 下的每个 Sku ,必须不重复"),
|
||||
PRODUCT_SPU_NOT_EXISTS(1003002003, "Spu 不存在"),
|
||||
PRODUCT_SPU_CATEGORY_MUST_BE_LEVEL2(1003002003, "Spu 只能添加在二级分类下"),
|
||||
|
||||
// ========== PRODUCT ATTR + ATTR_VALUE 模块 ==========
|
||||
PRODUCT_ATTR_VALUE_NOT_EXIST(1003003000, "商品属性值不存在"),
|
||||
PRODUCT_ATTR_NOT_EXIST(1003003001, "商品属性值不存在"),
|
||||
PRODUCT_ATTR_EXISTS(1003003002, "商品规格已经存在"),
|
||||
PRODUCT_ATTR_STATUS_EQUALS(1003003003, "商品规格已经是该状态"),
|
||||
PRODUCT_ATTR_VALUE_EXISTS(1003003004, "商品规格值已经存在"),
|
||||
PRODUCT_ATTR_VALUE_STATUS_EQUALS(1003003005, "商品规格值已经是该状态"),
|
||||
|
||||
// ========== PRODUCT BRAND模块 ==========
|
||||
PRODUCT_BRAND_EXIST(1003004000, "品牌值已经存在"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
ProductErrorCodeEnum(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.constant;
|
||||
|
||||
public class ProductSpuConstants {
|
||||
|
||||
/**
|
||||
* 状态 - 开启
|
||||
*/
|
||||
public static final Integer SKU_STATUS_ENABLE = 1;
|
||||
/**
|
||||
* 状态 - 关闭
|
||||
*/
|
||||
public static final Integer SKU_STATUS_DISABLE = 2;
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 品牌添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandAddDTO {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@NotEmpty(message = "品牌描述不能为空")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
@NotEmpty(message = "品牌图片地址不能为空")
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
@NotNull(message = "品牌状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 商品品牌分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandPageDTO {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态 1-开启 2-禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 品牌添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandUpdateDTO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "品牌主键不能为空")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "品牌名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@NotEmpty(message = "品牌描述不能为空")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
@NotEmpty(message = "品牌图片地址不能为空")
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
@NotNull(message = "品牌状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 商品分类添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductCategoryAddDTO {
|
||||
|
||||
/**
|
||||
* 父分类编号
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 商品分类更新 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductCategoryUpdateDTO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package cn.iocoder.mall.product.config;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("cn.iocoder.mall.product.dao") // 扫描对应的 Mapper 接口
|
||||
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
|
||||
public class DatabaseConfiguration {
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.product.config;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
@Configuration
|
||||
public class ServiceExceptionConfiguration {
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class) // 可参考 https://www.cnblogs.com/ssslinppp/p/7607509.html
|
||||
public void initMessages() {
|
||||
// 从 service_exception_message.properties 加载错误码的方案
|
||||
// Properties properties;
|
||||
// try {
|
||||
// properties = PropertiesLoaderUtils.loadAllProperties("classpath:service_exception_message.properties");
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
for (ProductErrorCodeEnum item : ProductErrorCodeEnum.values()) {
|
||||
ServiceExceptionUtil.put(item.getCode(), item.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package cn.iocoder.mall.product.convert;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandUpdateDTO;
|
||||
import cn.iocoder.mall.product.dataobject.ProductBrandDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductBrandConvert {
|
||||
|
||||
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductBrandBO> convert(List<ProductBrandDO> brands);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandBO convert(ProductBrandDO brand);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandDO convert(ProductBrandUpdateDTO brand);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandDO convert(ProductBrandAddDTO brand);
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package cn.iocoder.mall.product.convert;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductCategoryAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductCategoryUpdateDTO;
|
||||
import cn.iocoder.mall.product.dataobject.ProductCategoryDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductCategoryConvert {
|
||||
|
||||
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
ProductCategoryBO convertToBO(ProductCategoryDO category);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductCategoryBO> convertToBO(List<ProductCategoryDO> categoryList);
|
||||
|
||||
@Mappings({})
|
||||
ProductCategoryDO convert(ProductCategoryAddDTO productCategoryAddDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductCategoryDO convert(ProductCategoryUpdateDTO productCategoryUpdateDTO);
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductBrandDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductBrandMapper {
|
||||
|
||||
/**
|
||||
* 根据 id 获取数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ProductBrandDO selectById(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 根据 name 获取数据
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
ProductBrandDO selectByName(@Param("name") String name);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param name 名称
|
||||
* @param description 描述
|
||||
* @param status 状态 1开启 2禁用
|
||||
* @param offset 偏移量
|
||||
* @param limit 数量
|
||||
* @return
|
||||
*/
|
||||
List<ProductBrandDO> selectListByParams(@Param("name") String name,
|
||||
@Param("description") String description,
|
||||
@Param("status") Integer status,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 分页数量统计
|
||||
* @param name 名称
|
||||
* @param description 描述
|
||||
* @param status 状态 1开启 2禁用
|
||||
* @return
|
||||
*/
|
||||
Integer selectListCountByParams(@Param("name") String name,
|
||||
@Param("description") String description,
|
||||
@Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
* @param productBrandDO
|
||||
*/
|
||||
void insert(ProductBrandDO productBrandDO);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param productBrandDO
|
||||
*/
|
||||
void update(ProductBrandDO productBrandDO);
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductCategoryDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductCategoryMapper {
|
||||
|
||||
List<ProductCategoryDO> selectListByPidAndStatusOrderBySort(@Param("pid") Integer pid,
|
||||
@Param("status") Integer status);
|
||||
|
||||
List<ProductCategoryDO> selectList();
|
||||
|
||||
ProductCategoryDO selectById(@Param("id") Integer id);
|
||||
|
||||
List<ProductCategoryDO> selectByIds(@Param("ids") Collection<Integer> ids);
|
||||
|
||||
void insert(ProductCategoryDO productCategoryDO);
|
||||
|
||||
int update(ProductCategoryDO productCategoryDO);
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package cn.iocoder.mall.product.dataobject;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Product 品牌
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductBrandDO extends DeletableDO {
|
||||
|
||||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-开启
|
||||
* 2-禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package cn.iocoder.mall.product.dataobject;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductCategoryDO extends DeletableDO {
|
||||
|
||||
/**
|
||||
* 分类编号
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package cn.iocoder.mall.product.service;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.product.api.ProductBrandService;
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrangPageBO;
|
||||
import cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandUpdateDTO;
|
||||
import cn.iocoder.mall.product.convert.ProductBrandConvert;
|
||||
import cn.iocoder.mall.product.dao.ProductBrandMapper;
|
||||
import cn.iocoder.mall.product.dataobject.ProductBrandDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 商品规格 Service 实现类
|
||||
*
|
||||
* @see ProductBrandDO
|
||||
*/
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.ProductBrandService.version}")
|
||||
public class ProductBrandServiceImpl implements ProductBrandService {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandMapper productBrandMapper;
|
||||
|
||||
/**
|
||||
* 获取品牌分页数据
|
||||
* @param productBrandPageDTO 分页参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProductBrangPageBO getProductBrandPage(ProductBrandPageDTO productBrandPageDTO) {
|
||||
ProductBrangPageBO productBrangPageBO = new ProductBrangPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (productBrandPageDTO.getPageNo() - 1) * productBrandPageDTO.getPageSize();
|
||||
productBrangPageBO.setBrands(
|
||||
ProductBrandConvert.INSTANCE.convert(
|
||||
productBrandMapper.selectListByParams(productBrandPageDTO.getName(),
|
||||
productBrandPageDTO.getDescription(),
|
||||
productBrandPageDTO.getStatus(),
|
||||
offset, productBrandPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
productBrangPageBO.setCount(productBrandMapper.selectListCountByParams(productBrandPageDTO.getName(),
|
||||
productBrandPageDTO.getDescription(),
|
||||
productBrandPageDTO.getStatus()));
|
||||
return productBrangPageBO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品牌明细
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProductBrandBO getProductBrand(Integer id) {
|
||||
ProductBrandBO productBrandBO = new ProductBrandBO();
|
||||
productBrandBO = ProductBrandConvert.INSTANCE.convert(productBrandMapper.selectById(id));
|
||||
return productBrandBO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加品牌
|
||||
* @param adminId
|
||||
* @param productBrandAddDTO 添加参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProductBrandBO addProductBrand(Integer adminId, ProductBrandAddDTO productBrandAddDTO) {
|
||||
// 校验品牌名不重复
|
||||
if (productBrandMapper.selectByName(productBrandAddDTO.getName()) != null) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_BRAND_EXIST.getCode());
|
||||
}
|
||||
ProductBrandDO productBrandDO = new ProductBrandDO();
|
||||
productBrandDO = ProductBrandConvert.INSTANCE.convert(productBrandAddDTO);
|
||||
productBrandMapper.insert(productBrandDO);
|
||||
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新品牌
|
||||
* @param adminId
|
||||
* @param productBrandUpdateDTO 更新参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateProductBrand(Integer adminId, ProductBrandUpdateDTO productBrandUpdateDTO) {
|
||||
ProductBrandDO productBrandDO = new ProductBrandDO();
|
||||
productBrandDO = ProductBrandConvert.INSTANCE.convert(productBrandUpdateDTO);
|
||||
productBrandMapper.update(productBrandDO);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.iocoder.mall.product.dao.ProductBrandMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, name, description, pic_url, status, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductBrandDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_brand
|
||||
WHERE id = #{id}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByName" parameterType="String" resultType="ProductBrandDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_brand
|
||||
WHERE name = #{name}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insert" parameterType="ProductBrandDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_brand (
|
||||
name, description, pic_url, status, create_time, deleted
|
||||
) VALUES (
|
||||
#{name}, #{description}, #{picUrl}, #{status}, #{createTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="ProductBrandDO">
|
||||
UPDATE product_brand
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description},
|
||||
</if>
|
||||
<if test="picUrl != null">
|
||||
pic_url = #{picUrl},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<select id="selectListByParams" resultType="ProductBrandDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_brand
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="name != null">
|
||||
AND name LIKE "%"#{name}"%"
|
||||
</if>
|
||||
<if test="description != null">
|
||||
AND description LIKE "%"#{description}"%"
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectListCountByParams" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM product_brand
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="name != null">
|
||||
AND name LIKE "%"#{name}"%"
|
||||
</if>
|
||||
<if test="description != null">
|
||||
AND description LIKE "%"#{description}"%"
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.iocoder.mall.product.dao.ProductCategoryMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, pid, name, description, pic_url,
|
||||
sort, status, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectListByPidAndStatusOrderBySort" resultType="ProductCategoryDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_category
|
||||
WHERE pid = #{pid}
|
||||
AND status = #{status}
|
||||
AND deleted = 0
|
||||
ORDER BY sort ASC
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultType="ProductCategoryDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_category
|
||||
WHERE deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductCategoryDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_category
|
||||
WHERE id = #{id}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="ProductCategoryDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_category
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ProductCategoryDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_category (
|
||||
pid, name, description, pic_url, sort,
|
||||
status, create_time, deleted
|
||||
) VALUES (
|
||||
#{pid}, #{name}, #{description}, #{picUrl}, #{sort},
|
||||
#{status}, #{createTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="ProductCategoryDO">
|
||||
UPDATE product_category
|
||||
<set>
|
||||
<if test="pid != null">
|
||||
pid = #{pid},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description},
|
||||
</if>
|
||||
<if test="picUrl != null">
|
||||
pic_url = #{picUrl},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.product.application;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.config.ConfigFileApplicationListener;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.product"})
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
public class ProductApplication {
|
||||
|
||||
/**
|
||||
* 设置需要读取的配置文件的名字。
|
||||
* 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY} 实现。
|
||||
*/
|
||||
private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application";
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 设置环境变量
|
||||
System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE);
|
||||
|
||||
// 启动 Spring Boot 应用
|
||||
SpringApplication.run(ProductApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.product.api.ProductBrandService;
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrangPageBO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductBrandUpdateDTO;
|
||||
import cn.iocoder.mall.product.application.convert.ProductBrandConvert;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrandVO;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrangPageVO;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/brand")
|
||||
@Api("商品品牌")
|
||||
public class AdminsProductBrandController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.provider.ProductBrandService.version}")
|
||||
private ProductBrandService productBrandService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("创建品牌")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
|
||||
@ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
})
|
||||
public CommonResult<AdminsProductBrandVO> add(@RequestParam("name") String name,
|
||||
@RequestParam("description") String description,
|
||||
@RequestParam("picUrl") String picUrl,
|
||||
@RequestParam("status") Integer status) {
|
||||
// 创建 ProductBrandAddDTO 对象
|
||||
ProductBrandAddDTO productBrandAddDTO = new ProductBrandAddDTO().setName(name).setDescription(description)
|
||||
.setPicUrl(picUrl).setStatus(status);
|
||||
// 保存商品
|
||||
ProductBrandBO result = productBrandService.addProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandAddDTO);
|
||||
// 返回结果
|
||||
return success(ProductBrandConvert.INSTANCE.convert(result));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新商品")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
|
||||
@ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("description") String description,
|
||||
@RequestParam("picUrl") String picUrl,
|
||||
@RequestParam("status") Integer status) {
|
||||
// 创建 productBrandUpdateDTO 对象
|
||||
ProductBrandUpdateDTO productBrandUpdateDTO = new ProductBrandUpdateDTO().setId(id).setName(name).setDescription(description)
|
||||
.setPicUrl(picUrl).setStatus(status);
|
||||
// 更新商品
|
||||
productBrandService.updateProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandUpdateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获取品牌")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1")
|
||||
})
|
||||
public CommonResult<AdminsProductBrandVO> add(@RequestParam("id") Integer id) {
|
||||
// 保存商品
|
||||
ProductBrandBO result = productBrandService.getProductBrand(id);
|
||||
// 返回结果
|
||||
return success(ProductBrandConvert.INSTANCE.convert(result));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得品牌分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
|
||||
@ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, example = "10")
|
||||
})
|
||||
public CommonResult<AdminsProductBrangPageVO> attrPage(@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "description", required = false) String description,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
// 创建 ProductAttrPageDTO 对象
|
||||
ProductBrandPageDTO productBrandPageDTO = new ProductBrandPageDTO().setName(name)
|
||||
.setDescription(description)
|
||||
.setStatus(status)
|
||||
.setPageNo(pageNo)
|
||||
.setPageSize(pageSize);
|
||||
// 查询分页
|
||||
ProductBrangPageBO result = productBrandService.getProductBrandPage(productBrandPageDTO);
|
||||
// 返回结果
|
||||
return success(ProductBrandConvert.INSTANCE.convert(result));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.product.api.ProductCategoryService;
|
||||
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
|
||||
import cn.iocoder.mall.product.api.constant.ProductCategoryConstants;
|
||||
import cn.iocoder.mall.product.api.dto.ProductCategoryAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductCategoryUpdateDTO;
|
||||
import cn.iocoder.mall.product.application.convert.ProductCategoryConvert;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryTreeNodeVO;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryVO;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/category")
|
||||
@Api("商品分类")
|
||||
public class AdminsProductCategoryController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.provider.ProductCategoryService.version}")
|
||||
private ProductCategoryService productCategoryService;
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation("获得分类树结构")
|
||||
public CommonResult<List<AdminsProductCategoryTreeNodeVO>> tree() {
|
||||
List<ProductCategoryBO> productCategories = productCategoryService.getAll();
|
||||
// 创建 ProductCategoryTreeNodeVO Map
|
||||
Map<Integer, AdminsProductCategoryTreeNodeVO> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, ProductCategoryConvert.Admins.INSTANCE::convert));
|
||||
// 处理父子关系
|
||||
treeNodeMap.values().stream()
|
||||
.filter(node -> !node.getPid().equals(ProductCategoryConstants.PID_ROOT))
|
||||
.forEach((childNode) -> {
|
||||
// 获得父节点
|
||||
AdminsProductCategoryTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid());
|
||||
if (parentNode.getChildren() == null) { // 初始化 children 数组
|
||||
parentNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
// 将自己添加到父节点中
|
||||
parentNode.getChildren().add(childNode);
|
||||
});
|
||||
// 获得到所有的根节点
|
||||
List<AdminsProductCategoryTreeNodeVO> rootNodes = treeNodeMap.values().stream()
|
||||
.filter(node -> node.getPid().equals(ProductCategoryConstants.PID_ROOT))
|
||||
.sorted(Comparator.comparing(AdminsProductCategoryTreeNodeVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return success(rootNodes);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建商品分类")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pid", value = "父级分类编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "name", value = "分类名字(标识)", required = true, example = "admin/info"),
|
||||
@ApiImplicitParam(name = "description", value = "描述", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<AdminsProductCategoryVO> add(@RequestParam("pid") Integer pid,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("description") String description,
|
||||
@RequestParam(value = "picUrl", required = false) String picUrl,
|
||||
@RequestParam("sort") Integer sort) {
|
||||
// 创建 ProductCategoryAddDTO 对象
|
||||
ProductCategoryAddDTO productCategoryAddDTO = new ProductCategoryAddDTO().setPid(pid).setName(name)
|
||||
.setDescription(description).setPicUrl(picUrl).setSort(sort);
|
||||
// 创建商品分类
|
||||
ProductCategoryBO result = productCategoryService.addProductCategory(AdminSecurityContextHolder.getContext().getAdminId(), productCategoryAddDTO);
|
||||
// 返回结果
|
||||
return success(ProductCategoryConvert.Admins.INSTANCE.convert2(result));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新商品分类")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "分类编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "pid", value = "父级分类编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "name", value = "分类名字(标识)", required = true, example = "admin/info"),
|
||||
@ApiImplicitParam(name = "description", value = "描述", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("pid") Integer pid,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("description") String description,
|
||||
@RequestParam(value = "picUrl", required = false) String picUrl,
|
||||
@RequestParam("sort") Integer sort) {
|
||||
// 创建 ProductCategoryUpdateDTO 对象
|
||||
ProductCategoryUpdateDTO productCategoryAddDTO = new ProductCategoryUpdateDTO().setId(id).setPid(pid).setName(name)
|
||||
.setDescription(description).setPicUrl(picUrl).setSort(sort);
|
||||
// 更新商品分类
|
||||
return success(productCategoryService.updateProductCategory(AdminSecurityContextHolder.getContext().getAdminId(), productCategoryAddDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@ApiOperation(value = "更新商品分类状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "商品分类编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return success(productCategoryService.updateProductCategoryStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除商品分类")
|
||||
@ApiImplicitParam(name = "id", value = "商品分类编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return success(productCategoryService.deleteProductCategory(AdminSecurityContextHolder.getContext().getAdminId(), id));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.convert;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.api.bo.ProductBrangPageBO;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrandVO;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrangPageVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface ProductBrandConvert {
|
||||
|
||||
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductBrandVO convert(ProductBrandBO result);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductBrangPageVO convert(ProductBrangPageBO result);
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.convert;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryTreeNodeVO;
|
||||
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryVO;
|
||||
import cn.iocoder.mall.product.application.vo.users.UsersProductCategoryVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProductCategoryConvert {
|
||||
|
||||
@Mapper
|
||||
interface Users {
|
||||
|
||||
Users INSTANCE = Mappers.getMapper(Users.class);
|
||||
|
||||
@Mappings({})
|
||||
UsersProductCategoryVO convertToVO(ProductCategoryBO category);
|
||||
|
||||
@Mappings({})
|
||||
List<UsersProductCategoryVO> convertToVO(List<ProductCategoryBO> categoryList);
|
||||
|
||||
}
|
||||
|
||||
@Mapper
|
||||
interface Admins {
|
||||
|
||||
Admins INSTANCE = Mappers.getMapper(Admins.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductCategoryTreeNodeVO convert(ProductCategoryBO category);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductCategoryVO convert2(ProductCategoryBO result);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 商品品牌 VO
|
||||
*/
|
||||
|
||||
@ApiModel(value = "商品品牌 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductBrandVO {
|
||||
|
||||
/**
|
||||
* 品牌编号
|
||||
*/
|
||||
@ApiModelProperty(value = "品牌编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "名称", required = true, example = "安踏")
|
||||
private String name;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "描述", required = true, example = "安踏拖鞋")
|
||||
private String description;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "图片地址", required = true, example = "http://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@ApiModelProperty(value = "状态 1-开启 2-禁用", required = true, example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品品牌分页 BO
|
||||
*/
|
||||
@ApiModel("商品品牌分页")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductBrangPageVO {
|
||||
|
||||
@ApiModelProperty(value = "品牌数组", required = true)
|
||||
private List<AdminsProductBrandVO> brands;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "总数", required = true)
|
||||
private Integer count;
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("产品分类树节点 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductCategoryTreeNodeVO {
|
||||
|
||||
@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<AdminsProductCategoryTreeNodeVO> children;
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package cn.iocoder.mall.product.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("产品分类 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductCategoryVO {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
swagger:
|
||||
enable: true
|
||||
title: 商品子系统
|
||||
description: 商品子系统
|
||||
version: 1.0.0
|
||||
base-package: cn.iocoder.mall.product.application.controller
|
|
@ -1,34 +0,0 @@
|
|||
spring:
|
||||
application:
|
||||
name: product-application
|
||||
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
# Spring Cloud Sentinel 配置项
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: s1.iocoder.cn:12088 # Sentinel Dashboard 服务地址
|
||||
eager: true # 项目启动时,直接连接到 Sentinel
|
||||
|
||||
# server
|
||||
server:
|
||||
port: 18081
|
||||
servlet:
|
||||
context-path: /product-api/
|
||||
|
||||
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info,env,metrics,prometheus
|
||||
metrics:
|
||||
enabled: true
|
||||
|
||||
swagger:
|
||||
enable: true
|
||||
title: 商品子系统
|
||||
description: 商品子系统
|
||||
version: 1.0.0
|
||||
base-package: cn.iocoder.mall.product.application.controller
|
Loading…
Reference in New Issue