deason hai 1 ano
pai
achega
05566dbdaa

+ 1 - 1
src/main/java/com/qmth/exam/reserve/controller/student/StudentApplyController.java

@@ -78,7 +78,7 @@ public class StudentApplyController extends BaseController {
     @ApiOperation(value = "获取可预约的“日期”列表", notes = "日期格式:yyyyMMdd")
     @PostMapping(value = "/apply/date/list")
     public List<String> dateList() {
-        return examReserveService.getApplyDateList(curLoginStudent().getOrgId());
+        return examReserveService.getApplyDateList(curLoginStudent());
     }
 
     @ApiOperation(value = "获取可预约的“时段”列表")

+ 2 - 0
src/main/java/com/qmth/exam/reserve/service/ApplyTaskService.java

@@ -23,6 +23,8 @@ public interface ApplyTaskService extends IService<ApplyTaskEntity> {
 
     CurrentApplyTaskVO currentApplyTask(Long orgId);
 
+    ApplyTaskEntity getLessInfoApplyTaskById(Long applyTaskId);
+
     ApplyTaskEntity findApplyTask();
 
 }

+ 1 - 1
src/main/java/com/qmth/exam/reserve/service/ExamReserveService.java

@@ -20,7 +20,7 @@ public interface ExamReserveService {
 
     TicketInfo getApplyTicket(Long studentId, Long applyId);
 
-    List<String> getApplyDateList(Long orgId);
+    List<String> getApplyDateList(LoginUser loginUser);
 
     ApplyTimePeriodResult getApplyTimePeriodList(LoginUser loginUser, Long examSiteId, String date);
 

+ 15 - 6
src/main/java/com/qmth/exam/reserve/service/impl/ApplyTaskServiceImpl.java

@@ -1,11 +1,5 @@
 package com.qmth.exam.reserve.service.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -23,6 +17,11 @@ import com.qmth.exam.reserve.dao.ApplyTaskDao;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.service.ApplyTaskService;
 import com.qmth.exam.reserve.util.PageUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @Service
 public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEntity> implements ApplyTaskService {
@@ -99,9 +98,19 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
      */
     @Override
     public CurrentApplyTaskVO currentApplyTask(Long orgId) {
+        // 默认取一个最新的启用的预约任务
         return baseMapper.currentApplyTask(orgId);
     }
 
+    @Override
+    public ApplyTaskEntity getLessInfoApplyTaskById(Long applyTaskId) {
+        // 只查询id、name、enable等少量字段
+        LambdaQueryWrapper<ApplyTaskEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(ApplyTaskEntity::getId, ApplyTaskEntity::getName, ApplyTaskEntity::getEnable);
+        wrapper.eq(ApplyTaskEntity::getId, applyTaskId);
+        return this.getOne(wrapper);
+    }
+
     @Override
     public ApplyTaskEntity findApplyTask() {
         LambdaQueryWrapper<ApplyTaskEntity> wrapper = new LambdaQueryWrapper<>();

+ 1 - 6
src/main/java/com/qmth/exam/reserve/service/impl/AuthServiceImpl.java

@@ -1,6 +1,5 @@
 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.security.annotation.AuthorizationComponent;
 import com.qmth.boot.core.security.service.AuthorizationService;
@@ -92,7 +91,6 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
             throw new StatusException("登录密码不能为空");
         }
 
-        // 获取当前启用的预约任务
         CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(req.getOrgId());
         if (curApplyTask == null) {
             throw new StatusException("尚未开启预约任务");
@@ -139,10 +137,7 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
             throw new StatusException("登录用户不存在");
         }
 
-        LambdaQueryWrapper<ApplyTaskEntity> wrapper = new LambdaQueryWrapper<>();
-        wrapper.select(ApplyTaskEntity::getEnable);
-        wrapper.eq(ApplyTaskEntity::getId, student.getApplyTaskId());
-        ApplyTaskEntity curApplyTask = applyTaskService.getOne(wrapper);
+        ApplyTaskEntity curApplyTask = applyTaskService.getLessInfoApplyTaskById(student.getApplyTaskId());
         if (curApplyTask == null || !curApplyTask.getEnable()) {
             throw new StatusException("尚未开启预约任务");
         }

+ 2 - 4
src/main/java/com/qmth/exam/reserve/service/impl/ExamReserveServiceImpl.java

@@ -142,12 +142,11 @@ public class ExamReserveServiceImpl implements ExamReserveService {
     }
 
     @Override
-    public List<String> getApplyDateList(Long orgId) {
+    public List<String> getApplyDateList(LoginUser student) {
         // 日期格式:yyyyMMdd
         List<String> dateList = new ArrayList<>();
 
-        // 获取当前启用的预约任务
-        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(orgId);
+        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
         if (curApplyTask == null) {
             return dateList;
         }
@@ -202,7 +201,6 @@ public class ExamReserveServiceImpl implements ExamReserveService {
             throw new StatusException("预约日期值的格式不正确");
         }
 
-        // 获取当前启用的预约任务
         CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
         if (curApplyTask == null) {
             throw new StatusException("当前预约任务不存在");