diff --git a/src/main/java/cn/com/tenlion/controller/api/examplan/ExamPlanController.java b/src/main/java/cn/com/tenlion/controller/api/examplan/ExamPlanController.java index 14ea2d7..c5975d8 100644 --- a/src/main/java/cn/com/tenlion/controller/api/examplan/ExamPlanController.java +++ b/src/main/java/cn/com/tenlion/controller/api/examplan/ExamPlanController.java @@ -15,6 +15,7 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -98,7 +99,7 @@ public class ExamPlanController extends DefaultBaseController { @ApiOperation(value = "考试计划列表", notes = "考试计划列表接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("list") - public List list() { + public List list() throws ParseException { Map params = requestParams(); return examPlanService.list(params); } @@ -113,7 +114,7 @@ public class ExamPlanController extends DefaultBaseController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpage") - public SuccessResultList> listPage(ListPage page) { + public SuccessResultList> listPage(ListPage page) throws ParseException { Map params = requestParams(); page.setParams(params); return examPlanService.listPage(page); diff --git a/src/main/java/cn/com/tenlion/controller/app/api/examplan/ExamPlanAppController.java b/src/main/java/cn/com/tenlion/controller/app/api/examplan/ExamPlanAppController.java index f7acc7d..a5b4c32 100644 --- a/src/main/java/cn/com/tenlion/controller/app/api/examplan/ExamPlanAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/api/examplan/ExamPlanAppController.java @@ -15,6 +15,7 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -88,7 +89,7 @@ public class ExamPlanAppController extends DefaultBaseController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("list") - public List list(@RequestHeader("token") String token) { + public List list(@RequestHeader("token") String token) throws ParseException { Map params = requestParams(); return examPlanService.list(params); } @@ -104,7 +105,7 @@ public class ExamPlanAppController extends DefaultBaseController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpageexamplan") - public SuccessResultList> listPage(@RequestHeader("token") String token, ListPage page) { + public SuccessResultList> listPage(@RequestHeader("token") String token, ListPage page) throws ParseException { Map params = requestParams(); params.put("token", token); page.setParams(params); diff --git a/src/main/java/cn/com/tenlion/controller/resource/examplan/ExamPlanResourceController.java b/src/main/java/cn/com/tenlion/controller/resource/examplan/ExamPlanResourceController.java index bac1ddc..67d2ebe 100644 --- a/src/main/java/cn/com/tenlion/controller/resource/examplan/ExamPlanResourceController.java +++ b/src/main/java/cn/com/tenlion/controller/resource/examplan/ExamPlanResourceController.java @@ -15,6 +15,7 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -88,7 +89,7 @@ public class ExamPlanResourceController extends DefaultBaseController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("list") - public List list() { + public List list() throws ParseException { Map params = requestParams(); return examPlanService.list(params); } @@ -104,7 +105,7 @@ public class ExamPlanResourceController extends DefaultBaseController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpage") - public SuccessResultList> listPage(ListPage page) { + public SuccessResultList> listPage(ListPage page) throws ParseException { Map params = requestParams(); page.setParams(params); return examPlanService.listPage(page); diff --git a/src/main/java/cn/com/tenlion/service/examplan/IExamPlanService.java b/src/main/java/cn/com/tenlion/service/examplan/IExamPlanService.java index f8fc8f3..a12394e 100644 --- a/src/main/java/cn/com/tenlion/service/examplan/IExamPlanService.java +++ b/src/main/java/cn/com/tenlion/service/examplan/IExamPlanService.java @@ -7,6 +7,7 @@ import cn.com.tenlion.pojo.vos.examplan.ExamPlanVO; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.SuccessResultList; +import java.text.ParseException; import java.util.List; import java.util.Map; @@ -151,7 +152,7 @@ public interface IExamPlanService { * @param params * @return */ - List list(Map params); + List list(Map params) throws ParseException; /** * 考试计划列表 @@ -175,7 +176,7 @@ public interface IExamPlanService { * @param page * @return */ - SuccessResultList> listPage(ListPage page); + SuccessResultList> listPage(ListPage page) throws ParseException; /** * 考试计划统计 diff --git a/src/main/java/cn/com/tenlion/service/examplan/impl/ExamPlanServiceImpl.java b/src/main/java/cn/com/tenlion/service/examplan/impl/ExamPlanServiceImpl.java index afadf9a..960ee68 100644 --- a/src/main/java/cn/com/tenlion/service/examplan/impl/ExamPlanServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/examplan/impl/ExamPlanServiceImpl.java @@ -30,6 +30,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -231,12 +234,15 @@ public class ExamPlanServiceImpl extends DefaultBaseService implements IExamPlan } @Override - public List list(Map params) { + public List list(Map params) throws ParseException { String[] examPlanIds = params.get("examPlanIdList") == null ? null : params.get("examPlanIdList").toString().split(","); params.put("examPlanIdList", examPlanIds); List list = examPlanDao.list(params); String token = params.get("token") == null ? null : params.get("token").toString(); if(null != list && list.size() > 0) { + // 获取当前时间,判断是否到了报名截至日期 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nowTime = simpleDateFormat.format(new Date()); for(ExamPlanDTO examPlanDTO: list) { examPlanDTO.setBtnStatus("确认报考"); Integer count = Integer.valueOf(examPlanDTO.getExamCount()); @@ -281,6 +287,13 @@ public class ExamPlanServiceImpl extends DefaultBaseService implements IExamPlan examPlanDTO.setBtnStatus("暂停申报"); } } + String endTime = examPlanDTO.getEndTime(); + // 时间比较 + Date nowDate = simpleDateFormat.parse(nowTime); + Date endDate = simpleDateFormat.parse(endTime); + if(nowDate.getTime() <= endDate.getTime()) { + examPlanDTO.setBtnStatus("报名截止"); + } } } return list; @@ -297,7 +310,7 @@ public class ExamPlanServiceImpl extends DefaultBaseService implements IExamPlan } @Override - public SuccessResultList> listPage(ListPage page) { + public SuccessResultList> listPage(ListPage page) throws ParseException { PageHelper.startPage(page.getPage(), page.getRows()); List examPlanDTOs = list(page.getParams()); PageInfo pageInfo = new PageInfo<>(examPlanDTOs);