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

/**
 *图书分类-树
 */

export const A2_APIgetList1 = (): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get('cms/storage/getTree')
    if (res.code === 0) {
      dispatch({ type: 'A2/getTree', payload: res.data })
      // console.log(123, res)
    }
  }
}
/**
 * 图书分类-删除
 */
export const A2_APIdel1 = (id: number) => {
  return http.get(`cms/storage/remove/${id}`)
}

/**
 * 图书分类-获取详情
 */
export const A2_APIgetInfo1 = (id: number) => {
  return http.get(`cms/storage/detail/${id}`)
}

/**
 * 图书分类-新增、编辑
 */
export const A2_APIsave1 = (data: any) => {
  return http.post('cms/storage/save', data)
}

// -------------------展示分类--------------------

/**
 *展示分类-列表
 */

export const A2_APIgetList2 = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/exhibitType/getList', data)
    if (res.code === 0) {
      const obj = {
        list: res.data,
        total: 50
      }
      dispatch({ type: 'A2/getList', payload: obj })
    }
  }
}

/**
 * 展示分类-删除
 */
export const A2_APIdel2 = (id: number) => {
  return http.get(`cms/exhibitType/remove/${id}`)
}

/**
 * 展示分类-获取详情
 */
export const A2_APIgetInfo2 = (id: number) => {
  return http.get(`cms/exhibitType/detail/${id}`)
}

/**
 * 展示分类-新增、编辑
 */
export const A2_APIsave2 = (data: any) => {
  return http.post('cms/exhibitType/save', data)
}
