|
@@ -5,7 +5,6 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -13,8 +12,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+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.Student;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.AuthService;
|
|
@@ -45,24 +46,6 @@ public class AuthController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
StudentRepo studentRepo;
|
|
|
|
|
|
- @Value("${$sendVerificationCode.sign}")
|
|
|
- private String smsSign;
|
|
|
-
|
|
|
- @Value("${$sendVerificationCode.templatecode}")
|
|
|
- private String smsTemplatecode;
|
|
|
-
|
|
|
- /**
|
|
|
- * 短信验证码有效期/秒
|
|
|
- */
|
|
|
- @Value("${$sendVerificationCode.effectivetime}")
|
|
|
- private Integer smsEffectivetime;
|
|
|
-
|
|
|
- /**
|
|
|
- * 短信验证码 发送间隔时间/秒
|
|
|
- */
|
|
|
- @Value("${$sendVerificationCode.intervalseconds}")
|
|
|
- private Integer smsIntervalSeconds;
|
|
|
-
|
|
|
@ApiOperation(value = "登入", notes = "")
|
|
|
@PostMapping("login")
|
|
|
public User login(@RequestBody LoginInfo loginInfo, HttpServletRequest request) {
|
|
@@ -118,6 +101,23 @@ public class AuthController extends ControllerSupport {
|
|
|
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);
|