假期
This commit is contained in:
@ -170,5 +170,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CONFIG_TYPE_NOT_EXISTS = new ErrorCode(1_004_029_00, "配置类型不存在");
|
||||
|
||||
ErrorCode MONEY_NOT_EXISTS = new ErrorCode(1_004_030_00, "金额不存在");
|
||||
|
||||
ErrorCode HOLIDAY_NOT_EXISTS = new ErrorCode(1_004_031_00, "假期不存在");
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.holiday;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.holiday.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.holiday.HolidayDO;
|
||||
import cn.iocoder.yudao.module.member.service.holiday.HolidayService;
|
||||
|
||||
@Tag(name = "管理后台 - 假期")
|
||||
@RestController
|
||||
@RequestMapping("/member/holiday")
|
||||
@Validated
|
||||
public class HolidayController {
|
||||
|
||||
@Resource
|
||||
private HolidayService holidayService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建假期")
|
||||
@PreAuthorize("@ss.hasPermission('member:holiday:create')")
|
||||
public CommonResult<Long> createHoliday(@Valid @RequestBody HolidaySaveReqVO createReqVO) {
|
||||
return success(holidayService.createHoliday(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新假期")
|
||||
@PreAuthorize("@ss.hasPermission('member:holiday:update')")
|
||||
public CommonResult<Boolean> updateHoliday(@Valid @RequestBody HolidaySaveReqVO updateReqVO) {
|
||||
holidayService.updateHoliday(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除假期")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:holiday:delete')")
|
||||
public CommonResult<Boolean> deleteHoliday(@RequestParam("id") Long id) {
|
||||
holidayService.deleteHoliday(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得假期")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:holiday:query')")
|
||||
public CommonResult<HolidayRespVO> getHoliday(@RequestParam("id") Long id) {
|
||||
HolidayDO holiday = holidayService.getHoliday(id);
|
||||
return success(BeanUtils.toBean(holiday, HolidayRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得假期分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:holiday:query')")
|
||||
public CommonResult<PageResult<HolidayRespVO>> getHolidayPage(@Valid HolidayPageReqVO pageReqVO) {
|
||||
PageResult<HolidayDO> pageResult = holidayService.getHolidayPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, HolidayRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出假期 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('member:holiday:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportHolidayExcel(@Valid HolidayPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<HolidayDO> list = holidayService.getHolidayPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "假期.xls", "数据", HolidayRespVO.class,
|
||||
BeanUtils.toBean(list, HolidayRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.holiday.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HolidayDataVO {
|
||||
|
||||
private Boolean holiday;
|
||||
private String date;
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.holiday.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 假期分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class HolidayPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "是否假期")
|
||||
private Boolean holiday;
|
||||
|
||||
@Schema(description = "中文名", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private String[] date;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.holiday.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 假期 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class HolidayRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30414")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "是否假期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("是否假期")
|
||||
private Boolean holiday;
|
||||
|
||||
@Schema(description = "中文名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("中文名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("日期")
|
||||
private String date;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.holiday.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 假期新增/修改 Request VO")
|
||||
@Data
|
||||
public class HolidaySaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30414")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "是否假期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否假期不能为空")
|
||||
private Boolean holiday;
|
||||
|
||||
@Schema(description = "中文名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "中文名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "日期不能为空")
|
||||
private String date;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.holiday.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class HolidayVO {
|
||||
|
||||
private Integer code;
|
||||
private Map<String, HolidayDataVO> holiday;
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.holiday;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 假期 DO
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@TableName("member_holiday")
|
||||
@KeySequence("member_holiday_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HolidayDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 是否假期
|
||||
*/
|
||||
private Boolean holiday;
|
||||
/**
|
||||
* 中文名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String date;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.holiday;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.holiday.HolidayDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.holiday.vo.*;
|
||||
|
||||
/**
|
||||
* 假期 Mapper
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@Mapper
|
||||
public interface HolidayMapper extends BaseMapperX<HolidayDO> {
|
||||
|
||||
default PageResult<HolidayDO> selectPage(HolidayPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<HolidayDO>()
|
||||
.eqIfPresent(HolidayDO::getHoliday, reqVO.getHoliday())
|
||||
.likeIfPresent(HolidayDO::getName, reqVO.getName())
|
||||
.betweenIfPresent(HolidayDO::getDate, reqVO.getDate())
|
||||
.betweenIfPresent(HolidayDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(HolidayDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package cn.iocoder.yudao.module.member.job;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.holiday.vo.HolidayDataVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.holiday.vo.HolidayVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storebusiness.StoreBusinessDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.business.BusinessMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.storebusiness.StoreBusinessMapper;
|
||||
import cn.iocoder.yudao.module.member.service.holiday.HolidayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:qjq
|
||||
* @Date:2024/4/3 14:50
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HolidayJob implements JobHandler {
|
||||
@Resource
|
||||
private HolidayService holidayService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行任务
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
@TenantIgnore
|
||||
public String execute(String param){
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
// 获取下一年的年份
|
||||
int year = currentDate.getYear();
|
||||
int nextYear = year+ 1;
|
||||
|
||||
|
||||
String s = HttpUtil.get("https://timor.tech/api/holiday/year/"+nextYear);
|
||||
HolidayVO bean = JSONUtil.toBean(s, HolidayVO.class);
|
||||
|
||||
holidayService.getNextYearData(bean);
|
||||
|
||||
log.info("[execute][生成当天统计营业数据 {}条]", 1);
|
||||
return String.format("生成当天统计营业数据 %s 条 ", 1);
|
||||
}
|
||||
|
||||
}
|
@ -490,7 +490,7 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
// BigDecimal moneyByUserId = cardService.getMoneyByUserId(diningPlatesDO.getUserId());
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(diningPlatesDO.getUserId());
|
||||
|
||||
DishesRespDto dish = dishesApi.getDish(dishId);
|
||||
// DishesRespDto dish = dishesApi.getDish(dishId);
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(memberUserDO.getId(), storeId);
|
||||
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||
@ -500,8 +500,8 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
|
||||
AppUserInfo appUserInfo = new AppUserInfo();
|
||||
appUserInfo.setNickname(StrUtil.isNotBlank(memberUserDO.getName())?memberUserDO.getName():memberUserDO.getNickname())
|
||||
.setDishesName(dish.getDishesName())
|
||||
.setDishesBasePrice(dish.getDishesBasePrice()).setDishesSumPrice(dish.getDishesSumPrice())
|
||||
// .setDishesName(dish.getDishesName())
|
||||
// .setDishesBasePrice(dish.getDishesBasePrice()).setDishesSumPrice(dish.getDishesSumPrice())
|
||||
.setMoney(memberUserDO.getWxAmount().add(cashAmount))
|
||||
.setOrderMoney(new BigDecimal(stringRedisTemplate.opsForValue().get(diningPlatesNum+"-"+storeId)))
|
||||
.setReception(memberUserDO.getReception()).setLimitAmount(memberUserDO.getLimitAmount());
|
||||
|
@ -0,0 +1,60 @@
|
||||
package cn.iocoder.yudao.module.member.service.holiday;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.holiday.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.holiday.HolidayDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 假期 Service 接口
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
public interface HolidayService {
|
||||
|
||||
/**
|
||||
* 创建假期
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createHoliday(@Valid HolidaySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新假期
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateHoliday(@Valid HolidaySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除假期
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteHoliday(Long id);
|
||||
|
||||
/**
|
||||
* 获得假期
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 假期
|
||||
*/
|
||||
HolidayDO getHoliday(Long id);
|
||||
|
||||
/**
|
||||
* 获得假期分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 假期分页
|
||||
*/
|
||||
PageResult<HolidayDO> getHolidayPage(HolidayPageReqVO pageReqVO);
|
||||
|
||||
void getNextYearData(HolidayVO vo);
|
||||
/**
|
||||
* 判断今天是否是假期
|
||||
*/
|
||||
Boolean checkHoliday();
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package cn.iocoder.yudao.module.member.service.holiday;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.holiday.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.holiday.HolidayDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.holiday.HolidayMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 假期 Service 实现类
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class HolidayServiceImpl implements HolidayService {
|
||||
|
||||
@Resource
|
||||
private HolidayMapper holidayMapper;
|
||||
|
||||
@Override
|
||||
public Long createHoliday(HolidaySaveReqVO createReqVO) {
|
||||
// 插入
|
||||
HolidayDO holiday = BeanUtils.toBean(createReqVO, HolidayDO.class);
|
||||
holidayMapper.insert(holiday);
|
||||
// 返回
|
||||
return holiday.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHoliday(HolidaySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateHolidayExists(updateReqVO.getId());
|
||||
// 更新
|
||||
HolidayDO updateObj = BeanUtils.toBean(updateReqVO, HolidayDO.class);
|
||||
holidayMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteHoliday(Long id) {
|
||||
// 校验存在
|
||||
validateHolidayExists(id);
|
||||
// 删除
|
||||
holidayMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateHolidayExists(Long id) {
|
||||
if (holidayMapper.selectById(id) == null) {
|
||||
throw exception(HOLIDAY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HolidayDO getHoliday(Long id) {
|
||||
return holidayMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<HolidayDO> getHolidayPage(HolidayPageReqVO pageReqVO) {
|
||||
return holidayMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNextYearData(HolidayVO vo) {
|
||||
if (vo.getCode() == 0) {
|
||||
Map<String, HolidayDataVO> holiday = vo.getHoliday();
|
||||
Collection<HolidayDataVO> values = holiday.values();
|
||||
ArrayList<HolidayDO> add = new ArrayList<>();
|
||||
for (HolidayDataVO value : values) {
|
||||
HolidayDO holidayDO = new HolidayDO();
|
||||
holidayDO.setDate(value.getDate());
|
||||
holidayDO.setName(value.getName());
|
||||
holidayDO.setHoliday(value.getHoliday());
|
||||
add.add(holidayDO);
|
||||
}
|
||||
holidayMapper.insertBatch(add);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkHoliday() {
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// 判断当天是否周末
|
||||
boolean isHoliday = dayOfWeek== DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY;
|
||||
|
||||
//获取假期
|
||||
// 创建 DateTimeFormatter 对象
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
// 将 LocalDate 对象转换为字符串
|
||||
String formattedDate = currentDate.format(formatter);
|
||||
|
||||
HolidayDO holidayDO = holidayMapper.selectOne(new QueryWrapper<HolidayDO>().eq("date", formattedDate).last("LIMIT 1"));
|
||||
if (holidayDO != null) {
|
||||
isHoliday = holidayDO.getHoliday();
|
||||
}
|
||||
return isHoliday;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user