forked from YunaiV/yudao-cloud
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YunaiV
committed
Jul 28, 2020
1 parent
7587668
commit 7dbbd41
Showing
32 changed files
with
1,010 additions
and
174 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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.attr.ProductAttrKeyCreateReqVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyPageReqVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyRespVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyUpdateReqVO; | ||
import cn.iocoder.mall.managementweb.manager.product.ProductAttrKeyManager; | ||
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-attr/") | ||
@Api(tags = "商品规格键") | ||
@Validated | ||
public class ProductAttrController { | ||
|
||
@Autowired | ||
private ProductAttrKeyManager productAttrKeyManager; | ||
|
||
@PostMapping("/key/create") | ||
@ApiOperation("创建商品规格键") | ||
public CommonResult<Integer> createProductAttrKey(@Valid ProductAttrKeyCreateReqVO createVO) { | ||
return success(productAttrKeyManager.createProductAttrKey(createVO)); | ||
} | ||
|
||
@PostMapping("/key/update") | ||
@ApiOperation("更新商品规格键") | ||
public CommonResult<Boolean> updateProductAttrKey(@Valid ProductAttrKeyUpdateReqVO updateVO) { | ||
productAttrKeyManager.updateProductAttrKey(updateVO); | ||
return success(true); | ||
} | ||
|
||
@GetMapping("/key/get") | ||
@ApiOperation("获得商品规格键") | ||
@ApiImplicitParam(name = "productAttrKeyId", value = "商品规格键编号", required = true) | ||
public CommonResult<ProductAttrKeyRespVO> getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId) { | ||
return success(productAttrKeyManager.getProductAttrKey(productAttrKeyId)); | ||
} | ||
|
||
@GetMapping("/key/list") | ||
@ApiOperation("获得商品规格键列表") | ||
@ApiImplicitParam(name = "productAttrKeyIds", value = "商品规格键编号列表", required = true) | ||
public CommonResult<List<ProductAttrKeyRespVO>> listProductAttrKeys(@RequestParam("productAttrKeyIds") List<Integer> productAttrKeyIds) { | ||
return success(productAttrKeyManager.listProductAttrKeys(productAttrKeyIds)); | ||
} | ||
|
||
@GetMapping("/key/page") | ||
@ApiOperation("获得商品规格键分页") | ||
public CommonResult<PageResult<ProductAttrKeyRespVO>> pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) { | ||
return success(productAttrKeyManager.pageProductAttrKey(pageVO)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...a/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrKeyCreateReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cn.iocoder.mall.managementweb.controller.product.vo.attr; | ||
|
||
import cn.iocoder.common.framework.enums.CommonStatusEnum; | ||
import cn.iocoder.common.framework.validator.InEnum; | ||
import io.swagger.annotations.ApiModel; | ||
import io.swagger.annotations.ApiModelProperty; | ||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@ApiModel("商品规格键创建 Request VO") | ||
@Data | ||
public class ProductAttrKeyCreateReqVO { | ||
|
||
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸") | ||
@NotEmpty(message = "规格键名称不能为空") | ||
private String name; | ||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") | ||
@NotNull(message = "状态不能为空") | ||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") | ||
private Integer status; | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...ava/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrKeyPageReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cn.iocoder.mall.managementweb.controller.product.vo.attr; | ||
|
||
import cn.iocoder.common.framework.enums.CommonStatusEnum; | ||
import cn.iocoder.common.framework.validator.InEnum; | ||
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 ProductAttrKeyPageReqVO extends PageParam { | ||
|
||
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸", notes = "模糊匹配") | ||
private String name; | ||
@ApiModelProperty(value = "状态", example = "1", notes = "见 CommonStatusEnum 枚举") | ||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") | ||
private Integer status; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...n/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrKeyRespVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cn.iocoder.mall.managementweb.controller.product.vo.attr; | ||
|
||
import lombok.*; | ||
import io.swagger.annotations.*; | ||
import java.util.*; | ||
|
||
@ApiModel("商品规格键 Response VO") | ||
@Data | ||
public class ProductAttrKeyRespVO { | ||
|
||
@ApiModelProperty(value = "规格键编号", required = true, example = "1") | ||
private Integer id; | ||
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸") | ||
private String name; | ||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") | ||
private Integer status; | ||
@ApiModelProperty(value = "创建时间", required = true) | ||
private Date createTime; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...a/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrKeyUpdateReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cn.iocoder.mall.managementweb.controller.product.vo.attr; | ||
|
||
import cn.iocoder.common.framework.enums.CommonStatusEnum; | ||
import cn.iocoder.common.framework.validator.InEnum; | ||
import io.swagger.annotations.ApiModel; | ||
import io.swagger.annotations.ApiModelProperty; | ||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@ApiModel("商品规格键更新 Request VO") | ||
@Data | ||
public class ProductAttrKeyUpdateReqVO { | ||
|
||
@ApiModelProperty(value = "规格键编号", required = true, example = "1") | ||
@NotNull(message = "规格键编号不能为空") | ||
private Integer id; | ||
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸") | ||
@NotEmpty(message = "规格键名称不能为空") | ||
private String name; | ||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") | ||
@NotNull(message = "状态不能为空") | ||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") | ||
private Integer status; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...pp/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrKeyConvert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.attr.ProductAttrKeyCreateReqVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyPageReqVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyRespVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyUpdateReqVO; | ||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyCreateReqDTO; | ||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyPageReqDTO; | ||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyRespDTO; | ||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyUpdateReqDTO; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
import java.util.List; | ||
|
||
@Mapper | ||
public interface ProductAttrKeyConvert { | ||
|
||
ProductAttrKeyConvert INSTANCE = Mappers.getMapper(ProductAttrKeyConvert.class); | ||
|
||
ProductAttrKeyCreateReqDTO convert(ProductAttrKeyCreateReqVO bean); | ||
|
||
ProductAttrKeyUpdateReqDTO convert(ProductAttrKeyUpdateReqVO bean); | ||
|
||
ProductAttrKeyRespVO convert(ProductAttrKeyRespDTO bean); | ||
|
||
List<ProductAttrKeyRespVO> convertList(List<ProductAttrKeyRespDTO> list); | ||
|
||
PageResult<ProductAttrKeyRespVO> convertPage(PageResult<ProductAttrKeyRespDTO> page); | ||
|
||
ProductAttrKeyPageReqDTO convert(ProductAttrKeyPageReqVO bean); | ||
|
||
} |
97 changes: 97 additions & 0 deletions
97
...pp/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
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.attr.ProductAttrKeyCreateReqVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyPageReqVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyRespVO; | ||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyUpdateReqVO; | ||
import cn.iocoder.mall.managementweb.convert.product.ProductAttrKeyConvert; | ||
import cn.iocoder.mall.productservice.rpc.attr.ProductAttrRpc; | ||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyRespDTO; | ||
import org.apache.dubbo.config.annotation.DubboReference; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 商品规格 Manager | ||
*/ | ||
@Service | ||
public class ProductAttrKeyManager { | ||
|
||
@DubboReference(version = "${dubbo.consumer.ProductAttrRpc.version}") | ||
private ProductAttrRpc productAttrKeyRpc; | ||
|
||
/** | ||
* 创建商品规格键 | ||
* | ||
* @param createVO 创建商品规格键 VO | ||
* @return 商品规格键 | ||
*/ | ||
public Integer createProductAttrKey(ProductAttrKeyCreateReqVO createVO) { | ||
CommonResult<Integer> createProductAttrKeyResult = productAttrKeyRpc.createProductAttrKey( | ||
ProductAttrKeyConvert.INSTANCE.convert(createVO)); | ||
createProductAttrKeyResult.checkError(); | ||
return createProductAttrKeyResult.getData(); | ||
} | ||
|
||
/** | ||
* 更新商品规格键 | ||
* | ||
* @param updateVO 更新商品规格键 VO | ||
*/ | ||
public void updateProductAttrKey(ProductAttrKeyUpdateReqVO updateVO) { | ||
CommonResult<Boolean> updateProductAttrKeyResult = productAttrKeyRpc.updateProductAttrKey( | ||
ProductAttrKeyConvert.INSTANCE.convert(updateVO)); | ||
updateProductAttrKeyResult.checkError(); | ||
} | ||
|
||
/** | ||
* 删除商品规格键 | ||
* | ||
* @param productAttrKeyId 商品规格键编号 | ||
*/ | ||
public void deleteProductAttrKey(Integer productAttrKeyId) { | ||
CommonResult<Boolean> deleteProductAttrKeyResult = productAttrKeyRpc.deleteProductAttrKey(productAttrKeyId); | ||
deleteProductAttrKeyResult.checkError(); | ||
} | ||
|
||
/** | ||
* 获得商品规格键 | ||
* | ||
* @param productAttrKeyId 商品规格键编号 | ||
* @return 商品规格键 | ||
*/ | ||
public ProductAttrKeyRespVO getProductAttrKey(Integer productAttrKeyId) { | ||
CommonResult<ProductAttrKeyRespDTO> getProductAttrKeyResult = productAttrKeyRpc.getProductAttrKey(productAttrKeyId); | ||
getProductAttrKeyResult.checkError(); | ||
return ProductAttrKeyConvert.INSTANCE.convert(getProductAttrKeyResult.getData()); | ||
} | ||
|
||
/** | ||
* 获得商品规格键列表 | ||
* | ||
* @param productAttrKeyIds 商品规格键编号列表 | ||
* @return 商品规格键列表 | ||
*/ | ||
public List<ProductAttrKeyRespVO> listProductAttrKeys(List<Integer> productAttrKeyIds) { | ||
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeyResult = productAttrKeyRpc.listProductAttrKeys(productAttrKeyIds); | ||
listProductAttrKeyResult.checkError(); | ||
return ProductAttrKeyConvert.INSTANCE.convertList(listProductAttrKeyResult.getData()); | ||
} | ||
|
||
/** | ||
* 获得商品规格键分页 | ||
* | ||
* @param pageVO 商品规格键分页查询 | ||
* @return 商品规格键分页结果 | ||
*/ | ||
public PageResult<ProductAttrKeyRespVO> pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) { | ||
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKeyResult = productAttrKeyRpc.pageProductAttrKey( | ||
ProductAttrKeyConvert.INSTANCE.convert(pageVO)); | ||
pageProductAttrKeyResult.checkError(); | ||
return ProductAttrKeyConvert.INSTANCE.convertPage(pageProductAttrKeyResult.getData()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.