Commit 664abe70626acf5a0e23439f6e900c1803427784
1 parent
6e67120b
【功能优化】添加商品属性时允许选择已有的属性值
Showing
5 changed files
with
36 additions
and
4 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
| ... | ... | @@ -17,7 +17,10 @@ import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | 17 | import org.springframework.validation.annotation.Validated; |
| 18 | 18 | import org.springframework.web.bind.annotation.*; |
| 19 | 19 | |
| 20 | +import java.util.List; | |
| 21 | + | |
| 20 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 21 | 24 | |
| 22 | 25 | @Tag(name = "管理后台 - 商品属性项") |
| 23 | 26 | @RestController |
| ... | ... | @@ -69,4 +72,12 @@ public class ProductPropertyController { |
| 69 | 72 | return success(BeanUtils.toBean(pageResult, ProductPropertyRespVO.class)); |
| 70 | 73 | } |
| 71 | 74 | |
| 75 | + @GetMapping("/simple-list") | |
| 76 | + @Operation(summary = "获得属性项精简列表") | |
| 77 | + public CommonResult<List<ProductPropertyRespVO>> getPropertySimpleList() { | |
| 78 | + List<ProductPropertyDO> list = productPropertyService.getPropertyList(); | |
| 79 | + return success(convertList(list, property -> new ProductPropertyRespVO() // 只返回 id、name 属性 | |
| 80 | + .setId(property.getId()).setName(property.getName()))); | |
| 81 | + } | |
| 82 | + | |
| 72 | 83 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
| ... | ... | @@ -17,7 +17,11 @@ import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | 17 | import org.springframework.validation.annotation.Validated; |
| 18 | 18 | import org.springframework.web.bind.annotation.*; |
| 19 | 19 | |
| 20 | +import java.util.List; | |
| 21 | + | |
| 20 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 24 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.singleton; | |
| 21 | 25 | |
| 22 | 26 | @Tag(name = "管理后台 - 商品属性值") |
| 23 | 27 | @RestController |
| ... | ... | @@ -69,4 +73,13 @@ public class ProductPropertyValueController { |
| 69 | 73 | return success(BeanUtils.toBean(pageResult, ProductPropertyValueRespVO.class)); |
| 70 | 74 | } |
| 71 | 75 | |
| 76 | + @GetMapping("/simple-list") | |
| 77 | + @Operation(summary = "获得属性值精简列表") | |
| 78 | + @Parameter(name = "propertyId", description = "属性项编号", required = true, example = "1024") | |
| 79 | + public CommonResult<List<ProductPropertyValueRespVO>> getPropertyValueSimpleList(@RequestParam("propertyId") Long propertyId) { | |
| 80 | + List<ProductPropertyValueDO> list = productPropertyValueService.getPropertyValueListByPropertyId(singleton(propertyId)); | |
| 81 | + return success(convertList(list, value -> new ProductPropertyValueRespVO() // 只返回 id、name 属性 | |
| 82 | + .setId(value.getId()).setName(value.getName()))); | |
| 83 | + } | |
| 84 | + | |
| 72 | 85 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
| ... | ... | @@ -109,4 +109,9 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { |
| 109 | 109 | return productPropertyMapper.selectBatchIds(ids); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | + @Override | |
| 113 | + public List<ProductPropertyDO> getPropertyList() { | |
| 114 | + return productPropertyMapper.selectList(); | |
| 115 | + } | |
| 116 | + | |
| 112 | 117 | } | ... | ... |