
package org.jeecg.modules.workFlow.flowlong.mybatisplus.impl;

import org.jeecg.modules.workFlow.flowlong.engine.dao.FlwHisTaskActorDao;
import org.jeecg.modules.workFlow.flowlong.engine.entity.FlwHisTaskActor;
import org.jeecg.modules.workFlow.flowlong.engine.entity.FlwTaskActor;
import org.jeecg.modules.workFlow.flowlong.mybatisplus.mapper.FlwHisTaskActorMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import java.util.List;

/**
 * 历史任务参与者数据访问层接口实现类
 *
 * <p>
 * <a href="https://aizuda.com">官网</a>尊重知识产权，不允许非法使用，后果自负，不允许非法使用，后果自负
 * </p>
 *
 * @author hubin
 * @since 1.0
 */
public class FlwHisTaskActorDaoImpl implements FlwHisTaskActorDao {
    private final FlwHisTaskActorMapper hisTaskActorMapper;

    public FlwHisTaskActorDaoImpl(FlwHisTaskActorMapper hisTaskActorMapper) {
        this.hisTaskActorMapper = hisTaskActorMapper;
    }

    @Override
    public boolean insert(FlwHisTaskActor hisTaskActor) {
        return hisTaskActorMapper.insert(hisTaskActor) > 0;
    }

    @Override
    public boolean deleteByInstanceIds(List<Long> instanceIds) {
        return hisTaskActorMapper.delete(Wrappers.<FlwHisTaskActor>lambdaQuery()
                .in(FlwHisTaskActor::getInstanceId, instanceIds)) > 0;
    }

    @Override
    public boolean deleteByTaskId(Long taskId) {
        return hisTaskActorMapper.delete(Wrappers.<FlwHisTaskActor>lambdaQuery()
                .eq(FlwHisTaskActor::getTaskId, taskId)) > 0;
    }

    @Override
    public List<FlwHisTaskActor> selectCcTaskActorsByInstanceId(Long instanceId) {
        return hisTaskActorMapper.selectList(Wrappers.<FlwHisTaskActor>lambdaQuery()
                .eq(FlwHisTaskActor::getInstanceId, instanceId)
                .eq(FlwHisTaskActor::getWeight, 6));
    }

    @Override
    public List<FlwHisTaskActor> selectListByTaskId(Long taskId) {
        return hisTaskActorMapper.selectList(Wrappers.<FlwHisTaskActor>lambdaQuery()
                .eq(FlwHisTaskActor::getTaskId, taskId));
    }

    @Override
    public List<FlwHisTaskActor> selectListByTaskIds(List<Long> taskIds) {
        return hisTaskActorMapper.selectList(Wrappers.<FlwHisTaskActor>lambdaQuery()
                .in(FlwHisTaskActor::getTaskId, taskIds));
    }

    @Override
    public List<FlwHisTaskActor> selectListByTaskIdAndActorId(Long taskId, String actorId) {
        return hisTaskActorMapper.selectList(Wrappers.<FlwHisTaskActor>lambdaQuery()
                .eq(FlwHisTaskActor::getTaskId, taskId)
                .eq(FlwTaskActor::getActorId, actorId));
    }
}
