Ver Fonte

【功能优化】添加商品属性时允许选择已有的属性值

rayson há 11 meses atrás
pai
commit
7f88ccd500

+ 11 - 0
citu-module-mall/citu-module-product-biz/src/main/java/com/citu/module/product/controller/admin/property/ProductPropertyController.java

@@ -18,7 +18,10 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 
+import java.util.List;
+
 import static com.citu.framework.common.pojo.CommonResult.success;
+import static com.citu.framework.common.util.collection.CollectionUtils.convertList;
 
 @Tag(name = "管理后台 - 商品属性项")
 @RestController
@@ -70,4 +73,12 @@ public class ProductPropertyController {
         return success(BeanUtils.toBean(pageResult, ProductPropertyRespVO.class));
     }
 
+    @GetMapping("/simple-list")
+    @Operation(summary = "获得属性项精简列表")
+    public CommonResult<List<ProductPropertyRespVO>> getPropertySimpleList() {
+        List<ProductPropertyDO> list = productPropertyService.getPropertyList();
+        return success(convertList(list, property -> new ProductPropertyRespVO() // 只返回 id、name 属性
+                .setId(property.getId()).setName(property.getName())));
+    }
+
 }

+ 13 - 0
citu-module-mall/citu-module-product-biz/src/main/java/com/citu/module/product/controller/admin/property/ProductPropertyValueController.java

@@ -18,7 +18,11 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 
+import java.util.List;
+
 import static com.citu.framework.common.pojo.CommonResult.success;
+import static com.citu.framework.common.util.collection.CollectionUtils.convertList;
+import static com.citu.framework.common.util.collection.CollectionUtils.singleton;
 
 @Tag(name = "管理后台 - 商品属性值")
 @RestController
@@ -70,4 +74,13 @@ public class ProductPropertyValueController {
         return success(BeanUtils.toBean(pageResult, ProductPropertyValueRespVO.class));
     }
 
+    @GetMapping("/simple-list")
+    @Operation(summary = "获得属性值精简列表")
+    @Parameter(name = "propertyId", description = "属性项编号", required = true, example = "1024")
+    public CommonResult<List<ProductPropertyValueRespVO>> getPropertyValueSimpleList(@RequestParam("propertyId") Long propertyId) {
+        List<ProductPropertyValueDO> list = productPropertyValueService.getPropertyValueListByPropertyId(singleton(propertyId));
+        return success(convertList(list, value -> new ProductPropertyValueRespVO() // 只返回 id、name 属性
+                .setId(value.getId()).setName(value.getName())));
+    }
+
 }

+ 0 - 4
citu-module-mall/citu-module-product-biz/src/main/java/com/citu/module/product/dal/dataobject/property/ProductPropertyDO.java

@@ -39,10 +39,6 @@ public class ProductPropertyDO extends BaseDO {
      * 名称
      */
     private String name;
-    /**
-     * 状态
-     */
-    private Integer status;
     /**
      * 备注
      */

+ 7 - 0
citu-module-mall/citu-module-product-biz/src/main/java/com/citu/module/product/service/property/ProductPropertyService.java

@@ -63,4 +63,11 @@ public interface ProductPropertyService {
      */
     List<ProductPropertyDO> getPropertyList(Collection<Long> ids);
 
+    /**
+     * 获得指定状态的属性项列表
+     *
+     * @return 属性项列表
+     */
+    List<ProductPropertyDO> getPropertyList();
+
 }

+ 5 - 0
citu-module-mall/citu-module-product-biz/src/main/java/com/citu/module/product/service/property/ProductPropertyServiceImpl.java

@@ -109,4 +109,9 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
         return productPropertyMapper.selectBatchIds(ids);
     }
 
+    @Override
+    public List<ProductPropertyDO> getPropertyList() {
+        return productPropertyMapper.selectList();
+    }
+
 }

+ 0 - 5
citu-module-system/citu-module-system-biz/pom.xml

@@ -147,11 +147,6 @@
             <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
         </dependency>
 
-        <dependency>
-            <groupId>org.dromara.hutool</groupId>
-            <artifactId>hutool-extra</artifactId> <!-- 邮件 -->
-        </dependency>
-
     </dependencies>
 
     <build>

+ 2 - 1
citu-module-system/citu-module-system-biz/src/test/java/com/citu/module/system/framework/sms/core/client/impl/SmsClientTests.java

@@ -1,5 +1,6 @@
 package com.citu.module.system.framework.sms.core.client.impl;
 
+import cn.hutool.core.collection.ListUtil;
 import com.citu.framework.common.core.KeyValue;
 import com.citu.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO;
 import com.citu.module.system.framework.sms.core.client.dto.SmsSendRespDTO;
@@ -28,7 +29,7 @@ public class SmsClientTests {
         Long sendLogId = System.currentTimeMillis();
         String mobile = "15601691323";
         String apiTemplateId = "xx test01";
-        List<KeyValue<String, Object>> templateParams = List.of(new KeyValue<>("code", "1024"));
+        List<KeyValue<String, Object>> templateParams = ListUtil.of(new KeyValue<>("code", "1024"));
         // 调用
         SmsSendRespDTO smsSendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, templateParams);
         // 打印结果