weiwenhai преди 6 години
родител
ревизия
0fdd8e9069

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

@@ -42,9 +42,9 @@ public class SystemRestController {
 
     @ApiOperation(value = "获取短信验证码接口")
     @RequestMapping(value = "/send/sms/code", method = {RequestMethod.GET, RequestMethod.POST})
-    public Result sendSmsCode(@RequestParam String phone) throws Exception {
+    public Result sendSmsCode(@RequestHeader String key, @RequestHeader String token, @RequestParam String phone) throws Exception {
         //return smsService.sendSmsCode(key, token, phone);
-        return userAuthService.sendSmsCode(phone);
+        return userAuthService.sendSmsCode(key, token, phone);
     }
 
     @ApiOperation(value = "校验短信验证码接口", hidden = true)

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

@@ -82,7 +82,7 @@ public interface UserAuthService {
      * @return
      * @throws Exception
      */
-    Result sendSmsCode(String phone) throws Exception;
+    Result sendSmsCode(String key, String token, String phone) throws Exception;
 
     /**
      * 保存用户绑定的手机号

+ 3 - 10
src/main/java/cn/com/qmth/examcloud/app/service/impl/UserAuthServiceImpl.java

@@ -131,20 +131,13 @@ public class UserAuthServiceImpl implements UserAuthService {
     }
 
     @Override
-    public Result sendSmsCode(String phone) throws Exception {
+    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();
-        Request request = new Request.Builder()
-                .url(requestUrl)
-                .post(formBody)
+                .add("phone", phone)
                 .build();
-        //执行请求
-        Response response = HttpClientBuilder.getClient().newCall(request).execute();
-        String bodyStr = response.body().string();
-        return new Result().success(bodyStr);
+        return HttpUtils.doPost(requestUrl, formBody, key, token);
     }
 
     @Override