package cn.iocoder.yudao.module.bpm.service.oa;

import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAOvertimeItemDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAOvertimeItemMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * 加班申请子表 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class BpmOAOvertimeItemServiceImpl implements BpmOAOvertimeItemService {

    @Resource
    private BpmOAOvertimeItemMapper overtimeItemMapper;

    @Override
    public List<BpmOAOvertimeItemDO> getByOvertimeId(Long overtimeId) {
        return overtimeItemMapper.selectList(new LambdaQueryWrapper<BpmOAOvertimeItemDO>()
                .eq(BpmOAOvertimeItemDO::getOaOvertimeId, overtimeId));
    }

    @Override
    public List<BpmOAOvertimeItemDO> getByOvertimeIds(List<Long> overtimeIds) {
        if (CollectionUtil.isEmpty(overtimeIds)) {
            return Collections.emptyList();
        }
        return overtimeItemMapper.selectList(new LambdaQueryWrapper<BpmOAOvertimeItemDO>()
                .in(BpmOAOvertimeItemDO::getOaOvertimeId, overtimeIds));
    }
}
