Browse Source

修改相关接口ApplyAgencyCommand为GenerateAgencyCommand

xuexiaobo 6 years ago
parent
commit
bbcaf9641d

+ 3 - 0
site/src/main/java/com/mooctest/crowd/site/anticorruption/impl/UserAntiCorruptionImpl.java

@@ -51,6 +51,9 @@ public class UserAntiCorruptionImpl implements UserAntiCorruption {
         params.put("createTime", System.currentTimeMillis());
 
         HttpEntity<String> entity = new HttpEntity<>(params.toString() , httpHeaders);
+        ResponseEntity<UserInfo> checkResult = restTemplate.getForEntity(userServiceUrl + "/api/userByEmail/" + email, UserInfo.class);
+        if (checkResult.getStatusCode().is2xxSuccessful() && checkResult.getBody()!=null)
+            throw new BaseException("邮箱已存在,请更改或直接登录");
         ResponseEntity<UserInfo> responseEntity = restTemplate.exchange(userServiceUrl + "/api/user", HttpMethod.POST, entity, UserInfo.class);
         if (!responseEntity.getStatusCode().is2xxSuccessful())
             throw new BaseException("手机或邮箱已存在,请直接登录");

+ 2 - 1
site/src/main/java/com/mooctest/crowd/site/controller/AgencyController.java

@@ -2,6 +2,7 @@ package com.mooctest.crowd.site.controller;
 
 import com.mooctest.crowd.domain.exception.BaseException;
 import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
+import com.mooctest.crowd.site.command.GenerateAgencyCommand;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 import com.mooctest.crowd.site.service.AgencyService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +30,7 @@ public class AgencyController {
      * @return
      */
     @RequestMapping(value = "/greenChannel/agency", method = RequestMethod.POST)
-    public UserDTO generateAgency(@RequestBody @Validated ApplyAgencyAuthCommand command, BindingResult result){
+    public UserDTO generateAgency(@RequestBody @Validated GenerateAgencyCommand command, BindingResult result){
         if (result.hasErrors())
             throw new BaseException(result.getFieldError().getDefaultMessage());
         return agencyService.generateAgency(command);

+ 2 - 1
site/src/main/java/com/mooctest/crowd/site/service/AgencyService.java

@@ -1,6 +1,7 @@
 package com.mooctest.crowd.site.service;
 
 import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
+import com.mooctest.crowd.site.command.GenerateAgencyCommand;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 
 /**
@@ -11,7 +12,7 @@ import com.mooctest.crowd.site.data.dto.UserDTO;
 public interface AgencyService {
     UserDTO applyAgency(Long userId, ApplyAgencyAuthCommand command);
 
-    UserDTO generateAgency(ApplyAgencyAuthCommand command);
+    UserDTO generateAgency(GenerateAgencyCommand command);
 
     UserDTO updateAgencyStatus(Long userId, Integer status);
 }

+ 2 - 1
site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java

@@ -9,6 +9,7 @@ import com.mooctest.crowd.domain.exception.UserNotExistException;
 import com.mooctest.crowd.domain.repository.UserRepo;
 import com.mooctest.crowd.site.anticorruption.UserAntiCorruption;
 import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
+import com.mooctest.crowd.site.command.GenerateAgencyCommand;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 import com.mooctest.crowd.site.data.vo.AgencyVO;
 import com.mooctest.crowd.site.data.vo.UserVO;
@@ -48,7 +49,7 @@ public class AgencyServiceImpl implements AgencyService {
     }
 
     @Override
-    public UserDTO generateAgency(ApplyAgencyAuthCommand command) {
+    public UserDTO generateAgency(GenerateAgencyCommand command) {
         boolean mobileExists = false;
         try {
             userRepo.getByMobileNum(command.getMobile());