商品品牌的迁移,准备和前端管理后台对接
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user