|
@@ -1,18 +1,22 @@
|
|
package com.qmth.exam.reserve.service.impl;
|
|
package com.qmth.exam.reserve.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.core.security.annotation.AuthorizationComponent;
|
|
import com.qmth.boot.core.security.annotation.AuthorizationComponent;
|
|
import com.qmth.boot.core.security.service.AuthorizationService;
|
|
import com.qmth.boot.core.security.service.AuthorizationService;
|
|
import com.qmth.boot.tools.signature.SignatureType;
|
|
import com.qmth.boot.tools.signature.SignatureType;
|
|
import com.qmth.boot.tools.uuid.FastUUID;
|
|
import com.qmth.boot.tools.uuid.FastUUID;
|
|
|
|
+import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.login.LoginReq;
|
|
import com.qmth.exam.reserve.bean.login.LoginReq;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.login.WechatLoginReq;
|
|
import com.qmth.exam.reserve.bean.login.WechatLoginReq;
|
|
import com.qmth.exam.reserve.cache.CacheConstants;
|
|
import com.qmth.exam.reserve.cache.CacheConstants;
|
|
import com.qmth.exam.reserve.cache.LoginSessionManager;
|
|
import com.qmth.exam.reserve.cache.LoginSessionManager;
|
|
|
|
+import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
import com.qmth.exam.reserve.entity.UserEntity;
|
|
import com.qmth.exam.reserve.entity.UserEntity;
|
|
import com.qmth.exam.reserve.enums.Role;
|
|
import com.qmth.exam.reserve.enums.Role;
|
|
|
|
+import com.qmth.exam.reserve.service.ApplyTaskService;
|
|
import com.qmth.exam.reserve.service.AuthService;
|
|
import com.qmth.exam.reserve.service.AuthService;
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
import com.qmth.exam.reserve.service.UserService;
|
|
import com.qmth.exam.reserve.service.UserService;
|
|
@@ -38,6 +42,9 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
@Autowired
|
|
@Autowired
|
|
private StudentService studentService;
|
|
private StudentService studentService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ApplyTaskService applyTaskService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public LoginUser userLogin(LoginReq req) {
|
|
public LoginUser userLogin(LoginReq req) {
|
|
if (StringUtils.isBlank(req.getAccount())) {
|
|
if (StringUtils.isBlank(req.getAccount())) {
|
|
@@ -61,11 +68,11 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
|
|
|
LoginUser loginUser = new LoginUser();
|
|
LoginUser loginUser = new LoginUser();
|
|
loginUser.setId(user.getId());
|
|
loginUser.setId(user.getId());
|
|
- loginUser.setOrgId(user.getOrgId());
|
|
|
|
- loginUser.setCategoryId(user.getCategoryId());
|
|
|
|
loginUser.setAccount(user.getLoginName());
|
|
loginUser.setAccount(user.getLoginName());
|
|
loginUser.setName(user.getName());
|
|
loginUser.setName(user.getName());
|
|
loginUser.setRole(user.getRole());
|
|
loginUser.setRole(user.getRole());
|
|
|
|
+ loginUser.setOrgId(user.getOrgId());
|
|
|
|
+ loginUser.setCategoryId(user.getCategoryId());
|
|
|
|
|
|
loginUser.setSessionId(CacheConstants.CACHE_USER_LOGIN + user.getId());
|
|
loginUser.setSessionId(CacheConstants.CACHE_USER_LOGIN + user.getId());
|
|
loginUser.setToken(FastUUID.get());
|
|
loginUser.setToken(FastUUID.get());
|
|
@@ -85,8 +92,14 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
throw new StatusException("登录密码不能为空");
|
|
throw new StatusException("登录密码不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 获取当前启用的预约任务
|
|
|
|
+ CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(req.getOrgId());
|
|
|
|
+ if (curApplyTask == null) {
|
|
|
|
+ throw new StatusException("尚未开启预约任务");
|
|
|
|
+ }
|
|
|
|
+
|
|
log.debug("[STUDENT_LOGIN] verifying, account:{}", req.getAccount());
|
|
log.debug("[STUDENT_LOGIN] verifying, account:{}", req.getAccount());
|
|
- StudentEntity student = studentService.findByStudentCode(req.getOrgId(), req.getAccount());
|
|
|
|
|
|
+ StudentEntity student = studentService.findByStudentCode(curApplyTask.getTaskId(), req.getAccount());
|
|
if (student == null) {
|
|
if (student == null) {
|
|
throw new StatusException("登录用户不存在");
|
|
throw new StatusException("登录用户不存在");
|
|
}
|
|
}
|
|
@@ -98,11 +111,12 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
|
|
|
LoginUser loginUser = new LoginUser();
|
|
LoginUser loginUser = new LoginUser();
|
|
loginUser.setId(student.getId());
|
|
loginUser.setId(student.getId());
|
|
- loginUser.setOrgId(student.getOrgId());
|
|
|
|
- loginUser.setCategoryId(student.getCategoryId());
|
|
|
|
loginUser.setAccount(student.getStudentCode());
|
|
loginUser.setAccount(student.getStudentCode());
|
|
loginUser.setName(student.getName());
|
|
loginUser.setName(student.getName());
|
|
loginUser.setRole(Role.STUDENT);
|
|
loginUser.setRole(Role.STUDENT);
|
|
|
|
+ loginUser.setOrgId(student.getOrgId());
|
|
|
|
+ loginUser.setCategoryId(student.getCategoryId());
|
|
|
|
+ loginUser.setApplyTaskId(student.getApplyTaskId());
|
|
loginUser.setOpenId(student.getOpenId());
|
|
loginUser.setOpenId(student.getOpenId());
|
|
|
|
|
|
loginUser.setSessionId(CacheConstants.CACHE_STUDENT_LOGIN + student.getId());
|
|
loginUser.setSessionId(CacheConstants.CACHE_STUDENT_LOGIN + student.getId());
|
|
@@ -125,13 +139,22 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
throw new StatusException("登录用户不存在");
|
|
throw new StatusException("登录用户不存在");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ LambdaQueryWrapper<ApplyTaskEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.select(ApplyTaskEntity::getEnable);
|
|
|
|
+ wrapper.eq(ApplyTaskEntity::getId, student.getApplyTaskId());
|
|
|
|
+ ApplyTaskEntity curApplyTask = applyTaskService.getOne(wrapper);
|
|
|
|
+ if (curApplyTask == null || !curApplyTask.getEnable()) {
|
|
|
|
+ throw new StatusException("尚未开启预约任务");
|
|
|
|
+ }
|
|
|
|
+
|
|
LoginUser loginUser = new LoginUser();
|
|
LoginUser loginUser = new LoginUser();
|
|
loginUser.setId(student.getId());
|
|
loginUser.setId(student.getId());
|
|
- loginUser.setOrgId(student.getOrgId());
|
|
|
|
- loginUser.setCategoryId(student.getCategoryId());
|
|
|
|
loginUser.setAccount(student.getStudentCode());
|
|
loginUser.setAccount(student.getStudentCode());
|
|
loginUser.setName(student.getName());
|
|
loginUser.setName(student.getName());
|
|
loginUser.setRole(Role.STUDENT);
|
|
loginUser.setRole(Role.STUDENT);
|
|
|
|
+ loginUser.setOrgId(student.getOrgId());
|
|
|
|
+ loginUser.setCategoryId(student.getCategoryId());
|
|
|
|
+ loginUser.setApplyTaskId(student.getApplyTaskId());
|
|
loginUser.setOpenId(student.getOpenId());
|
|
loginUser.setOpenId(student.getOpenId());
|
|
|
|
|
|
loginUser.setSessionId(CacheConstants.CACHE_STUDENT_LOGIN + student.getId());
|
|
loginUser.setSessionId(CacheConstants.CACHE_STUDENT_LOGIN + student.getId());
|