Browse Source

节假日模块完善优化

dev_ycq
21819 2 years ago
parent
commit
9121850671
  1. 93
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java
  2. 4
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
  3. 4
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/UserController.java
  4. 9
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java
  5. 10
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayDTO.java
  6. 2
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormData.java
  7. 2
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormPage.java
  8. 3
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailPageInfo.java
  9. 2
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/PageSet.java
  10. 2
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormData.java
  11. 2
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormPage.java
  12. 4
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserPageInfo.java
  13. 11
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Holiday.java
  14. 3
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java
  15. 17
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java
  16. 40
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java
  17. 4
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java

93
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java

@ -1,16 +1,18 @@
package com.biutag.outeradmin.controller;
import com.biutag.core.AjaxResult;
import com.biutag.outeradmin.model.vo.HolidayVo;
import com.biutag.outeradmin.entity.Holiday;
import com.biutag.outeradmin.dto.HolidayDTO;
import com.biutag.outeradmin.mapper.HolidayMapper;
import com.biutag.outeradmin.service.HolidayService;
import com.biutag.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RequiredArgsConstructor
@RestController
@ -18,42 +20,59 @@ import java.util.Map;
@RequestMapping("/outer/holiday")
public class HolidayController {
private final HolidayService holidayService;
private final HolidayMapper holidayMapper;
@RequestMapping("/getholiday")
@ApiOperation("查询节假日")
public AjaxResult getlist(@RequestParam("search") String search) throws Exception {
// @RequestMapping("/getholiday")
// @ApiOperation("查询节假日")
// public AjaxResult getlist(@RequestParam("search") String search) throws Exception {
//
// //判断年份
// LocalDateTime currentDate = LocalDateTime.now();
// int currentyear = currentDate.getYear();
// if (Integer.parseInt(search) != currentyear) {
// return AjaxResult.success();
// }
// Map<String, List<HolidayVo>> map = holidayService.showholiday();
// return AjaxResult.success(map);
//
// }
//
//
// @PostMapping("/saveholiday")
// @ApiOperation("节假日")
// public AjaxResult setlist(@RequestBody String search) throws Exception {
// LocalDateTime currentDate = LocalDateTime.now();
// int currentyear = currentDate.getYear();
// if (Integer.parseInt(search) != currentyear) {
// return AjaxResult.success();
// }
// holidayService.saveholiday(search);
// return AjaxResult.success();
//
// }
//判断年份
LocalDateTime currentDate = LocalDateTime.now();
int currentyear = currentDate.getYear();
if (Integer.parseInt(search) != currentyear) {
return AjaxResult.success();
}
Map<String, List<HolidayVo>> map = holidayService.showholiday();
return AjaxResult.success(map);
}
@PostMapping("/saveholiday")
@ApiOperation("节假日")
public AjaxResult setlist(@RequestBody String search) throws Exception {
LocalDateTime currentDate = LocalDateTime.now();
int currentyear = currentDate.getYear();
if (Integer.parseInt(search) != currentyear) {
return AjaxResult.success();
}
holidayService.saveholiday(search);
return AjaxResult.success();
}
@RequestMapping("/showholiday")
@RequestMapping("/show-holiday")
@ApiOperation("进入页面显示节假日")
public AjaxResult getlist() throws Exception {
Map<String, List<HolidayVo>> map = holidayService.showholiday();
return AjaxResult.success(map);
public List<HolidayDTO> getlist() throws Exception {
List<Holiday> holidayList = holidayService.list();
List<HolidayDTO> result = new ArrayList<>();
for (Holiday holiday : holidayList) {
if (holiday.getHolidayFlag().equals("Y")) {
HolidayDTO holidayDTO = new HolidayDTO();
holidayDTO.setHolidayFlag(holiday.getHolidayFlag());
holidayDTO.setDetail(holiday.getDetail());
holidayDTO.setDate(holiday.getDate());
result.add(holidayDTO);
} else if (holiday.getHolidayFlag().equals("N") && StringUtils.isNotEmpty(holiday.getDetail())) {
HolidayDTO holidayDTO = new HolidayDTO();
holidayDTO.setHolidayFlag(holiday.getHolidayFlag());
holidayDTO.setDetail(holiday.getDetail());
holidayDTO.setDate(holiday.getDate());
result.add(holidayDTO);
}
}
return result;
}

4
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java

@ -4,6 +4,10 @@ import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.outeradmin.dto.MailFormData;
import com.biutag.outeradmin.dto.MailFormPage;
import com.biutag.outeradmin.dto.MailPageInfo;
import com.biutag.outeradmin.dto.PageSet;
import com.biutag.outeradmin.entity.*;
import com.biutag.outeradmin.mapper.MailMapper;
import com.biutag.outeradmin.service.MailService;

4
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/UserController.java

@ -4,6 +4,10 @@ import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.outeradmin.dto.PageSet;
import com.biutag.outeradmin.dto.UserFormData;
import com.biutag.outeradmin.dto.UserFormPage;
import com.biutag.outeradmin.dto.UserPageInfo;
import com.biutag.outeradmin.entity.*;
import com.biutag.outeradmin.mapper.UserMapper;
import com.biutag.outeradmin.service.UserService;

9
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java

@ -1,14 +1,11 @@
package com.biutag.outeradmin.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 管理员
*/
@ -17,13 +14,9 @@ import java.io.Serializable;
@NoArgsConstructor
@AllArgsConstructor
public class Holiday implements Serializable {
@TableId(type = IdType.AUTO)
@TableId(type = IdType.AUTO)
private Integer id;
private String date;
private String holiday_flag;
private String detail;
}

10
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayDTO.java

@ -0,0 +1,10 @@
package com.biutag.outeradmin.dto;
import lombok.Data;
@Data
public class HolidayDTO {
private String date;
private String holidayFlag;
private String detail;
}

2
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormData.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormData.java

@ -1,4 +1,4 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import lombok.Data;

2
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormPage.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormPage.java

@ -1,4 +1,4 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import lombok.Data;

3
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailPageInfo.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailPageInfo.java

@ -1,5 +1,6 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import com.biutag.outeradmin.entity.Mail;
import lombok.Data;
import java.util.List;

2
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/PageSet.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/PageSet.java

@ -1,4 +1,4 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import lombok.Data;

2
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormData.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormData.java

@ -1,4 +1,4 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import lombok.Data;

2
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormPage.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormPage.java

@ -1,4 +1,4 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import lombok.Data;

4
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserPageInfo.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserPageInfo.java

@ -1,5 +1,7 @@
package com.biutag.outeradmin.entity;
package com.biutag.outeradmin.dto;
import com.biutag.outeradmin.dto.PageSet;
import com.biutag.outeradmin.entity.User;
import lombok.Data;
import java.util.List;

11
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Holiday.java

@ -0,0 +1,11 @@
package com.biutag.outeradmin.entity;
import lombok.Data;
@Data
public class Holiday {
private Integer id;
private String date;
private String holidayFlag;
private String detail;
}

3
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java

@ -2,8 +2,7 @@ package com.biutag.outeradmin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.entity.user.User;
import com.biutag.outeradmin.domain.Holiday;
import com.biutag.outeradmin.entity.Holiday;
import org.apache.ibatis.annotations.Mapper;
@Mapper

17
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java

@ -1,15 +1,10 @@
package com.biutag.outeradmin.service;
import com.biutag.outeradmin.domain.Holiday;
import com.biutag.outeradmin.model.vo.HolidayVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outeradmin.entity.Holiday;
import com.biutag.outeradmin.mapper.HolidayMapper;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public interface HolidayService {
List<Holiday> getholiday(String search) throws IOException;
void saveholiday(String search) throws IOException;
Map<String,List<HolidayVo>> showholiday();
@Service
public class HolidayService extends ServiceImpl<HolidayMapper, Holiday> {
}

40
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java

@ -1,40 +0,0 @@
package com.biutag.outeradmin.service.impl;
import com.biutag.outeradmin.domain.Holiday;
import com.biutag.outeradmin.mapper.HolidayMapper;
import com.biutag.outeradmin.model.vo.HolidayVo;
import com.biutag.outeradmin.service.HolidayService;
import com.biutag.outeradmin.utils.HolidayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@Service
public class HolidayServiceImpl implements HolidayService {
@Autowired
private HolidayMapper holidayMapper;
@Override
public List<Holiday> getholiday(String search) throws IOException {
return HolidayUtil.getAllHolidayByYear(search);
}
public Map<String,List<HolidayVo>> showholiday() {
List<Holiday> list = holidayMapper.selectList(null);
return HolidayUtil.HolidayHandle(list);
}
@Override
public void saveholiday(String search) throws IOException {
holidayMapper.delete(null);
List<Holiday> list = HolidayUtil.getAllHolidayByYear(search);
for(Holiday holiday :list){
holidayMapper.insert(holiday);
}
}
}

4
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/utils/HolidayUtil.java → mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java

@ -1,4 +1,4 @@
package com.biutag.outeradmin.utils;
package com.biutag.outeradmin.util;
import com.biutag.outeradmin.domain.Holiday;
@ -11,10 +11,8 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
Loading…
Cancel
Save