package cn.iocoder.yudao.module.system.dal.mysql.holiday.holidaysetting;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.holiday.holidaysetting.vo.HolidaySettingPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.holiday.holidaysetting.vo.HolidaySettingRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.holiday.holidaysetting.HolidaySettingDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 假期设置 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface HolidaySettingMapper extends BaseMapperX<HolidaySettingDO> {

    default PageResult<HolidaySettingDO> selectPage(HolidaySettingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HolidaySettingDO>()
                .likeIfPresent(HolidaySettingDO::getName, reqVO.getName())
                .eqIfPresent(HolidaySettingDO::getSalaryFlag, reqVO.getSalaryFlag())
                .eqIfPresent(HolidaySettingDO::getMinUnit, reqVO.getMinUnit())
                .eqIfPresent(HolidaySettingDO::getRoundFlag, reqVO.getRoundFlag())
                .eqIfPresent(HolidaySettingDO::getRoundDirection, reqVO.getRoundDirection())
                .eqIfPresent(HolidaySettingDO::getRoundUnit, reqVO.getRoundUnit())
                .eqIfPresent(HolidaySettingDO::getCalculationMethod, reqVO.getCalculationMethod())
                .betweenIfPresent(HolidaySettingDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HolidaySettingDO::getId));
    }

    /**
     * 获取列表
     *
     * @param vo
     * @param page
     * @return
     */
    IPage<HolidaySettingDO> getHolidaySettingPage(@Param("vo") HolidaySettingPageReqVO vo, @Param("page") Page page);

    /**
     * 获取限制余额的假期列表
     *
     * @return
     */
    List<HolidaySettingDO> getLimitBalanceHolidayList();
}
