deason 7 年之前
父节点
当前提交
458285bddf

+ 6 - 2
src/main/java/cn/com/qmth/examcloud/app/controller/version1/SystemRestController.java

@@ -10,6 +10,7 @@ package cn.com.qmth.examcloud.app.controller.version1;
 import cn.com.qmth.examcloud.app.model.Result;
 import cn.com.qmth.examcloud.app.service.NetExamService;
 import cn.com.qmth.examcloud.app.service.SmsService;
+import cn.com.qmth.examcloud.app.service.UserAuthService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +30,8 @@ public class SystemRestController {
     @Autowired
     private NetExamService netExamService;
     @Autowired
+    private UserAuthService userAuthService;
+    @Autowired
     private SmsService smsService;
 
     @ApiOperation(value = "获取服务器当前时间接口")
@@ -40,10 +43,11 @@ public class SystemRestController {
     @ApiOperation(value = "获取短信验证码接口")
     @RequestMapping(value = "/send/sms/code", method = {RequestMethod.GET, RequestMethod.POST})
     public Result sendSmsCode(@RequestHeader String key, @RequestHeader String token, @RequestParam String phone) throws Exception {
-        return smsService.sendSmsCode(key, token, phone);
+        //return smsService.sendSmsCode(key, token, phone);
+        return userAuthService.sendSmsCode(key, token, phone);
     }
 
-    @ApiOperation(value = "校验短信验证码接口")
+    @ApiOperation(value = "校验短信验证码接口", hidden = true)
     @RequestMapping(value = "/check/sms/code", method = {RequestMethod.GET, RequestMethod.POST})
     public Result checkSmsCode(@RequestHeader String key, @RequestHeader String token, @RequestParam String phone, @RequestParam String code) throws Exception {
         return smsService.checkSmsCode(key, token, phone, code);

+ 3 - 3
src/main/java/cn/com/qmth/examcloud/app/controller/version1/UserAuthRestController.java

@@ -68,10 +68,10 @@ public class UserAuthRestController {
         return userAuthService.updatePassword(key, token, userId, password);
     }
 
-    @ApiOperation(value = "保存用户绑定的手机号接口", hidden = true)
+    @ApiOperation(value = "保存用户绑定的手机号接口")
     @RequestMapping(value = "/user/binding/phone", method = {RequestMethod.GET, RequestMethod.POST})
-    public Result userBindingPhone(@RequestHeader String key, @RequestHeader String token, @RequestParam Long userId, @RequestParam String phone, @RequestParam String code) throws Exception {
-        return baseInfoService.userBindingPhone(key, token, userId, phone, code);
+    public Result userBindingPhone(@RequestHeader String key, @RequestHeader String token, @RequestParam String phone, @RequestParam String code) throws Exception {
+        return userAuthService.userBindingPhone(key, token, phone, code);
     }
 
 }

+ 0 - 1
src/main/java/cn/com/qmth/examcloud/app/core/utils/HttpUtils.java

@@ -36,7 +36,6 @@ public class HttpUtils {
                 .addHeader(PARAM_TOKEN, token)
                 .addHeader(PARAM_TRACE_ID, ThreadUtils.getTraceID())
                 .addHeader(PARAM_CLIENT, PARAM_CLIENT_VALUE)
-                .addHeader(PARAM_TOKEN, token)
                 .build();
 
         //执行请求

+ 2 - 0
src/main/java/cn/com/qmth/examcloud/app/model/Result.java

@@ -7,6 +7,7 @@
 
 package cn.com.qmth.examcloud.app.model;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
@@ -76,6 +77,7 @@ public class Result<T> implements Serializable {
         return this;
     }
 
+    @JsonIgnore
     public boolean isSuccess() {
         if (Constants.CODE_200.equals(getCode())) {
             return true;

+ 0 - 2
src/main/java/cn/com/qmth/examcloud/app/service/BaseInfoService.java

@@ -19,6 +19,4 @@ public interface BaseInfoService {
 
     Result getStudentInfo(String key, String token) throws Exception;
 
-    Result userBindingPhone(String key, String token, Long userId, String phone, String code);
-
 }

+ 4 - 0
src/main/java/cn/com/qmth/examcloud/app/service/UserAuthService.java

@@ -28,6 +28,10 @@ public interface UserAuthService {
 
     Result updatePassword(String key, String token, Long userId, String password) throws Exception;
 
+    Result sendSmsCode(String key, String token, String phone) throws Exception;
+
+    Result userBindingPhone(String key, String token, String phone, String code) throws Exception;
+
     void cacheLoginInfo(LoginInfo loginInfo, UserInfo userInfo);
 
     void cacheLoginInfo(LoginInfo loginInfo, String key);

+ 0 - 6
src/main/java/cn/com/qmth/examcloud/app/service/impl/BaseInfoServiceImpl.java

@@ -36,10 +36,4 @@ public class BaseInfoServiceImpl implements BaseInfoService {
         return HttpUtils.doGet(requestUrl, key, token);
     }
 
-    @Override
-    public Result userBindingPhone(String key, String token, Long userId, String phone, String code) {
-        //api/core_api/auth/sendVerificationCode
-        return new Result().error();
-    }
-
 }

+ 21 - 0
src/main/java/cn/com/qmth/examcloud/app/service/impl/UserAuthServiceImpl.java

@@ -111,6 +111,27 @@ public class UserAuthServiceImpl implements UserAuthService {
         return HttpUtils.doPut(requestUrl, formBody, key, token);
     }
 
+    @Override
+    public Result sendSmsCode(String key, String token, String phone) throws Exception {
+        //封装请求参数
+        final String requestUrl = String.format("%s/api/ecs_core/auth/sendVerificationCode", propertyService.getUserAuthUrl());
+        RequestBody formBody = new FormBody.Builder()
+                .add("phone", phone)
+                .build();
+        return HttpUtils.doPost(requestUrl, formBody, key, token);
+    }
+
+    @Override
+    public Result userBindingPhone(String key, String token, String phone, String code) throws Exception {
+        //封装请求参数
+        final String requestUrl = String.format("%s/api/ecs_core/auth/bindSecurityPhone", propertyService.getUserAuthUrl());
+        RequestBody formBody = new FormBody.Builder()
+                .add("phone", phone)
+                .add("verificationCode", code)
+                .build();
+        return HttpUtils.doPost(requestUrl, formBody, key, token);
+    }
+
     @Override
     public void cacheLoginInfo(LoginInfo loginInfo, UserInfo userInfo) {
         if (loginInfo == null || userInfo == null) {