import { useAjax } from '@/Hook/useAjax'
import {
    ListType, getPlanListApi, getTotalCostApi, getPlanCostApi, getCostSpeedApi, getUserGroupApi, getAllPlanListApi,
    allPlanProps, getDetailListApi, getAgencyListApi, getBookListApi, listProps, getMinuteListApi, downLoadUpAdApi, downLoadDetailApi,
    downLoadDetailMinuteApi, downLoadSpeedApi, downLoadAllAdListApi, addEditGroupApi, getAdGroupListApi, deleteAdGroupApi, 
    getAccountListApi, AccountListProps, addDelAccountApi, getBookListAllApi
} from '@/services/launch/adMonitor'


export default function useMonitor() {
    /** 获取起量计划列表 */
    const getPlanList = useAjax((params: ListType) => getPlanListApi(params), { formatResult: true })
    /**获取起来计划列表明细*/
    const getPlanDetailList = useAjax((params: ListType) => getDetailListApi(params), { formatResult: true })
    /**获取起来计划列表5min*/
    const getMinuteList = useAjax((params: ListType) => getMinuteListApi(params), { formatResult: true })
    /** 获取今日计划总消耗图谱 */
    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 })
    const getAgencyList = useAjax((params: listProps) => getAgencyListApi(params), { formatResult: true })
    const getBookList = useAjax((params: listProps) => getBookListApi(params), { formatResult: true })
    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 })
    return {
        getPlanList,
        getTotalCost,
        getPlanCost,
        getCostSpeed,
        getUserGroup,
        getAllPlanList,
        getPlanDetailList,
        getAgencyList,
        getBookList,
        getMinuteList,
        downLoadUpAd,
        downLoadDetail,
        downLoadDetailMinute,
        downLoadSpeed,
        downLoadAllAdList,
        addEditGroup,
        getAdGroupList,
        deleteAdGroup,
        getAccountList,
        addDelAccount,
        getBookListAll
    }
}