import { useAjax } from '@/Hook/useAjax';
import { listOfPageApi, templateMsgApi, syncTemplateApi, strategyApi, temDelApi, modifyStrategyApi, temPreviewApi } from '@/services/operating/news';

export default function useAtemplate() {
    const getKefuMsgStrategy = useAjax((params: {mpId: string}) => templateMsgApi(params)) 
    const listOfPageAjax = useAjax((params: {mpId?: string, taskName?: string, executionStatus?: number, pageNum: number, pageSize: number}) => listOfPageApi(params))
    const syncTemplateAjax = useAjax((params: {mpId: string}) => syncTemplateApi(params)) 
    const strategyAjax = useAjax((params: {mpId: string, 
        templateId: number, 
        taskName: string, 
        fansAll: boolean, 
        fansFilterTagType?: number,
        fansFilterTagids?: any[]
        contentFields: any[],
        url?: string,
        miniprogramAppid?: string,
        miniprogramPagepath?: string,
        triggerType: number,
        sendTime?: string,
        enabled: boolean,
        isUrl: boolean,
        fansFilterSex?: number}) => strategyApi(params)) 
    const modifyStrategyAjax = useAjax((params: {mpId: string, 
            id: number,
            templateId: number, 
            taskName: string, 
            fansAll: boolean, 
            fansFilterTagType?: number,
            fansFilterTagids?: any[]
            contentFields: any[],
            url?: string,
            miniprogramAppid?: string,
            miniprogramPagepath?: string,
            triggerType: number,
            sendTime?: string,
            enabled: boolean,
            isUrl: boolean,
            fansFilterSex?: number}) => modifyStrategyApi(params), { msgNmae: '修改' }) 
    const temDelAjax = useAjax((params: {id: number}) => temDelApi(params)) 
    const temPreviewAjax = useAjax((params: {mpId: number, 
        fansIds: number,
        templateId: number, 
        taskName: string, 
        fansAll: boolean, 
        fansFilterTagType?: number,
        fansFilterTagids?: any[]
        contentFields: any[],
        url?: string,
        miniprogramAppid?: string,
        miniprogramPagepath?: string,
        triggerType: number,
        sendTime?: string,
        enabled: boolean,
        isUrl: boolean,
        fansFilterSex?: number}) => temPreviewApi(params), { msgNmae: '预览' }) 
    return {
        getKefuMsgStrategy,
        listOfPageAjax,
        syncTemplateAjax,
        strategyAjax,
        temDelAjax,
        modifyStrategyAjax,
        temPreviewAjax
    }
}
