import { useAjax } from '@/Hook/useAjax'
import {
    ListType, getPlanListApi, getTotalCostApi, getPlanCostApi, getCostSpeedApi, getUserGroupApi, getAllPlanListApi,
    allPlanProps, getDetailListApi, getMinuteListApi, downLoadUpAdApi, downLoadDetailApi,
    downLoadDetailMinuteApi, downLoadSpeedApi, downLoadAllAdListApi, addEditGroupApi, getAdGroupListApi, deleteAdGroupApi, 
    getAccountListApi, AccountListProps, addDelAccountApi, getBookListAllApi, getCostTopListApi, getCostTrendListApi, getListForHourApi, getColumnTrendApi, getAdTotalDataApi, getListForAdApi, getCostTrendV3ListApi, getCostTopV3ListApi, getListForHourV3Api, getColumnTrendV3Api, getAdTotalDataV3Api, getListForAdV3Api
} from '@/services/adMonitor/adMonitor'
import { getAdAccountApi } from '@/services/launchAdq/adAuthorize'


export default function useMonitor() {
    /** 获取起量计划列表 */
    const getPlanList = useAjax((params: ListType) => getPlanListApi(params), { formatResult: true, debounceInterval: 1000 })
    /**获取起来计划列表明细*/
    const getPlanDetailList = useAjax((params: ListType) => getDetailListApi(params), { formatResult: true, debounceInterval: 100 })
    /**获取起来计划列表5min*/
    const getMinuteList = useAjax((params: ListType) => getMinuteListApi(params), { formatResult: true, debounceInterval: 100 })
    /** 获取今日计划总消耗图谱 */
    const getTotalCost = useAjax((params: ListType) => getTotalCostApi(params), { formatResult: true })
    /** 获取计划消耗图谱 */
    const getPlanCost = useAjax((params: ListType) => getPlanCostApi(params), { formatResult: true })
    /** 获取消耗速度详情(弹窗) */
    const getCostSpeed = useAjax((params: ListType) => getCostSpeedApi(params), { formatResult: true })
    /** 获取组员 */
    const getUserGroup = useAjax(() => getUserGroupApi(), { formatResult: true })
    /** 计划列表 */
    const getAllPlanList = useAjax((params: allPlanProps) => getAllPlanListApi(params), { formatResult: true, debounceInterval: 1000 })
    const getBookListAll = useAjax(() => getBookListAllApi(), { formatResult: true })
    /** 下载 */
    const downLoadUpAd = useAjax((params: ListType) => downLoadUpAdApi(params), { formatResult: true })
    const downLoadDetail = useAjax((params: ListType) => downLoadDetailApi(params), { formatResult: true })
    const downLoadDetailMinute = useAjax((params: ListType) => downLoadDetailMinuteApi(params), { formatResult: true })
    const downLoadSpeed = useAjax((params: ListType) => downLoadSpeedApi(params), { formatResult: true })
    const downLoadAllAdList = useAjax((params: allPlanProps) => downLoadAllAdListApi(params), { formatResult: true })
    // 监控数据源
    const addEditGroup = useAjax((params: { groupName: string, id?: number, remark?: string }) => addEditGroupApi(params), { formatResult: true })
    const getAdGroupList = useAjax(() => getAdGroupListApi(), { formatResult: true })
    const deleteAdGroup = useAjax((params: { id: number }) => deleteAdGroupApi(params), { formatResult: true })
    const getAccountList = useAjax((params: AccountListProps) => getAccountListApi(params), { formatResult: true })
    const addDelAccount = useAjax((params: { accountIdList: number[], groupId: number, type: 0 | 1 }) => addDelAccountApi(params), { formatResult: true })

    // 获取广告账号列表
    const getAdqAccountList = useAjax(() => getAdAccountApi(), { formatResult: true })

    // NEW
    const getListForHour = useAjax((params) => getListForHourApi(params), { formatResult: true, debounceInterval: 100 })
    const getCostTrendList = useAjax((params: ListType) => getCostTrendListApi(params), { formatResult: true })
    const getCostTopList = useAjax((params: ListType) => getCostTopListApi(params), { formatResult: true })
    const getColumnTrend = useAjax((params) => getColumnTrendApi(params), { formatResult: true })
    const getAdTotalData = useAjax((params) => getAdTotalDataApi(params), { formatResult: true })
    const getListForAd = useAjax((params) => getListForAdApi(params), { formatResult: true })

    // 3.0
    const getListForHourV3 = useAjax((params) => getListForHourV3Api(params), { formatResult: true, debounceInterval: 100 })
    const getCostTrendV3List = useAjax((params: ListType) => getCostTrendV3ListApi(params), { formatResult: true })
    const getCostTopV3List = useAjax((params: ListType) => getCostTopV3ListApi(params), { formatResult: true })
    const getColumnTrendV3 = useAjax((params) => getColumnTrendV3Api(params), { formatResult: true })
    const getAdTotalDataV3 = useAjax((params) => getAdTotalDataV3Api(params), { formatResult: true })
    const getListForAdV3 = useAjax((params) => getListForAdV3Api(params), { formatResult: true })


    return {
        getPlanList,
        getTotalCost,
        getCostTrendList,
        getPlanCost,
        getCostTopList,
        getCostSpeed,
        getUserGroup,
        getAllPlanList,
        getPlanDetailList,
        getListForHour,
        getMinuteList,
        downLoadUpAd,
        downLoadDetail,
        downLoadDetailMinute,
        downLoadSpeed,
        downLoadAllAdList,
        addEditGroup,
        getAdGroupList,
        deleteAdGroup,
        getAccountList,
        addDelAccount,
        getBookListAll,
        getAdqAccountList,
        getColumnTrend,
        getAdTotalData,
        getListForAd,
        getListForHourV3,
        getCostTrendV3List,
        getCostTopV3List,
        getColumnTrendV3,
        getAdTotalDataV3,
        getListForAdV3
    }
}