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
54
55
56
57
58
59
package cn.iocoder.yudao.module.hrm.dal.mysql.salary;
 
import cn.hutool.core.collection.CollUtil;
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.HrmSalaryPaymentDetailPageReqVO;
import cn.iocoder.yudao.module.hrm.dal.dataobject.salary.HrmSalaryPaymentDetailDO;
import org.apache.ibatis.annotations.Mapper;
 
import java.util.Collection;
import java.util.Collections;
import java.util.List;
 
/**
 * 薪资发放明细 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface HrmSalaryPaymentDetailMapper extends BaseMapperX<HrmSalaryPaymentDetailDO> {
 
    default PageResult<HrmSalaryPaymentDetailDO> selectPage(HrmSalaryPaymentDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HrmSalaryPaymentDetailDO>()
                .eqIfPresent(HrmSalaryPaymentDetailDO::getPaymentId, reqVO.getPaymentId())
                .eqIfPresent(HrmSalaryPaymentDetailDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HrmSalaryPaymentDetailDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(HrmSalaryPaymentDetailDO::getStatus, reqVO.getStatus())
                .orderByAsc(HrmSalaryPaymentDetailDO::getUserId));
    }
 
    default List<HrmSalaryPaymentDetailDO> selectListByPaymentId(Long paymentId) {
        return selectList(HrmSalaryPaymentDetailDO::getPaymentId, paymentId);
    }
 
    default List<HrmSalaryPaymentDetailDO> selectListByPaymentIdAndStatus(Long paymentId, Integer status) {
        return selectList(new LambdaQueryWrapperX<HrmSalaryPaymentDetailDO>()
                .eq(HrmSalaryPaymentDetailDO::getPaymentId, paymentId)
                .eq(HrmSalaryPaymentDetailDO::getStatus, status));
    }
 
    default HrmSalaryPaymentDetailDO selectByCalculationId(Long calculationId) {
        return selectOne(HrmSalaryPaymentDetailDO::getCalculationId, calculationId);
    }
 
    /**
     * 批量查询:哪些核算单已被工资发放明细引用
     *
     * 用于删除核算单前做引用保护,避免发放明细变成孤儿数据。
     */
    default List<HrmSalaryPaymentDetailDO> selectListByCalculationIds(Collection<Long> calculationIds) {
        if (CollUtil.isEmpty(calculationIds)) {
            return Collections.emptyList();
        }
        return selectList(new LambdaQueryWrapperX<HrmSalaryPaymentDetailDO>()
                .in(HrmSalaryPaymentDetailDO::getCalculationId, calculationIds));
    }
 
}