|
@@ -0,0 +1,74 @@
|
|
|
+package cn.com.qmth.examcloud.core.oe.student.api.controller;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.base.utils.CommonUtil;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.SmsCloudService;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.request.CheckSmsCodeReq;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.request.SendSmsCodeReq;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.response.CheckSmsCodeResp;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.response.SendSmsCodeResp;
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author chenken
|
|
|
+ * @date 2018年9月5日 下午3:33:26
|
|
|
+ * @company QMTH
|
|
|
+ * @description ExamSmsController.java
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@Api(tags = "考试短信接口")
|
|
|
+@RequestMapping("${app.api.oe.student}/sms")
|
|
|
+public class ExamSmsController extends ControllerSupport {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentCloudService studentCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SmsCloudService smsCloudService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "发送短信验证码")
|
|
|
+ @PostMapping("/sendSmsCodeToStudent")
|
|
|
+ public SendSmsCodeResp sendSmsCodeToStudent() {
|
|
|
+ User user = getAccessUser();
|
|
|
+ GetStudentReq getStudentReq = new GetStudentReq();
|
|
|
+ getStudentReq.setStudentId(user.getUserId());
|
|
|
+ GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(getStudentResp.getStudentInfo().getPhoneNumber())) {
|
|
|
+ throw new StatusException("100001", "系统中手机号码为空,请联系管理员");
|
|
|
+ }
|
|
|
+ SendSmsCodeReq sendSmsReq = new SendSmsCodeReq();
|
|
|
+ sendSmsReq.setPhone(getStudentResp.getStudentInfo().getPhoneNumber());
|
|
|
+ sendSmsReq.setCode(CommonUtil.makeRandomNum(6));
|
|
|
+
|
|
|
+ return smsCloudService.sendSmsCode(sendSmsReq);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "检查验证码是否正确")
|
|
|
+ @PostMapping(value = "/checkSmsCode")
|
|
|
+ public CheckSmsCodeResp checkSmsCode(@RequestParam String phoneNumber,
|
|
|
+ @RequestParam String code) {
|
|
|
+ Check.isBlank(phoneNumber, "phoneNumber不能为空");
|
|
|
+ Check.isBlank(code, "code不能为空");
|
|
|
+ CheckSmsCodeReq checkSmsCodeReq = new CheckSmsCodeReq();
|
|
|
+ checkSmsCodeReq.setPhone(phoneNumber);
|
|
|
+ checkSmsCodeReq.setCode(code);
|
|
|
+ return smsCloudService.checkSmsCode(checkSmsCodeReq);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|