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

/**
 *课程管理-列表
 */

export const A3_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/subject/pageList', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }
      dispatch({ type: 'A3/getList', payload: obj })
    }
  }
}

/**
 * 课程管理-详情
 */
export const A3_APIgetInfo = (id: number) => {
  return http.get(`cms/subject/detail/${id}`)
}

/**
 * 课程管理-删除
 */
export const A3_APIdel = (id: number) => {
  return http.get(`cms/subject/removes/${id}`)
}

/**
 * 课程管理-新增、修改
 */
export const A3_APIsave = (data: any) => {
  return http.post('cms/subject/save', data)
}

/**
 * 课程管理-类别设置-列表
 */
export const A3_APIgetTypeList = () => {
  return http.get('cms/dict/getList?type=subject')
}

/**
 * 课程管理-类别设置-删除
 */
export const A3_APItypeDel = (id: number) => {
  return http.get(`cms/dict/removes/${id}`)
}

/**
 * 课程管理-类别设置-新增、修改
 */
export const A3_APItypeSave = (data: any) => {
  return http.post('cms/dict/save', { ...data, type: 'subject' })
}
