|
@@ -22,6 +22,7 @@ import cn.com.qmth.examcloud.core.basic.base.constants.PropKeys;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.AuthService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.StudentService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
|
|
|
import cn.com.qmth.examcloud.exchange.inner.api.SendSmsCloudService;
|
|
|
import cn.com.qmth.examcloud.exchange.inner.api.request.CheckSmsCodeReq;
|
|
@@ -50,6 +51,9 @@ public class AuthController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
StudentRepo studentRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ StudentService studentService;
|
|
|
+
|
|
|
@ApiOperation(value = "登入", notes = "")
|
|
|
@PostMapping("login")
|
|
|
public Object login(@RequestBody LoginInfo loginInfo, HttpServletRequest request) {
|
|
@@ -113,6 +117,47 @@ public class AuthController extends ControllerSupport {
|
|
|
return authService.thirdPartyAccess(orgId, loginName, appId, timestamp, token, realIp);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "发送验证码", notes = "")
|
|
|
+ @PostMapping("sendVerificationCode4Student")
|
|
|
+ public void sendVerificationCode4Student(@RequestParam(required = true) Long rootOrgId,
|
|
|
+ @RequestParam(required = true) String phone,
|
|
|
+ @RequestParam(required = true) Boolean bound) {
|
|
|
+
|
|
|
+ Boolean hasBeBound = studentService.hasBeBound(rootOrgId, phone);
|
|
|
+ if (bound && !hasBeBound.equals(bound)) {
|
|
|
+ throw new StatusException("B-002050", "手机号未被关联");
|
|
|
+ } else if ((!bound) && hasBeBound.equals(bound)) {
|
|
|
+ throw new StatusException("B-002050", "手机号已被关联");
|
|
|
+ }
|
|
|
+
|
|
|
+ SendSmsReq req = new SendSmsReq();
|
|
|
+ req.setPhone(phone);
|
|
|
+ int code = 1000 + RandomUtils.nextInt(1, 9999);
|
|
|
+ req.setCode(String.valueOf(code));
|
|
|
+
|
|
|
+ int smsEffectivetime = PropertiesUtil.getInt(PropKeys.SEND_VERIFICATION_CODE_EFFECTIVE_TIME,
|
|
|
+ 120);
|
|
|
+ int smsIntervalSeconds = PropertiesUtil
|
|
|
+ .getInt(PropKeys.SEND_VERIFICATION_CODE_INTERVAL_SECONDS, 60);
|
|
|
+
|
|
|
+ String smsSign = PropertiesUtil.getString(PropKeys.SEND_VERIFICATION_CODE_SIGN);
|
|
|
+ String smsTemplatecode = PropertiesUtil
|
|
|
+ .getString(PropKeys.SEND_VERIFICATION_CODE_TEMPLATE_CODE);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(smsSign)) {
|
|
|
+ throw new StatusException("B-001060", "签名未配置");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(smsTemplatecode)) {
|
|
|
+ throw new StatusException("B-001061", "模板未配置");
|
|
|
+ }
|
|
|
+
|
|
|
+ req.setEffectiveTime(smsEffectivetime);
|
|
|
+ req.setIntervalSeconds(smsIntervalSeconds);
|
|
|
+ req.setSign(smsSign);
|
|
|
+ req.setTemplateCode(smsTemplatecode);
|
|
|
+ sendSmsCloudService.sendIdentifyingCode(req);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "发送验证码", notes = "")
|
|
|
@PostMapping("/sendVerificationCode")
|
|
|
public void sendVerificationCode(@RequestParam String phone) {
|