package incheon.ags.ias.userRole.mapper;

import incheon.ags.ias.userRole.vo.UserRoleSearchVO;
import incheon.ags.ias.userRole.vo.UserRoleVO;
import incheon.com.config.annotation.MainDB;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;

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

@org.egovframe.rte.psl.dataaccess.mapper.Mapper @incheon.com.config.annotation.MainDB
public interface UserRoleMapper {
    List<Map<String, Object>> selectUserRoleList(UserRoleSearchVO userRoleSearchVO) throws Exception;
    int selectUserRoleCnt(UserRoleSearchVO userRoleSearchVO) throws Exception;
    List<Map<String, Object>> selectUserRole(UserRoleVO userRoleVO) throws Exception;
    List<Map<String, Object>> selectUserRoleHistory(UserRoleVO userRoleVO) throws Exception;
    List<Map<String, Object>> selectUserRoleHistoryForPaging(UserRoleVO userRoleVO) throws Exception;
    int selectUserRoleHistoryCnt(UserRoleVO userRoleVO) throws Exception;
    UserRoleVO selectUserRoleDetail(UserRoleVO userRoleVO) throws Exception;
    List<Map<String, Object>> selectSysListWithRoleCnt(UserRoleVO userRoleVO) throws Exception;
    List<Map<String, Object>> selectRoleListBySys(String sysCd) throws Exception;
    List<String> selectUserRoleCodes(UserRoleVO userRoleVO);
    List<String> selectAutoAssignRoleCodes(UserRoleVO userRoleVO);
    int insertUserRole(UserRoleVO userRoleVO);
    int deleteUserRole(UserRoleVO userRoleVO);

    // 전체 교체용 메서드
    int deleteUserRolesBySystem(Map<String, Object> params);  // 시스템별 권한 전체 삭제
    int expireUserRoleAplyMst(Map<String, Object> params);    // 기존 신청 만료 처리
    Long insertUserRoleAplyMst(Map<String, Object> params);   // 신청 마스터 INSERT
    int insertUserRoleAplyDtl(Map<String, Object> params);    // 신청 상세 단건 INSERT

    // 신청 상세 역할 목록 조회 (팝업용)
    List<Map<String, Object>> selectUserRoleAplyDetail(Long aplySn);

    // 사용자+시스템별 가장 최근 승인된 신청 정보 조회 (프리셋용)
    Map<String, Object> selectLatestUserRoleAply(UserRoleVO userRoleVO);

    // 사용자의 시스템별 보유 역할 상세 조회 (직접 부여된 역할 포함)
    List<Map<String, Object>> selectUserSysRoleDetail(UserRoleVO userRoleVO);
}