package com.cf.imes.module.system.dal.mysql.process;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
import com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 工序用户表 process_user Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface ProcessUserMapper extends BaseMapperX<ProcessUserDO> {

    default List<ProcessUserDO> selectByProcessId(Long processId,Long organId) {
        return selectList(new LambdaQueryWrapperX<ProcessUserDO>()
                .eq(ProcessUserDO::getProcessId, processId)
                .eq(ProcessUserDO::getOrganId, organId));
    }

    default List<ProcessUserDO> selectByProcessId(Long processId) {
        return selectList(new LambdaQueryWrapperX<ProcessUserDO>()
                .eq(ProcessUserDO::getProcessId, processId));
    }

    default List<ProcessUserDO> selectById(Long processId,Long userId) {
        return selectList(new LambdaQueryWrapperX<ProcessUserDO>()
                .eq(ProcessUserDO::getProcessId, processId)
                .eq(ProcessUserDO::getUserId, userId));
    }

    default ProcessUserDO selectUserByProcessId(Long processId) {
        return selectOne(ProcessUserDO::getProcessId, processId);
    }

    int deleteUserByProcessId(@Param("processId") Long processId);

    ProcessDO selectOneById(@Param("processId") Long processId, @Param("organId") Long organId);
}