import { useAjax } from '@/Hook/useAjax'
import { data_list, data_label, collects_data, } from '@/services/dataStatistics/dataCenter'
import {
    editLabel, addLabel, getLabelsApi, delLabelApi, getContentListApi, ContentIF,
    addContentsAjax, addContentIF, delContentsAjax, editContentsAjax, editContentIF, collectsApi,
    collectsCancelApi, addMediasAjax, addMediasIF, getMediasListApi, getMediasIF, delMediasAjax, editMediasAjax,
    getIdeasListApi, delIdeasAjax, addIdeasAjax, addIdeasIF, editIdeasAjax, getScDetailApi, setBatchMediasApi, setBatchContentsApi,
    setTagIdeaApi, setTagMediaApi, setTagContentApi
} from '@/services/operating/adMaterial'
import { useModel } from 'umi'

export default function useWxGroupList() {
    const userId  = useModel('@@initialState', model =>model.initialState?.currentUser?.userId)
    const getLabels = useAjax((params: { pageNum: string | number, pageSize: string | number }) => getLabelsApi(params))
    const labelAdd = useAjax((params: { label: string }) => addLabel(params), { msgNmae: '添加' })
    const LabelEdit = useAjax((params: { label: string, id: number }) => editLabel(params), { msgNmae: '修改' })
    const delLabel = useAjax((params: { id: number }) => delLabelApi(params), { msgNmae: '删除' })

    const getContentList = useAjax((params: ContentIF) => getContentListApi(params))
    const addContents = useAjax((params: addContentIF) => addContentsAjax(params), { msgNmae: '添加' })
    const delContents = useAjax((params: { ids: string }) => delContentsAjax(params), { msgNmae: '删除' })
    const editContents = useAjax((params: editContentIF) => editContentsAjax(params), { msgNmae: '修改' })

    const collects = useAjax((params: { contentIds: string, type: number }) => collectsApi(params), { msgNmae: '收藏' })
    const collectsCancel = useAjax((params: { contentIds: string, type: number }) => collectsCancelApi(params), { msgNmae: '取消收藏' })

    const addMedias = useAjax((params: addMediasIF) => addMediasAjax(params), { msgNmae: '添加' })
    const getMediasList = useAjax((params: getMediasIF) => getMediasListApi(params))
    const delMedias = useAjax((params: { ids: string }) => delMediasAjax(params), { msgNmae: '删除' })
    const editMedias = useAjax((params: addMediasIF) => editMediasAjax(params), { msgNmae: '修改' })

    const getIdeasList = useAjax((params: getMediasIF) => getIdeasListApi(params))
    const delIdeas = useAjax((params: { ids: string }) => delIdeasAjax(params), { msgNmae: '删除' })
    const addIdeas = useAjax((params: addIdeasIF) => addIdeasAjax(params), { msgNmae: '添加' })
    const editIdeas = useAjax((params: addIdeasIF) => editIdeasAjax(params), { msgNmae: '修改' })
    const getSmDetail = useAjax((id: number) => getScDetailApi(id))

    /**数据云 */
    const dataList = useAjax((params) => data_list({...params,userId}), { formatResult: true })
    const dataLable = useAjax((params) => data_label({...params,userId}), { formatResult: true })
    const datacollects = useAjax((params) => collects_data({...params,userId}), { msgNmae:'操作' })

    /** 批量修改标签 */
    const setBatchMedias = useAjax((params: {mediaIds: string, labelIds: string}) => setBatchMediasApi(params), { msgNmae: '修改' })
    const setBatchContents = useAjax((params: {mediaIds: string, labelIds: string}) => setBatchContentsApi(params), { msgNmae: '修改' })
    const setTagIdea = useAjax((params: {mediaIds: string, labelIds: string}) => setTagIdeaApi(params), { msgNmae: '修改' })
    const setTagMedia = useAjax((params: {mediaIds: string, labelIds: string}) => setTagMediaApi(params), { msgNmae: '修改' })
    const setTagContent = useAjax((params: {mediaIds: string, labelIds: string}) => setTagContentApi(params), { msgNmae: '修改' })

    return {
        getLabels,
        labelAdd,
        LabelEdit,
        delLabel,
        getContentList,
        addContents,
        delContents,
        editContents,
        collects,
        collectsCancel,
        addMedias,
        getMediasList,
        delMedias,
        editMedias,
        getIdeasList,
        delIdeas,
        addIdeas,
        editIdeas,
        getSmDetail,
        dataList,
        dataLable,
        datacollects,
        setBatchMedias,
        setBatchContents,
        setTagIdea,
        setTagMedia,
        setTagContent
    }
}