import { AppDispatch } from '@/store'
import http from '@/utils/http'

/**
 * 分页列表
 */
export const H1_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/show/pageList', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

      dispatch({ type: 'H1/getList', payload: obj })
    }
  }
}

export const H1_APIsave = (data: any): any => {
  return http.post('cms/show/saveEntity', data)
}

export const H1_APIgetInfo = (id: number): any => {
  return http.get(`cms/show/detail/${id}`)
}

export const H1_APIdelete = (id: number): any => {
  return http.get(`cms/show/remove/${id}`)
}

/**
 * 展品清单 - 分页列表
 */
export const H1_APIgetShowGoodPage = (data: any): any => {
  return http.post('cms/show/showGoodPage', data)
}

/**
 * 展位设置 - 更新展区与具体位置
 */
export const H1_APIupdateRegion = (
  data: { id: number; region: string; address: string }[]
): any => {
  return http.post('cms/show/updateRegion', data)
}
