package cn.iocoder.lyzsys.module.tjt.dal.mysql.employeeyearcostbudget;

import cn.iocoder.lyzsys.framework.common.pojo.PageResult;
import cn.iocoder.lyzsys.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.lyzsys.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.lyzsys.module.tjt.controller.admin.employeeyearcostbudget.vo.EmployeeYearCostBudgetPageReqVO;
import cn.iocoder.lyzsys.module.tjt.dal.dataobject.employeeyearcostbudget.EmployeeYearCostBudgetDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface EmployeeYearCostBudgetMapper extends BaseMapperX<EmployeeYearCostBudgetDO> {

    default PageResult<EmployeeYearCostBudgetDO> selectPage(EmployeeYearCostBudgetPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EmployeeYearCostBudgetDO>()
                .eqIfPresent(EmployeeYearCostBudgetDO::getEmployeeId, reqVO.getEmployeeId())
                .likeIfPresent(EmployeeYearCostBudgetDO::getEmployeeName, reqVO.getEmployeeName())
                .eqIfPresent(EmployeeYearCostBudgetDO::getBudgetYear, reqVO.getBudgetYear())
                .eqIfPresent(EmployeeYearCostBudgetDO::getEnabledFlag, reqVO.getEnabledFlag())
                .orderByDesc(EmployeeYearCostBudgetDO::getBudgetYear)
                .orderByAsc(EmployeeYearCostBudgetDO::getSortNo)
                .orderByAsc(EmployeeYearCostBudgetDO::getId));
    }

    default EmployeeYearCostBudgetDO selectByEmployeeIdAndBudgetYear(Long employeeId, Integer budgetYear) {
        return selectOne(new LambdaQueryWrapperX<EmployeeYearCostBudgetDO>()
                .eq(EmployeeYearCostBudgetDO::getEmployeeId, employeeId)
                .eq(EmployeeYearCostBudgetDO::getBudgetYear, budgetYear));
    }

    default List<EmployeeYearCostBudgetDO> selectListByBudgetYear(Integer budgetYear) {
        return selectList(new LambdaQueryWrapperX<EmployeeYearCostBudgetDO>()
                .eq(EmployeeYearCostBudgetDO::getBudgetYear, budgetYear));
    }

    default Long selectCountByEmployeeId(Long employeeId) {
        return selectCount(new LambdaQueryWrapperX<EmployeeYearCostBudgetDO>()
                .eq(EmployeeYearCostBudgetDO::getEmployeeId, employeeId));
    }

}
