package jnpf.personnels.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.model.personnels.dto.audit.FtbPersonnelsAuditSubConfigVO;
import jnpf.model.personnels.dto.config.MasterConfigUserBoudDto;
import jnpf.model.personnels.po.FtbPersonnelsAuditSubConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface FtbPersonnelsAuditSubConfigMapper extends BaseMapper<FtbPersonnelsAuditSubConfig> {

    List<FtbPersonnelsAuditSubConfig> queryInitializeExecutionNode(@Param("orgId") String orgId,
                                      @Param("type") Integer type,
                                       @Param("isOnePersonPasses")Integer isOnePersonPasses);

    FtbPersonnelsAuditSubConfigVO queryAuditSubConfig(@Param("orgId")String orgId,
                                                      @Param("userId") String userId,
                                                      @Param("configType")Integer configType);

    List<Map<String, Object>> isItAnApprover(@Param("userId") String userId);
    @Select("SELECT\n" +
            "\tCOUNT(\n" +
            "\tsub.F_Id) AS coun \n" +
            "FROM\n" +
            "\tftb_personnels_audit_master_config AS mas\n" +
            "\tINNER JOIN ftb_personnels_audit_sub_config AS sub ON mas.F_Id = sub.F_MasterId \n" +
            "WHERE\n" +
            "\tmas.F_EnableMark = '0' \n" +
            "\tAND sub.F_AuditorId = #{userId}")
    Long checkWhetherTheCurrentPersonIsTheApprover(@Param("userId") String userId);

    List<MasterConfigUserBoudDto> queryUserBound(String userId);
}