From 9121850671ab7c87892fdec49cf4fa9c396dca84 Mon Sep 17 00:00:00 2001 From: 21819 Date: Wed, 24 Jan 2024 14:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E5=81=87=E6=97=A5=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HolidayController.java | 93 +++++++++++-------- .../outeradmin/controller/MailController.java | 4 + .../outeradmin/controller/UserController.java | 4 + .../com/biutag/outeradmin/domain/Holiday.java | 11 +-- .../com/biutag/outeradmin/dto/HolidayDTO.java | 10 ++ .../{entity => dto}/MailFormData.java | 2 +- .../{entity => dto}/MailFormPage.java | 2 +- .../{entity => dto}/MailPageInfo.java | 3 +- .../outeradmin/{entity => dto}/PageSet.java | 2 +- .../{entity => dto}/UserFormData.java | 2 +- .../{entity => dto}/UserFormPage.java | 2 +- .../{entity => dto}/UserPageInfo.java | 4 +- .../com/biutag/outeradmin/entity/Holiday.java | 11 +++ .../outeradmin/mapper/HolidayMapper.java | 3 +- .../outeradmin/service/HolidayService.java | 17 ++-- .../service/impl/HolidayServiceImpl.java | 40 -------- .../{utils => util}/HolidayUtil.java | 4 +- 17 files changed, 105 insertions(+), 109 deletions(-) create mode 100644 mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayDTO.java rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/MailFormData.java (88%) rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/MailFormPage.java (76%) rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/MailPageInfo.java (64%) rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/PageSet.java (78%) rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/UserFormData.java (83%) rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/UserFormPage.java (76%) rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{entity => dto}/UserPageInfo.java (54%) create mode 100644 mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Holiday.java delete mode 100644 mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java rename mailbox-outer-admin/src/main/java/com/biutag/outeradmin/{utils => util}/HolidayUtil.java (98%) diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java index 2052058..c0006a8 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java +++ b/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> 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> 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> map = holidayService.showholiday(); - return AjaxResult.success(map); + public List getlist() throws Exception { + List holidayList = holidayService.list(); + List 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; } diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java index 222151b..76f2e55 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/UserController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/UserController.java index 5013a5a..3b9264b 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/UserController.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java index 577afe5..6fc5644 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java +++ b/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; - -} +} \ No newline at end of file diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayDTO.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayDTO.java new file mode 100644 index 0000000..e8d5973 --- /dev/null +++ b/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; +} diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormData.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormData.java similarity index 88% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormData.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormData.java index dd1c408..3fdabc0 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormData.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormPage.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormPage.java similarity index 76% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormPage.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailFormPage.java index a5b93fd..4cf9db8 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailFormPage.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailPageInfo.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailPageInfo.java similarity index 64% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailPageInfo.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailPageInfo.java index a8f8b36..db725dc 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailPageInfo.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/PageSet.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/PageSet.java similarity index 78% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/PageSet.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/PageSet.java index 0cad16e..3bbca4e 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/PageSet.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormData.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormData.java similarity index 83% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormData.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormData.java index f0c2e39..317a994 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormData.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormPage.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormPage.java similarity index 76% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormPage.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserFormPage.java index 2703a4d..3b5358a 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserFormPage.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserPageInfo.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserPageInfo.java similarity index 54% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserPageInfo.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/UserPageInfo.java index 54384c4..fcea549 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/UserPageInfo.java +++ b/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; diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Holiday.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Holiday.java new file mode 100644 index 0000000..9ab7eaa --- /dev/null +++ b/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; +} diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java index 147dc6e..99eb796 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java +++ b/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 diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java index 215414b..f7de197 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java +++ b/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 getholiday(String search) throws IOException; - void saveholiday(String search) throws IOException; - Map> showholiday(); +@Service +public class HolidayService extends ServiceImpl { } diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java deleted file mode 100644 index 3e363b5..0000000 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java +++ /dev/null @@ -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 getholiday(String search) throws IOException { - return HolidayUtil.getAllHolidayByYear(search); - } - public Map> showholiday() { - List list = holidayMapper.selectList(null); - return HolidayUtil.HolidayHandle(list); - } - @Override - public void saveholiday(String search) throws IOException { - holidayMapper.delete(null); - List list = HolidayUtil.getAllHolidayByYear(search); - for(Holiday holiday :list){ - holidayMapper.insert(holiday); - } - } - - -} diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/utils/HolidayUtil.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java similarity index 98% rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/utils/HolidayUtil.java rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java index 933db8c..3a23b83 100644 --- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/utils/HolidayUtil.java +++ b/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.*;