weiwenhai 6 жил өмнө
parent
commit
7134fdbf79

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

@@ -47,6 +47,14 @@ public class SystemRestController {
         return userAuthService.sendSmsCode(key, token, phone);
     }
 
+    @ApiOperation(value = "获取短信验证码接口")
+    @RequestMapping(value = "/send/sms/code4Student", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result sendSmsCode(@RequestParam(required = true) Long rootOrgId,
+							  @RequestParam(required = true) String phone) throws Exception {
+        //return smsService.sendSmsCode(key, token, phone);
+        return userAuthService.code4Student(rootOrgId, phone, true);
+    }
+    
     @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 {

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

@@ -83,6 +83,17 @@ public interface UserAuthService {
      * @throws Exception
      */
     Result sendSmsCode(String key, String token, String phone) throws Exception;
+    
+    /**
+     * 获取短信验证码
+     *
+     * @param key
+     * @param token
+     * @param phone
+     * @return
+     * @throws Exception
+     */
+    Result code4Student(Long rootOrgId, String phone, Boolean bound) throws Exception;
 
     /**
      * 保存用户绑定的手机号

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

@@ -139,6 +139,25 @@ public class UserAuthServiceImpl implements UserAuthService {
                 .build();
         return HttpUtils.doPost(requestUrl, formBody, key, token);
     }
+    
+    @Override
+	public Result code4Student(Long rootOrgId, String phone, Boolean bound) throws Exception {
+    	//封装请求参数
+    	final String requestUrl = String.format("%s/api/ecs_core/auth/sendVerificationCode4Student", propertyService.getUserAuthUrl());
+    	RequestBody formBody = new FormBody.Builder()
+    			.add("rootOrgId", rootOrgId.toString())
+    			.add("phone", phone)
+		        .add("bound", bound.toString())
+		        .build();
+    	Request request = new Request.Builder()
+		        .url(requestUrl)
+		        .post(formBody)
+		        .build();
+		//执行请求
+		Response response = HttpClientBuilder.getClient().newCall(request).execute();
+		String bodyStr = response.body().string();
+		return new Result().success(bodyStr);
+	}
 
     @Override
     public Result userBindingPhone(String key, String token, String phone, String code) throws Exception {