|
@@ -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());
|