Browse Source

预约任务管理

haogh 1 year ago
parent
commit
c52cbe182c

+ 24 - 0
src/main/java/com/qmth/exam/reserve/bean/applytask/TimePeriodReq.java

@@ -0,0 +1,24 @@
+package com.qmth.exam.reserve.bean.applytask;
+
+import com.qmth.exam.reserve.bean.IModel;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class TimePeriodReq implements IModel {
+
+    private static final long serialVersionUID = -130467262770041499L;
+
+    @ApiModelProperty(required = false, value = "预约时段ID")
+    private Long id;
+
+    @ApiModelProperty(required = false, value = "开始时间")
+    private Long startTime;
+
+    @ApiModelProperty(required = false, value = "截止时间")
+    private Long endTime;
+
+}

+ 18 - 0
src/main/java/com/qmth/exam/reserve/bean/task/ApplyTaskPageReq.java

@@ -0,0 +1,18 @@
+package com.qmth.exam.reserve.bean.task;
+
+import com.qmth.exam.reserve.bean.PagerReq;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ApplyTaskPageReq extends PagerReq {
+
+    private static final long serialVersionUID = 7446776354220969902L;
+
+    @ApiModelProperty("任务名称")
+    private String name;
+
+}

+ 10 - 9
src/main/java/com/qmth/exam/reserve/bean/task/ApplyTaskReq.java

@@ -1,38 +1,39 @@
 package com.qmth.exam.reserve.bean.task;
 package com.qmth.exam.reserve.bean.task;
 
 
-import com.qmth.exam.reserve.bean.PagerReq;
+import com.qmth.exam.reserve.bean.IModel;
+
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
 
 
 @Getter
 @Getter
 @Setter
 @Setter
-public class ApplyTaskReq extends PagerReq {
+public class ApplyTaskReq implements IModel {
 
 
     private static final long serialVersionUID = -1610996900633972962L;
     private static final long serialVersionUID = -1610996900633972962L;
 
 
-    @ApiModelProperty("任务名称")
+    @ApiModelProperty(required = true, value = "任务名称")
     private String name;
     private String name;
 
 
     @ApiModelProperty("任务ID")
     @ApiModelProperty("任务ID")
     private Long id;
     private Long id;
 
 
-    @ApiModelProperty("考前多少天禁止考生预约")
+    @ApiModelProperty(required = true, value = "考前多少天禁止考生预约")
     private Integer allowApplyDays;
     private Integer allowApplyDays;
 
 
-    @ApiModelProperty("考前多少小时禁止考生自主取消预约")
+    @ApiModelProperty(required = true, value = "考前多少小天禁止考生自主取消预约")
     private Integer allowApplyCancelDays;
     private Integer allowApplyCancelDays;
 
 
-    @ApiModelProperty("自主预约起始时间")
+    @ApiModelProperty(required = true, value = "自主预约起始时间")
     private Long selfApplyStartTime;
     private Long selfApplyStartTime;
 
 
-    @ApiModelProperty("自主预约截止时间")
+    @ApiModelProperty(required = true, value = "自主预约截止时间")
     private Long selfApplyEndTime;
     private Long selfApplyEndTime;
 
 
-    @ApiModelProperty("开放式预约起始时间")
+    @ApiModelProperty(required = true, value = "开放式预约起始时间")
     private Long openApplyStartTime;
     private Long openApplyStartTime;
 
 
-    @ApiModelProperty("开放式预约截止时间")
+    @ApiModelProperty(required = true, value = "开放式预约截止时间")
     private Long openApplyEndTime;
     private Long openApplyEndTime;
 
 
 }
 }

+ 27 - 14
src/main/java/com/qmth/exam/reserve/controller/admin/ApplyTaskController.java

@@ -1,5 +1,7 @@
 package com.qmth.exam.reserve.controller.admin;
 package com.qmth.exam.reserve.controller.admin;
 
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -10,11 +12,16 @@ import org.springframework.web.bind.annotation.RestController;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.core.collection.PageResult;
 import com.qmth.boot.core.collection.PageResult;
+import com.qmth.boot.core.exception.StatusException;
+import com.qmth.exam.reserve.bean.applytask.TimePeriodReq;
 import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.login.LoginUser;
+import com.qmth.exam.reserve.bean.task.ApplyTaskPageReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.controller.BaseController;
 import com.qmth.exam.reserve.controller.BaseController;
 import com.qmth.exam.reserve.service.ApplyTaskService;
 import com.qmth.exam.reserve.service.ApplyTaskService;
+import com.qmth.exam.reserve.service.TimePeriodService;
+import com.qmth.exam.reserve.util.JsonHelper;
 
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
@@ -23,15 +30,18 @@ import io.swagger.annotations.ApiParam;
 @RestController
 @RestController
 @Api(tags = "预约任务相关接口")
 @Api(tags = "预约任务相关接口")
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/apply/task")
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/apply/task")
-@Aac(strict = false, auth = false)
+@Aac(strict = false, auth = true)
 public class ApplyTaskController extends BaseController {
 public class ApplyTaskController extends BaseController {
 
 
     @Autowired
     @Autowired
     private ApplyTaskService applyTaskService;
     private ApplyTaskService applyTaskService;
 
 
+    @Autowired
+    private TimePeriodService timePeriodService;
+
     @ApiOperation(value = "预约任务查询")
     @ApiOperation(value = "预约任务查询")
     @PostMapping(value = "/page")
     @PostMapping(value = "/page")
-    public PageResult<ApplyTaskVO> page(@RequestBody ApplyTaskReq req) {
+    public PageResult<ApplyTaskVO> page(@RequestBody ApplyTaskPageReq req) {
         return applyTaskService.page(req);
         return applyTaskService.page(req);
     }
     }
 
 
@@ -43,31 +53,34 @@ public class ApplyTaskController extends BaseController {
 
 
     @ApiOperation(value = "基础规则新增/编辑")
     @ApiOperation(value = "基础规则新增/编辑")
     @PostMapping(value = "/rule/save")
     @PostMapping(value = "/rule/save")
-    public String ruleSave(@RequestBody ApplyTaskReq req) {
+    public void ruleSave(@RequestBody ApplyTaskReq req) {
         LoginUser user = this.curLoginUser();
         LoginUser user = this.curLoginUser();
-        applyTaskService.ruleSave(req, user);
-        return "success";
+        applyTaskService.saveRule(req, user);
     }
     }
 
 
     @ApiOperation(value = "预约时段新增/编辑")
     @ApiOperation(value = "预约时段新增/编辑")
     @PostMapping(value = "/time/save")
     @PostMapping(value = "/time/save")
-    public String timeSave() {
-        return "success";
+    public void timeSave(@ApiParam("预约任务ID") @RequestParam Long id,
+            @ApiParam("预约时段json") @RequestParam String timeJson) {
+        List<TimePeriodReq> timeList = JsonHelper.toList(timeJson, TimePeriodReq.class);
+        if (timeList.isEmpty())
+            throw new StatusException("请填写时段");
+        LoginUser user = this.curLoginUser();
+        timePeriodService.saveTimePeriod(user.getId(), id, timeList);
     }
     }
 
 
     @ApiOperation(value = "考试说明新增/编辑")
     @ApiOperation(value = "考试说明新增/编辑")
     @PostMapping(value = "/notice/save")
     @PostMapping(value = "/notice/save")
-    public String noticesave() {
-        return "success";
+    public void noticesave(@ApiParam("预约任务ID") @RequestParam Long id, @ApiParam("考试说明") @RequestParam String notice) {
+        LoginUser user = this.curLoginUser();
+        applyTaskService.saveNotice(user.getId(), id, notice);
     }
     }
 
 
     @ApiOperation(value = "预约任务启用/禁用")
     @ApiOperation(value = "预约任务启用/禁用")
     @PostMapping(value = "/enable")
     @PostMapping(value = "/enable")
-    public String enable() {
-        return "success";
+    public void enable(@ApiParam("预约任务ID") @RequestParam Long id, @ApiParam("预约任务的状态") @RequestParam Boolean enable) {
+        LoginUser user = this.curLoginUser();
+        applyTaskService.enable(user.getId(), id, enable);
     }
     }
 
 
-    public static void main(String[] args) {
-        System.out.println(System.currentTimeMillis());
-    }
 }
 }

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

@@ -10,7 +10,6 @@ import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -135,7 +134,7 @@ public class StudentApplyController extends BaseController {
     }
     }
 
 
     @ApiOperation(value = "打印签到表")
     @ApiOperation(value = "打印签到表")
-    @GetMapping(value = "/std/auto/sign/in/print")
+    @PostMapping(value = "/std/auto/sign/in/print")
     public void printSignIn(@ApiParam("教学点ID") @RequestParam Long teachingId,
     public void printSignIn(@ApiParam("教学点ID") @RequestParam Long teachingId,
             @ApiParam("考点ID") @RequestParam(required = false) Long agentId) {
             @ApiParam("考点ID") @RequestParam(required = false) Long agentId) {
         LoginUser user = this.curLoginUser();
         LoginUser user = this.curLoginUser();

+ 6 - 5
src/main/java/com/qmth/exam/reserve/dao/ApplyTaskDao.java

@@ -1,23 +1,24 @@
 package com.qmth.exam.reserve.dao;
 package com.qmth.exam.reserve.dao;
 
 
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
-import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
+import com.qmth.exam.reserve.bean.task.ApplyTaskPageReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.TimePeriodVO;
 import com.qmth.exam.reserve.bean.task.TimePeriodVO;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
 
 
 public interface ApplyTaskDao extends BaseMapper<ApplyTaskEntity> {
 public interface ApplyTaskDao extends BaseMapper<ApplyTaskEntity> {
 
 
     CurrentApplyTaskVO currentApplyTask(@Param("orgId") Long orgId);
     CurrentApplyTaskVO currentApplyTask(@Param("orgId") Long orgId);
 
 
-    IPage<ApplyTaskVO> page(Page<ApplyTaskVO> page, @Param(value = "req") ApplyTaskReq req);
+    IPage<ApplyTaskVO> page(Page<ApplyTaskVO> page, @Param(value = "req") ApplyTaskPageReq req);
 
 
     ApplyTaskRuleVO find(Long id);
     ApplyTaskRuleVO find(Long id);
 
 

+ 7 - 1
src/main/java/com/qmth/exam/reserve/enums/EventType.java

@@ -9,7 +9,13 @@ public enum EventType {
 
 
     CANCEL_APPLY("取消预约"),
     CANCEL_APPLY("取消预约"),
 
 
-    DELETE_APPLY("删除预约");
+    DELETE_APPLY("删除预约"),
+
+    SAVE_TIME_PERIOD("保存编辑考试时段"),
+
+    SAVE_NOTICE("保存编辑考试时段"),
+
+    ENABLE_APPLY_TASK("开启禁用预约任务");
 
 
     private String name;
     private String name;
 
 

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

@@ -7,17 +7,18 @@ import com.qmth.boot.core.collection.PageResult;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
 import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
+import com.qmth.exam.reserve.bean.task.ApplyTaskPageReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 
 
 public interface ApplyTaskService extends IService<ApplyTaskEntity> {
 public interface ApplyTaskService extends IService<ApplyTaskEntity> {
 
 
-    PageResult<ApplyTaskVO> page(ApplyTaskReq req);
+    PageResult<ApplyTaskVO> page(ApplyTaskPageReq req);
 
 
     ApplyTaskVO find(Long id);
     ApplyTaskVO find(Long id);
 
 
-    void ruleSave(ApplyTaskReq req, LoginUser user);
+    void saveRule(ApplyTaskReq req, LoginUser user);
 
 
     List<CategoryVO> listTask();
     List<CategoryVO> listTask();
 
 
@@ -27,4 +28,8 @@ public interface ApplyTaskService extends IService<ApplyTaskEntity> {
 
 
     ApplyTaskEntity findApplyTask();
     ApplyTaskEntity findApplyTask();
 
 
+    void saveNotice(Long userId, Long id, String notice);
+
+    void enable(Long userId, Long id, Boolean enable);
+
 }
 }

+ 5 - 0
src/main/java/com/qmth/exam/reserve/service/TimePeriodService.java

@@ -1,8 +1,13 @@
 package com.qmth.exam.reserve.service;
 package com.qmth.exam.reserve.service;
 
 
+import java.util.List;
+
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.exam.reserve.bean.applytask.TimePeriodReq;
 import com.qmth.exam.reserve.entity.TimePeriodEntity;
 import com.qmth.exam.reserve.entity.TimePeriodEntity;
 
 
 public interface TimePeriodService extends IService<TimePeriodEntity> {
 public interface TimePeriodService extends IService<TimePeriodEntity> {
 
 
+    void saveTimePeriod(Long userId, Long id, List<TimePeriodReq> timeList);
+
 }
 }

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

@@ -1,5 +1,13 @@
 package com.qmth.exam.reserve.service.impl;
 package com.qmth.exam.reserve.service.impl;
 
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+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.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -10,24 +18,25 @@ import com.qmth.boot.core.exception.StatusException;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
 import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
+import com.qmth.exam.reserve.bean.task.ApplyTaskPageReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.dao.ApplyTaskDao;
 import com.qmth.exam.reserve.dao.ApplyTaskDao;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
+import com.qmth.exam.reserve.enums.EventType;
 import com.qmth.exam.reserve.service.ApplyTaskService;
 import com.qmth.exam.reserve.service.ApplyTaskService;
+import com.qmth.exam.reserve.service.OperateLogService;
 import com.qmth.exam.reserve.util.PageUtil;
 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
 @Service
 public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEntity> implements ApplyTaskService {
 public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEntity> implements ApplyTaskService {
 
 
+    @Autowired
+    private OperateLogService logService;
+
     @Override
     @Override
-    public PageResult<ApplyTaskVO> page(ApplyTaskReq req) {
+    public PageResult<ApplyTaskVO> page(ApplyTaskPageReq req) {
         IPage<ApplyTaskVO> iPage = this.baseMapper.page(new Page<ApplyTaskVO>(req.getPageNumber(), req.getPageSize()),
         IPage<ApplyTaskVO> iPage = this.baseMapper.page(new Page<ApplyTaskVO>(req.getPageNumber(), req.getPageSize()),
                 req);
                 req);
         return PageUtil.of(iPage);
         return PageUtil.of(iPage);
@@ -44,17 +53,10 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
     }
     }
 
 
     @Override
     @Override
-    public void ruleSave(ApplyTaskReq req, LoginUser user) {
+    public void saveRule(ApplyTaskReq req, LoginUser user) {
         checkRule(req);
         checkRule(req);
         ApplyTaskEntity task = new ApplyTaskEntity();
         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());
+        BeanUtils.copyProperties(req, task);
         task.setEnable(Boolean.FALSE);
         task.setEnable(Boolean.FALSE);
         task.setOrgId(user.getOrgId());
         task.setOrgId(user.getOrgId());
         this.saveOrUpdate(task);
         this.saveOrUpdate(task);
@@ -75,6 +77,12 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
             throw new StatusException("请填写开放式预约起始时间");
             throw new StatusException("请填写开放式预约起始时间");
         if (StringUtils.isEmpty(req.getOpenApplyEndTime()))
         if (StringUtils.isEmpty(req.getOpenApplyEndTime()))
             throw new StatusException("请填写开放式预约截止时间");
             throw new StatusException("请填写开放式预约截止时间");
+        if (req.getSelfApplyStartTime() >= req.getSelfApplyEndTime())
+            throw new StatusException("第一阶段起始时间必须小于截止时间");
+        if (req.getOpenApplyStartTime() >= req.getOpenApplyEndTime())
+            throw new StatusException("第三阶段起始时间必须小于截止时间");
+        if (req.getSelfApplyEndTime() >= req.getOpenApplyStartTime())
+            throw new StatusException("第三阶段的时间必须在第一阶段结束之后");
     }
     }
 
 
     @Override
     @Override
@@ -118,4 +126,34 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
         return baseMapper.selectOne(wrapper);
         return baseMapper.selectOne(wrapper);
     }
     }
 
 
+    @Override
+    public void saveNotice(Long userId, Long id, String notice) {
+        ApplyTaskEntity task = checkTask(id);
+        task.setNotice(notice);
+        this.updateById(task);
+        logService.insertOperateLog(userId, EventType.SAVE_NOTICE, null);
+    }
+
+    @Override
+    public void enable(Long userId, Long id, Boolean enable) {
+        ApplyTaskEntity task = checkTask(id);
+        if (enable) {
+            LambdaQueryWrapper<ApplyTaskEntity> query = new LambdaQueryWrapper<>();
+            query.eq(ApplyTaskEntity::getEnable, Boolean.TRUE);
+            ApplyTaskEntity existTask = this.getOne(query);
+            if (existTask != null)
+                throw new StatusException("只能有一个任务是开启状态");
+        }
+        task.setEnable(enable);
+        updateById(task);
+        logService.insertOperateLog(userId, EventType.ENABLE_APPLY_TASK, null);
+    }
+
+    private ApplyTaskEntity checkTask(Long id) {
+        ApplyTaskEntity task = getById(id);
+        if (task == null)
+            throw new StatusException("预约任务不存在");
+        return task;
+    }
+
 }
 }

+ 30 - 4
src/main/java/com/qmth/exam/reserve/service/impl/TimePeriodServiceImpl.java

@@ -1,17 +1,43 @@
 package com.qmth.exam.reserve.service.impl;
 package com.qmth.exam.reserve.service.impl;
 
 
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.core.exception.StatusException;
+import com.qmth.exam.reserve.bean.applytask.TimePeriodReq;
 import com.qmth.exam.reserve.dao.TimePeriodDao;
 import com.qmth.exam.reserve.dao.TimePeriodDao;
+import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.TimePeriodEntity;
 import com.qmth.exam.reserve.entity.TimePeriodEntity;
+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.TimePeriodService;
 import com.qmth.exam.reserve.service.TimePeriodService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
 
 
 @Service
 @Service
 public class TimePeriodServiceImpl extends ServiceImpl<TimePeriodDao, TimePeriodEntity> implements TimePeriodService {
 public class TimePeriodServiceImpl extends ServiceImpl<TimePeriodDao, TimePeriodEntity> implements TimePeriodService {
 
 
-    private static final Logger log = LoggerFactory.getLogger(TimePeriodServiceImpl.class);
+    @Autowired
+    private ApplyTaskService taskService;
+
+    @Autowired
+    private OperateLogService logService;
 
 
+    @Override
+    public void saveTimePeriod(Long userId, Long id, List<TimePeriodReq> timeList) {
+        ApplyTaskEntity task = taskService.getById(id);
+        if (task == null)
+            throw new StatusException("预约任务不存在!");
+        for (TimePeriodReq time : timeList) {
+            TimePeriodEntity timePeriod = new TimePeriodEntity();
+            BeanUtils.copyProperties(time, timePeriod);
+            timePeriod.setApplyTaskId(id);
+            this.saveOrUpdate(timePeriod);
+        }
+        logService.insertOperateLog(userId, EventType.SAVE_TIME_PERIOD, null);
+    }
 
 
 }
 }