|
@@ -25,9 +25,12 @@ import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
|
import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
|
import com.qmth.exam.reserve.dao.ApplyTaskDao;
|
|
|
import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
|
+import com.qmth.exam.reserve.entity.StudentApplyEntity;
|
|
|
import com.qmth.exam.reserve.enums.EventType;
|
|
|
import com.qmth.exam.reserve.service.ApplyTaskService;
|
|
|
import com.qmth.exam.reserve.service.OperateLogService;
|
|
|
+import com.qmth.exam.reserve.service.StudentApplyService;
|
|
|
+import com.qmth.exam.reserve.service.TimePeriodService;
|
|
|
import com.qmth.exam.reserve.util.PageUtil;
|
|
|
|
|
|
@Service
|
|
@@ -39,6 +42,12 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
|
@Autowired
|
|
|
private ApplyTaskCacheService cacheService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StudentApplyService studentApplyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TimePeriodService timePeriodService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageResult<ApplyTaskVO> page(ApplyTaskPageReq req) {
|
|
|
IPage<ApplyTaskVO> iPage = this.baseMapper.page(new Page<ApplyTaskVO>(req.getPageNumber(), req.getPageSize()),
|
|
@@ -61,7 +70,10 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
|
checkRule(req);
|
|
|
ApplyTaskEntity task = new ApplyTaskEntity();
|
|
|
BeanUtils.copyProperties(req, task);
|
|
|
- task.setEnable(Boolean.FALSE);
|
|
|
+ task.setAllowApplyDays(task.getAllowApplyCancelDays());
|
|
|
+ if (req.getId() == null) {
|
|
|
+ task.setEnable(Boolean.FALSE);
|
|
|
+ }
|
|
|
task.setOrgId(user.getOrgId());
|
|
|
this.saveOrUpdate(task);
|
|
|
}
|
|
@@ -69,10 +81,8 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
|
private void checkRule(ApplyTaskReq req) {
|
|
|
if (StringUtils.isEmpty(req.getName()))
|
|
|
throw new StatusException("请填写任务名称");
|
|
|
- if (StringUtils.isEmpty(req.getAllowApplyDays()))
|
|
|
- throw new StatusException("请填写禁止考生预约的天数");
|
|
|
if (StringUtils.isEmpty(req.getAllowApplyCancelDays()))
|
|
|
- throw new StatusException("请填写禁止考生取消预约的天数");
|
|
|
+ throw new StatusException("请填写学生自主操作限制的天数");
|
|
|
if (StringUtils.isEmpty(req.getSelfApplyStartTime()))
|
|
|
throw new StatusException("请填写自主预约起始时间");
|
|
|
if (StringUtils.isEmpty(req.getSelfApplyEndTime()))
|
|
@@ -164,4 +174,17 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
|
return task;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void deleteRule(Long timeId) {
|
|
|
+ if (timeId == null)
|
|
|
+ return;
|
|
|
+ LambdaQueryWrapper<StudentApplyEntity> lm = new LambdaQueryWrapper<>();
|
|
|
+ lm.eq(StudentApplyEntity::getTimePeriodId, timeId);
|
|
|
+ List<StudentApplyEntity> applyList = studentApplyService.list(lm);
|
|
|
+ if (applyList != null && applyList.size() > 0) {
|
|
|
+ throw new StatusException("考生已经预约,不能删除预约时段");
|
|
|
+ }
|
|
|
+ timePeriodService.removeById(timeId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|