Browse Source

节假日管理重构

master
laishajiang 2 years ago
parent
commit
76e3315382
  1. 75
      mailbox-lan/src/main/java/com/biutag/lan/controller/system/HolidayController.java
  2. 12
      mailbox-lan/src/main/java/com/biutag/lan/service/HolidayService.java
  3. 10
      mailbox-lan/src/main/java/com/biutag/lan/vo/system/HolidayVo.java

75
mailbox-lan/src/main/java/com/biutag/lan/controller/system/HolidayController.java

@ -1,6 +1,9 @@
package com.biutag.lan.controller.system; package com.biutag.lan.controller.system;
import com.alibaba.fastjson2.JSON;
import com.biutag.entity.system.Holiday;
import com.biutag.lan.aop.Log; import com.biutag.lan.aop.Log;
import com.biutag.lan.service.HolidayService;
import com.biutag.lan.service.IHolidayService; import com.biutag.lan.service.IHolidayService;
import com.biutag.lan.validate.commons.IdValidate; import com.biutag.lan.validate.commons.IdValidate;
import com.biutag.lan.validate.system.HolidayCreateValidate; import com.biutag.lan.validate.system.HolidayCreateValidate;
@ -11,58 +14,48 @@ import com.biutag.lan.vo.system.HolidayListedVo;
import com.biutag.lan.vo.system.HolidayDetailVo; import com.biutag.lan.vo.system.HolidayDetailVo;
import com.biutag.core.AjaxResult; import com.biutag.core.AjaxResult;
import com.biutag.core.PageResult; import com.biutag.core.PageResult;
import com.biutag.lan.vo.system.HolidayVo;
import com.biutag.mapper.system.HolidayMapper;
import com.biutag.util.StringUtils;
import com.biutag.validator.annotation.IDMust; import com.biutag.validator.annotation.IDMust;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@RequiredArgsConstructor
@RestController @RestController
@RequestMapping("api/holiday") @RequestMapping("api/holiday")
@Api(tags = "节假日管理") @Api(tags = "节假日管理")
public class HolidayController { public class HolidayController {
private final HolidayService holidayService;
@Resource private final HolidayMapper holidayMapper;
IHolidayService iHolidayService; @RequestMapping("/show-holiday")
@ApiOperation("进入页面显示节假日")
@GetMapping("/list") public List<HolidayVo> getlist() {
@ApiOperation(value="节假日列表") List<Holiday> holidayList = holidayService.list();
public AjaxResult<PageResult<HolidayListedVo>> list(@Validated PageValidate pageValidate, List<HolidayVo> result = new ArrayList<>();
@Validated HolidaySearchValidate searchValidate) { for (Holiday holiday : holidayList) {
PageResult<HolidayListedVo> list = iHolidayService.list(pageValidate, searchValidate); if (holiday.getHolidayFlag().equals("Y")) {
return AjaxResult.success(list); HolidayVo HolidayVo = new HolidayVo();
} HolidayVo.setHolidayFlag(holiday.getHolidayFlag());
HolidayVo.setDetail(holiday.getDetail());
@GetMapping("/detail") HolidayVo.setDate(holiday.getDate());
@ApiOperation(value="节假日详情") result.add(HolidayVo);
public AjaxResult<HolidayDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) { } else if (holiday.getHolidayFlag().equals("N") && StringUtils.isNotEmpty(holiday.getDetail())) {
HolidayDetailVo detail = iHolidayService.detail(id); HolidayVo HolidayVo = new HolidayVo();
return AjaxResult.success(detail); HolidayVo.setHolidayFlag(holiday.getHolidayFlag());
} HolidayVo.setDetail(holiday.getDetail());
HolidayVo.setDate(holiday.getDate());
@Log(title = "节假日新增") result.add(HolidayVo);
@PostMapping("/add") }
@ApiOperation(value="节假日新增") }
public AjaxResult<Void> add(@Validated @RequestBody HolidayCreateValidate createValidate) { return result;
iHolidayService.add(createValidate);
return AjaxResult.success();
}
@Log(title = "节假日编辑")
@PostMapping("/edit")
@ApiOperation(value="节假日编辑")
public AjaxResult<Void> edit(@Validated @RequestBody HolidayUpdateValidate updateValidate) {
iHolidayService.edit(updateValidate);
return AjaxResult.success();
}
@Log(title = "节假日删除")
@PostMapping("/del")
@ApiOperation(value="节假日删除")
public AjaxResult<Void> del(@Validated @RequestBody IdValidate idValidate) {
iHolidayService.del(idValidate.getId());
return AjaxResult.success();
} }
} }

12
mailbox-lan/src/main/java/com/biutag/lan/service/HolidayService.java

@ -0,0 +1,12 @@
package com.biutag.lan.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.entity.system.Holiday;
import com.biutag.mapper.system.HolidayMapper;
import org.springframework.stereotype.Service;
@Service
public class HolidayService extends ServiceImpl<HolidayMapper, Holiday> {
}

10
mailbox-lan/src/main/java/com/biutag/lan/vo/system/HolidayVo.java

@ -0,0 +1,10 @@
package com.biutag.lan.vo.system;
import lombok.Data;
@Data
public class HolidayVo {
private String date;
private String holidayFlag;
private String detail;
}
Loading…
Cancel
Save