package cn.iocoder.yudao.module.hrm.dal.mysql.salary; 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.hrm.controller.admin.salary.vo.HrmEmployeeSocialSecurityPageReqVO; import cn.iocoder.yudao.module.hrm.dal.dataobject.salary.HrmEmployeeSocialSecurityDO; import org.apache.ibatis.annotations.Mapper; import java.util.Collection; import java.util.List; /** * 部门社保公积金档案 Mapper * * @author 超级管理员 */ @Mapper public interface HrmEmployeeSocialSecurityMapper extends BaseMapperX { default HrmEmployeeSocialSecurityDO selectLatestByDeptId(Long deptId) { return selectOne(new LambdaQueryWrapperX() .eq(HrmEmployeeSocialSecurityDO::getDeptId, deptId) .eq(HrmEmployeeSocialSecurityDO::getStatus, 0) .orderByDesc(HrmEmployeeSocialSecurityDO::getEffectiveDate) .last("LIMIT 1")); } /** * 批量查询多个部门各自最新生效的档案,用于薪酬核算时避免逐员工查询 */ default List selectListByDeptIds(Collection deptIds) { return selectList(new LambdaQueryWrapperX() .inIfPresent(HrmEmployeeSocialSecurityDO::getDeptId, deptIds) .eq(HrmEmployeeSocialSecurityDO::getStatus, 0) .orderByDesc(HrmEmployeeSocialSecurityDO::getEffectiveDate)); } default List selectListByDeptId(Long deptId) { return selectList(new LambdaQueryWrapperX() .eq(HrmEmployeeSocialSecurityDO::getDeptId, deptId) .orderByDesc(HrmEmployeeSocialSecurityDO::getEffectiveDate)); } default PageResult selectPage(HrmEmployeeSocialSecurityPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(HrmEmployeeSocialSecurityDO::getDeptId, reqVO.getDeptId()) .eqIfPresent(HrmEmployeeSocialSecurityDO::getStatus, reqVO.getStatus()) .eqIfPresent(HrmEmployeeSocialSecurityDO::getEffectiveDate, reqVO.getEffectiveDate()) .orderByDesc(HrmEmployeeSocialSecurityDO::getId)); } }