import http from '@/utils/http'
import { AppDispatch } from '..'
import { A4AddType } from '@/types/api/A4news'

/**
 * 资讯-删除
 */
export const A4_APIdel = (id: number) => {
  return http.post(`museum/information/del/${id}`)
}

/**
 * 资讯-获取详情
 */
export const A4_APIgetInfo = (id: number) => {
  return http.post(`museum/information/info/${id}`)
}

/**
 * 资讯 新增
 */
export const A4_APIadd = (data: A4AddType) => {
  return http.post('museum/information/add', data)
}

/**
 * 资讯 修改
 */
export const A4_APIedit = (data: A4AddType) => {
  return http.post('museum/information/edit', data)
}

/**
 * 资讯-发布
 */
export const A4_APIpublish = (id: number) => {
  return http.post(`museum/information/publish`, { informationId: id })
}

/**
 * 资讯-发布
 */
export const A4_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('museum/information/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }
      dispatch({ type: 'A4/getList', payload: obj })
    }
  }
}
