|
@@ -1,10 +1,14 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.api.controller;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -12,6 +16,7 @@ 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.web.redis.RedisClient;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ResponseStatus;
|
|
@@ -19,6 +24,7 @@ import cn.com.qmth.examcloud.commons.web.support.StatusResponse;
|
|
|
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.ImgCodeService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.SmsCodeService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.StudentService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
|
|
@@ -39,6 +45,9 @@ public class AuthController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
AuthService authService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RedisClient redisClient;
|
|
|
+
|
|
|
@Autowired
|
|
|
SmsCodeService smsCodeService;
|
|
|
|
|
@@ -48,6 +57,9 @@ public class AuthController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
StudentService studentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ImgCodeService imgCodeService;
|
|
|
+
|
|
|
@ApiOperation(value = "登入", notes = "")
|
|
|
@PostMapping("login")
|
|
|
public Object login(@RequestBody LoginInfo loginInfo, HttpServletRequest request) {
|
|
@@ -156,4 +168,13 @@ public class AuthController extends ControllerSupport {
|
|
|
studentRepo.saveAndFlush(s);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "获取验证码图片", notes = "")
|
|
|
+ @GetMapping("code.jpg")
|
|
|
+ public void getCodeImg(@RequestParam(required = true) String sessionId,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ response.setContentType("image/jpg");
|
|
|
+ String code = imgCodeService.generate(response.getOutputStream());
|
|
|
+ redisClient.set("$_IMG_" + sessionId, code, 30);
|
|
|
+ }
|
|
|
+
|
|
|
}
|