Bläddra i källkod

fix group code

huodongdong 6 år sedan
förälder
incheckning
9637fee49d

+ 16 - 2
rankin-cms-web/src/main/java/cn/rankin/cmsweb/controller/product/GroupController.java

@@ -4,12 +4,15 @@ import cn.rankin.cmsweb.assist.resolver.NeedUser;
 import cn.rankin.cmsweb.entity.UserDetails;
 import cn.rankin.cmsweb.service.product.GroupService;
 import cn.rankin.cmsweb.service.user.MerchantInfoSetService;
+import cn.rankin.cmsweb.service.user.MerchantService;
 import cn.rankin.common.utils.api.model.APIResult;
+import cn.rankin.common.utils.api.model.BaseCode;
 import cn.rankin.common.utils.api.page.Page;
 import cn.rankin.data.api.product.dto.GroupDTO;
 import cn.rankin.common.utils.dto.search.GroupSearchDTO;
 import cn.rankin.common.utils.util.BeanUtil;
 import cn.rankin.data.api.product.vo.GroupVo;
+import cn.rankin.data.api.user.vo.MerchantVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -25,6 +28,9 @@ public class GroupController {
     private GroupService groupService;
 
     @Autowired
+    private MerchantService merchantService;
+
+    @Autowired
     private MerchantInfoSetService<GroupVo> merchantInfoSetService;
 
     @RequestMapping(value = "/list", method = RequestMethod.GET)
@@ -42,8 +48,16 @@ public class GroupController {
     @RequestMapping(method = RequestMethod.POST)
     public APIResult<GroupVo> create(@Valid @RequestBody GroupDTO groupDTO) {
         // 转大写
-        String code = groupDTO.getCode();
-        groupDTO.setCode(code.toUpperCase());
+        String merchantId = groupDTO.getMerchantId();
+        APIResult<MerchantVo> merchantVoAPIResult = merchantService.getMerchant(merchantId);
+        if (merchantVoAPIResult.getSuccess()) {
+            MerchantVo merchantVo = merchantVoAPIResult.getData();
+            String code = groupDTO.getCode() + "_" + merchantVo.getSimple();
+            groupDTO.setCode(code.toUpperCase());
+        }else {
+            return APIResult.error(new BaseCode(merchantVoAPIResult.getCode(), merchantVoAPIResult.getMessage()));
+        }
+
         APIResult<GroupVo> groupVoAPIResult = groupService.create(groupDTO);
         if (groupVoAPIResult.getSuccess()) {
             merchantInfoSetService.setMerchantInfo(groupVoAPIResult.getData());

+ 2 - 2
rankin-common-utils/src/main/java/cn/rankin/common/utils/constant/Constant.java

@@ -4,9 +4,9 @@ public class Constant {
 
     public final static String ROOT_ID = "1";
 
-    public final static String APP_CODE = "1502";
+    public final static String APP_CODE = "1001";
 
-    public final static String BIZ_CODE = "0129";
+    public final static String BIZ_CODE = "1001";
 
     public final static String MRegEx = "^\\d{4}$";
 

+ 1 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/user/entity/Merchant.java

@@ -36,6 +36,7 @@ public class Merchant implements Serializable {
 
     private String name;
 
+    @Column(unique = true, nullable = false)
     private String simple;
 
     @Column(name = "contact_name")