package incheon.ags.ias.common.excel;

import incheon.ags.ias.authrt.vo.AuthrtSearchVO;
import incheon.ags.ias.authrtAplyMng.vo.AuthrtAplyMngSearchVO;
import incheon.ags.ias.cntn.cntnPrst.vo.CntnPrstVO;
import incheon.ags.ias.cntn.cntnStats.vo.CntnStatsVO;
import incheon.ags.ias.role.vo.RoleSearchVO;
import incheon.ags.ias.spceUtlz.vo.SpceUtlzSearchVO;
import incheon.ags.ias.sysMenuAuthrt.vo.SysMenuAuthrtSearchVO;
import incheon.ags.ias.user.vo.UserSearchVO;
import incheon.ags.ias.userRole.vo.UserRoleSearchVO;
import incheon.com.excel.ExcelExportConfig;
import incheon.com.excel.ExcelExportRegistry;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

import javax.annotation.PostConstruct;

/**
 * IAS 업무 엑셀 내보내기 설정
 */
@Configuration
@RequiredArgsConstructor
@Slf4j
@Lazy(false)
public class IasExcelExportConfig {

    private final ExcelExportRegistry excelExportRegistry;

    @PostConstruct
    public void registerExcelExportConfigs() {
        log.info("IAS 엑셀 내보내기 설정 등록");

        // 시스템 메뉴 권한
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("sysMenuAuthrt")
                .service("sysMenuAuthrtService")
                .method("selectSysMenuAuthrtList")
                .searchVo(SysMenuAuthrtSearchVO.class)
                .build());

        // 역할
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("role")
                .service("roleService")
                .method("selectRoleList")
                .searchVo(RoleSearchVO.class)
                .build());

        // 사용자 역할
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("userRole")
                .service("userAuthService")
                .method("selectUserRoleList")
                .searchVo(UserRoleSearchVO.class)
                .build());

        // 사용자
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("user")
                .service("userService")
                .method("selectUserList")
                .searchVo(UserSearchVO.class)
                .build());

        // 권한
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("authrt")
                .service("authrtService")
                .method("selectAuthrtList")
                .searchVo(AuthrtSearchVO.class)
                .build());

        // 권한 신청
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("authrtAplyMng")
                .service("authrtAplyMngService")
                .method("selectUserRoleAplyList")
                .searchVo(AuthrtAplyMngSearchVO.class)
                .build());

        // 공간 활용 (전체)
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("spceUtlz")
                .service("SpceUtlzService")
                .method("selectWeeklyTop10UsersForExcel")
                .searchVo(SpceUtlzSearchVO.class)
                .paging(false)
                .build());

        // 접속 현황 - 일별 (전체)
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("cntnPrst")
                .service("cntnPrstService")
                .method("selectCntnPrstDailyStats")
                .searchVo(CntnPrstVO.class)
                .paging(false)
                .build());

        // 접속 통계 - 시스템별 (전체)
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("cntnStatsSystem")
                .service("cntnStatsService")
                .method("selectSystemWebLog")
                .searchVo(CntnStatsVO.class)
                .paging(false)
                .build());

        // 접속 통계 - 메뉴별
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("cntnStatsMenu")
                .service("cntnStatsService")
                .method("selectMenuWebLog")
                .searchVo(CntnStatsVO.class)
                .build());

        // 접속 통계 - 부서별
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("cntnStatsDept")
                .service("cntnStatsService")
                .method("selectDeptWebLog")
                .searchVo(CntnStatsVO.class)
                .build());

        // 접속 통계 - 사용자별
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("cntnStatsUser")
                .service("cntnStatsService")
                .method("selectUserWebLog")
                .searchVo(CntnStatsVO.class)
                .build());

        // 접속 통계 - 시간대별 (전체)
        excelExportRegistry.register(ExcelExportConfig.builder()
                .type("cntnStatsHour")
                .service("cntnStatsService")
                .method("selectHourlyWebLog")
                .searchVo(CntnStatsVO.class)
                .paging(false)
                .build());
    }
}
