|
@@ -1,12 +1,15 @@
|
|
|
package com.qmth.exam.reserve.service.impl;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
|
+import com.qmth.boot.core.exception.StatusException;
|
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
|
|
|
+import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
|
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
|
import com.qmth.exam.reserve.dao.ApplyTaskDao;
|
|
|
import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
@@ -23,4 +26,49 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
|
return PageUtil.of(iPage);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ApplyTaskRuleVO find(Long id) {
|
|
|
+ ApplyTaskRuleVO task = this.baseMapper.find(id);
|
|
|
+ if (StringUtils.isEmpty(task)) {
|
|
|
+ throw new StatusException("预约任务不存在!");
|
|
|
+ }
|
|
|
+ task.setTimeList(this.baseMapper.getTimePeriodList(id));
|
|
|
+ return task;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void ruleSave(ApplyTaskReq req) {
|
|
|
+ checkRule(req);
|
|
|
+ ApplyTaskEntity task = new ApplyTaskEntity();
|
|
|
+ task.setId(req.getId());
|
|
|
+ task.setName(req.getName());
|
|
|
+ task.setAllowApplyDays(req.getAllowApplyDays());
|
|
|
+ task.setAllowApplyCancelDays(req.getAllowApplyCancelDays());
|
|
|
+ task.setSelfApplyStartTime(req.getSelfApplyStartTime());
|
|
|
+ task.setSelfApplyEndTime(req.getSelfApplyEndTime());
|
|
|
+ task.setOpenApplyStartTime(req.getOpenApplyStartTime());
|
|
|
+ task.setOpenApplyEndTime(req.getOpenApplyEndTime());
|
|
|
+ task.setEnable(Boolean.FALSE);
|
|
|
+ //TODO 根据登录用户获取机构ID
|
|
|
+ task.setOrgId(1L);
|
|
|
+ this.saveOrUpdate(task);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("请填写禁止考生取消预约的天数");
|
|
|
+ if (StringUtils.isEmpty(req.getSelfApplyStartTime()))
|
|
|
+ throw new StatusException("请填写自主预约起始时间");
|
|
|
+ if (StringUtils.isEmpty(req.getSelfApplyEndTime()))
|
|
|
+ throw new StatusException("请填写自主预约截止时间");
|
|
|
+ if (StringUtils.isEmpty(req.getOpenApplyStartTime()))
|
|
|
+ throw new StatusException("请填写开放式预约起始时间");
|
|
|
+ if (StringUtils.isEmpty(req.getOpenApplyEndTime()))
|
|
|
+ throw new StatusException("请填写开放式预约截止时间");
|
|
|
+ }
|
|
|
+
|
|
|
}
|