package cn.iocoder.yudao.module.employee.dal.mysql.employeeinfo;

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.employee.dal.dataobject.employeeinfo.EmployeeInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.employee.controller.admin.employeeinfo.vo.*;

/**
 * 员工信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EmployeeInfoMapper extends BaseMapperX<EmployeeInfoDO> {

    default PageResult<EmployeeInfoDO> selectPage(EmployeeInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EmployeeInfoDO>()
                .eqIfPresent(EmployeeInfoDO::getInfoId, reqVO.getInfoId())
                .eqIfPresent(EmployeeInfoDO::getEmployeeNumber, reqVO.getEmployeeNumber())
                .likeIfPresent(EmployeeInfoDO::getName, reqVO.getName())
                .eqIfPresent(EmployeeInfoDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(EmployeeInfoDO::getPhone, reqVO.getPhone())
                .eqIfPresent(EmployeeInfoDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(EmployeeInfoDO::getEmail, reqVO.getEmail())
                .eqIfPresent(EmployeeInfoDO::getPosition, reqVO.getPosition())
                .eqIfPresent(EmployeeInfoDO::getPostId, reqVO.getPostId())
                .betweenIfPresent(EmployeeInfoDO::getEntryDate, reqVO.getEntryDate())
                .betweenIfPresent(EmployeeInfoDO::getProbationEndDate, reqVO.getProbationEndDate())
                .eqIfPresent(EmployeeInfoDO::getWorkLocation, reqVO.getWorkLocation())
                .eqIfPresent(EmployeeInfoDO::getEmployeeStatus, reqVO.getEmployeeStatus())
                .eqIfPresent(EmployeeInfoDO::getGender, reqVO.getGender())
                .betweenIfPresent(EmployeeInfoDO::getBirthDate, reqVO.getBirthDate())
                .eqIfPresent(EmployeeInfoDO::getMarriageStatus, reqVO.getMarriageStatus())
                .eqIfPresent(EmployeeInfoDO::getIdCardNumber, reqVO.getIdCardNumber())
                .eqIfPresent(EmployeeInfoDO::getIdCardAddress, reqVO.getIdCardAddress())
                .eqIfPresent(EmployeeInfoDO::getHouseholdType, reqVO.getHouseholdType())
                .eqIfPresent(EmployeeInfoDO::getHouseholdLocation, reqVO.getHouseholdLocation())
                .eqIfPresent(EmployeeInfoDO::getEducationLevel, reqVO.getEducationLevel())
                .eqIfPresent(EmployeeInfoDO::getMajor, reqVO.getMajor())
                .eqIfPresent(EmployeeInfoDO::getGraduationSchool, reqVO.getGraduationSchool())
                .betweenIfPresent(EmployeeInfoDO::getGraduationDate, reqVO.getGraduationDate())
                .betweenIfPresent(EmployeeInfoDO::getWorkStartDate, reqVO.getWorkStartDate())
                .eqIfPresent(EmployeeInfoDO::getAnnualLeaveDays, reqVO.getAnnualLeaveDays())
                .eqIfPresent(EmployeeInfoDO::getSalaryBank, reqVO.getSalaryBank())
                .eqIfPresent(EmployeeInfoDO::getSalaryCardNumber, reqVO.getSalaryCardNumber())
                .eqIfPresent(EmployeeInfoDO::getSalary, reqVO.getSalary())
                .eqIfPresent(EmployeeInfoDO::getPositionSalary, reqVO.getPositionSalary())
                .eqIfPresent(EmployeeInfoDO::getProjectAllowance, reqVO.getProjectAllowance())
                .eqIfPresent(EmployeeInfoDO::getSpecialPositionAllowance, reqVO.getSpecialPositionAllowance())
                .eqIfPresent(EmployeeInfoDO::getForeignAllowance, reqVO.getForeignAllowance())
                .eqIfPresent(EmployeeInfoDO::getLunchSubsidy, reqVO.getLunchSubsidy())
                .eqIfPresent(EmployeeInfoDO::getSpecialAllowance, reqVO.getSpecialAllowance())
                .eqIfPresent(EmployeeInfoDO::getSubsidy, reqVO.getSubsidy())
                .eqIfPresent(EmployeeInfoDO::getYearEndBonus, reqVO.getYearEndBonus())
                .eqIfPresent(EmployeeInfoDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(EmployeeInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(EmployeeInfoDO::getUserId, reqVO.getUserId())
                .orderByDesc(EmployeeInfoDO::getId));
    }

    default EmployeeInfoDO getInfo(EmployeeInfoQueryReqVO reqVO) {
        return selectOne(new LambdaQueryWrapperX<EmployeeInfoDO>()
                .eqIfPresent(EmployeeInfoDO::getUserId, reqVO.getUserId())
                .eqIfPresent(EmployeeInfoDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(EmployeeInfoDO::getId));
    }

}