gaoluyang
4 天以前 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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<HrmEmployeeSocialSecurityDO> {
 
    default HrmEmployeeSocialSecurityDO selectLatestByDeptId(Long deptId) {
        return selectOne(new LambdaQueryWrapperX<HrmEmployeeSocialSecurityDO>()
                .eq(HrmEmployeeSocialSecurityDO::getDeptId, deptId)
                .eq(HrmEmployeeSocialSecurityDO::getStatus, 0)
                .orderByDesc(HrmEmployeeSocialSecurityDO::getEffectiveDate)
                .last("LIMIT 1"));
    }
 
    /**
     * 批量查询多个部门各自最新生效的档案,用于薪酬核算时避免逐员工查询
     */
    default List<HrmEmployeeSocialSecurityDO> selectListByDeptIds(Collection<Long> deptIds) {
        return selectList(new LambdaQueryWrapperX<HrmEmployeeSocialSecurityDO>()
                .inIfPresent(HrmEmployeeSocialSecurityDO::getDeptId, deptIds)
                .eq(HrmEmployeeSocialSecurityDO::getStatus, 0)
                .orderByDesc(HrmEmployeeSocialSecurityDO::getEffectiveDate));
    }
 
    default List<HrmEmployeeSocialSecurityDO> selectListByDeptId(Long deptId) {
        return selectList(new LambdaQueryWrapperX<HrmEmployeeSocialSecurityDO>()
                .eq(HrmEmployeeSocialSecurityDO::getDeptId, deptId)
                .orderByDesc(HrmEmployeeSocialSecurityDO::getEffectiveDate));
    }
 
    default PageResult<HrmEmployeeSocialSecurityDO> selectPage(HrmEmployeeSocialSecurityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HrmEmployeeSocialSecurityDO>()
                .eqIfPresent(HrmEmployeeSocialSecurityDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(HrmEmployeeSocialSecurityDO::getStatus, reqVO.getStatus())
                .eqIfPresent(HrmEmployeeSocialSecurityDO::getEffectiveDate, reqVO.getEffectiveDate())
                .orderByDesc(HrmEmployeeSocialSecurityDO::getId));
    }
 
}