|
|
@@ -2,14 +2,13 @@ package com.qy.worksheetsystem.controller;
|
|
|
|
|
|
import com.qy.worksheetsystem.model.MessageResult;
|
|
|
import com.qy.worksheetsystem.model.MessageResultV2;
|
|
|
-import com.qy.worksheetsystem.service.WorkCalendarService;
|
|
|
-import com.qy.worksheetsystem.service.YunzhijiaService;
|
|
|
import com.qy.worksheetsystem.util.DateUtil;
|
|
|
import com.qy.worksheetsystem.util.JWTUtil;
|
|
|
-import com.qy.worksheetsystem.vo.WorkCalendarVo;
|
|
|
-import io.swagger.annotations.*;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -35,9 +34,6 @@ import java.util.Map;
|
|
|
@Api(value = "工作日历",tags="工作日历")
|
|
|
public class WorkCalendarController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private WorkCalendarService workCalendarService;
|
|
|
-
|
|
|
@ApiOperation(value = "获取工作日历")
|
|
|
@GetMapping("/getWorkCalendar")
|
|
|
@ApiImplicitParams({
|
|
|
@@ -45,24 +41,29 @@ public class WorkCalendarController {
|
|
|
@ApiImplicitParam(name="startDate",value="开始日期",required=true,paramType="query",dataType="String"),
|
|
|
@ApiImplicitParam(name="endDate",value="结束日期",required=true,paramType="query",dataType="String"),
|
|
|
})
|
|
|
-
|
|
|
public MessageResult getWorkCalendar(@RequestHeader("token") String token, String startDate, String endDate) throws ParseException {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String number = JWTUtil.getCacheNumber(token);
|
|
|
+ String number = JWTUtil.getNumber(token);
|
|
|
if(StringUtils.isEmpty(number)){
|
|
|
- return MessageResultV2.error("token异常");
|
|
|
+ return MessageResult.error("token异常");
|
|
|
+ }
|
|
|
+ if (DateUtil.isValidDate(startDate, endDate) == false) {
|
|
|
+ return MessageResult.error("请输入正确的日期时间,日期格式例如2022-01-01");
|
|
|
}
|
|
|
- int isValid = DateUtil.isValidDate(startDate, endDate);
|
|
|
|
|
|
- if (isValid== 1) {
|
|
|
- return MessageResultV2.error("请输入正确的日期时间,日期格式例如2022-01-01");
|
|
|
- }else if (isValid== 2){
|
|
|
- return MessageResultV2.error("开始时间不能大于结束时间");
|
|
|
+ Date start = sdf.parse(startDate);
|
|
|
+ Date end = sdf.parse(endDate);
|
|
|
+
|
|
|
+ if (start.getTime() > end.getTime()) {
|
|
|
+ return MessageResult.error("开始时间不能大于结束时间");
|
|
|
}
|
|
|
|
|
|
- List<WorkCalendarVo> list = workCalendarService.getWorkCalendar(startDate,endDate);
|
|
|
- MessageResultV2<List<WorkCalendarVo>> messageResult= MessageResultV2.success();
|
|
|
- messageResult.setData(list);
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("startDate", startDate);
|
|
|
+ map.put("endDate", endDate);
|
|
|
+
|
|
|
+ MessageResultV2 messageResult= MessageResultV2.success();
|
|
|
+ messageResult.setData(map);
|
|
|
return messageResult;
|
|
|
}
|
|
|
}
|