package incheon.ags.ias.userRole.service;

import incheon.ags.ias.userRole.vo.UserRoleSearchVO;
import incheon.ags.ias.userRole.vo.UserRoleVO;

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

public interface UserRoleService {
    List<Map<String,Object>> selectUserRoleList(UserRoleSearchVO userRoleSearchVO) throws Exception;
    int selectUserRoleCnt(UserRoleSearchVO searchVO) 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);

    /**
     * 사용자가 특정 시스템에서 자동 할당받은 역할 코드 목록 조회
     * (FRST_REG_ID = 'SYSTEM')
     */
    List<String> selectAutoAssignRoleCodes(UserRoleVO userRoleVO);

    /**
     * 사용자 역할 전체 교체 (기존 만료 + 신규 할당)
     *
     * @param userId 대상 사용자 ID
     * @param sysCd 시스템 코드
     * @param roleCdList 새로운 역할 목록
     * @param aplyBgngYmd 역할 시작일
     * @param aplyEndYmd 역할 종료일
     * @param rvwOpnnCn 검토의견(수정사유)
     * @param atchFileId 첨부파일ID
     * @return 신청 일련번호 (APLY_SN)
     */
    Long replaceUserRoles(String userId, String sysCd, List<String> roleCdList, String aplyBgngYmd, String aplyEndYmd, String rvwOpnnCn, String atchFileId) throws Exception;

    /**
     * 신청 상세 역할 목록 조회 (팝업용)
     *
     * @param aplySn 신청 일련번호
     * @return 역할 목록
     */
    List<Map<String, Object>> selectUserRoleAplyDetail(Long aplySn) throws Exception;

    /**
     * 사용자+시스템별 가장 최근 승인된 신청 정보 조회 (프리셋용)
     *
     * @param userRoleVO userId, sysCd 필수
     * @return 최근 신청 정보 (시작일, 종료일, 수정사유, 첨부파일ID)
     */
    Map<String, Object> selectLatestUserRoleAply(UserRoleVO userRoleVO) throws Exception;

    /**
     * 사용자의 시스템별 보유 역할 상세 조회 (직접 부여된 역할 포함)
     *
     * @param userRoleVO userId, sysCd 필수
     * @return 역할 목록
     */
    List<Map<String, Object>> selectUserSysRoleDetail(UserRoleVO userRoleVO) throws Exception;
}
