import { useAjax } from '@/Hook/useAjax'
import {
    getGdtAccountApi, gdtAccountProps, addGdtAccountApi, addGdtAccointProps, editGdtAccountApi, editGdtAccountProps,
    delGdtAccountApi, queryApi, checkGdtAccountGdtApi, checkGdtAccountProps, getQuickAppAccountApi, QuickAppAccout, addQuickAppAccountApi,
    AddQuickAppAccount, editQuickAppAccountApi, EditQuickAppAccount, delQuickAppAccountApi, checkQuickAppAccountApi, CheckQuickAppAccount,
    getKyyListApi, KyyListProps, getResourceOfUserApi, getGdtChangeRecordApi, getAccountChangeRecordApi, editAccountChangeRecordApi, editGdtChangeRecordApi
} from '@/services/operating/accountyyb'

import {
    businessGroup, getBookAll, getPeriodAll, allBook, listByPlatform, lins, resourceChangeRecord, insertCutRecordApi, insetCutProps,
    editCutRecordApi, editCutProps, delCutRecordApi
} from "@/services/operating/book"
import { getAllUser } from "@/services/operating/account"

export default function useAccountyyb() {
    const getGdtAccount = useAjax((params: gdtAccountProps) => getGdtAccountApi(params), { debounceInterval: 200 })
    const addGdtAccount = useAjax((params: addGdtAccointProps) => addGdtAccountApi(params), { msgNmae: '添加' })
    const editGdtAccount = useAjax((params: editGdtAccountProps) => editGdtAccountApi(params), { msgNmae: '编辑' })
    const delGdtAccount = useAjax((params: { gdtAccountIds: string }) => delGdtAccountApi(params), { msgNmae: '删除' })
    const checkGdtAccountGdt = useAjax((params: checkGdtAccountProps) => checkGdtAccountGdtApi(params), { msgNmae: '切号' })
    const getGdtChangeRecord = useAjax((params: { gdtAccountId: number, pageNum: number, pageSize: number }) => getGdtChangeRecordApi(params), { debounceInterval: 200 })
    const editGdtChangeRecord = useAjax((params: { recordId: number, putResourceId: number, beginTime: string, endTime: string }) => editGdtChangeRecordApi(params), { msgNmae: '编辑' })

    const getQuickAppAccount = useAjax((params: QuickAppAccout) => getQuickAppAccountApi(params), { debounceInterval: 200 })
    const addQuickAppAccount = useAjax((params: AddQuickAppAccount) => addQuickAppAccountApi(params), { msgNmae: '添加' })
    const editQuickAppAccount = useAjax((params: EditQuickAppAccount) => editQuickAppAccountApi(params), { msgNmae: '编辑' })
    const delQuickAppAccount = useAjax((params: { quickAppAccountIds: string }) => delQuickAppAccountApi(params), { msgNmae: '删除' })
    const checkQuickAppAccount = useAjax((params: CheckQuickAppAccount) => checkQuickAppAccountApi(params), { msgNmae: '切号' })
    const getAccountChangeRecord = useAjax((params: { quickAppAccountId: number, pageNum: number, pageSize: number }) => getAccountChangeRecordApi(params), { debounceInterval: 200 })
    const editAccountChangeRecord = useAjax((params: { recordId: number, putResourceId: number, beginTime: string, endTime: string }) => editAccountChangeRecordApi(params), { msgNmae: '编辑' })

    const getResource = useAjax((params: { resourceType: string; resourceName: string }) => queryApi(params), { debounceInterval: 800 })
    const getResourceOfUser = useAjax((params: { userId: number, resourceType: 10 | 0 }) => getResourceOfUserApi(params))

    const getKyyList = useAjax((params: KyyListProps) => getKyyListApi(params))
    const businessGroupALL = useAjax(() => businessGroup())//项目组
    const getBookALL = useAjax(() => getBookAll())//书
    const getPeriodALL = useAjax(() => getPeriodAll())//期数
    const allBookCity = useAjax(() => allBook())//书城
    const platformAll = useAjax((platformId: number) => listByPlatform(platformId))//获取账号
    const cutBookPlatform = useAjax((params: any) => lins(params), { msgNmae: '切书切平台' }) //
    const gitCutRecordList = useAjax((params: any) => resourceChangeRecord(params)) //获取记录列表
    const getAllUserList = useAjax(() => getAllUser()) //获取所有用户列表

    const insertCutRecord = useAjax((params: insetCutProps) => insertCutRecordApi(params), { msgNmae: '插入' })
    const editCutRecord = useAjax((params: editCutProps) => editCutRecordApi(params), { msgNmae: '编辑' })
    const delCutRecord = useAjax((id: number) => delCutRecordApi(id), { msgNmae: '删除' })
    return {
        getGdtAccount,
        addGdtAccount,
        editGdtAccount,
        delGdtAccount,
        getResource,
        checkGdtAccountGdt,
        getQuickAppAccount,
        addQuickAppAccount,
        editQuickAppAccount,
        delQuickAppAccount,
        checkQuickAppAccount,
        getKyyList,
        businessGroupALL,
        getBookALL,
        getPeriodALL,
        allBookCity,
        platformAll,
        cutBookPlatform,
        gitCutRecordList,
        getAllUserList,
        insertCutRecord,
        editCutRecord,
        delCutRecord,
        getResourceOfUser,
        getGdtChangeRecord,
        getAccountChangeRecord,
        editAccountChangeRecord,
        editGdtChangeRecord
    }
}