import request from '@/axios'
import type { classList, classUp, configList, classConfigUp } from './types'
import { REQUEST_BASE } from '@/constants'

export const getClass = (params: classList): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/config_class`, params })
}
export const addClass = (params: classUp) => {
  return request.post({ url: `${REQUEST_BASE}/config_class`, data: params })
}
export const delClass = (params: { id: number }) => {
  return request.delete({ url: `${REQUEST_BASE}/config_class/${params.id}` })
}
export const putClassStatus = (params) => {
  return request.put({
    url: `${REQUEST_BASE}/config_class/set_status/${params.id}/${params.status}`
  })
}
export const putClass = (params: classUp) => {
  return request.put({ url: `${REQUEST_BASE}/config_class/${params.id}`, data: params })
}
export const getClassConfigList = (params: configList): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/config`, params })
}

export const addClassConfig = (params: classConfigUp) => {
  return request.post({ url: `${REQUEST_BASE}/config`, data: params })
}
export const delClassConfig = (params: { id: number }) => {
  return request.delete({ url: `${REQUEST_BASE}/config/${params.id}` })
}
export const putClassConfigStatus = (params: { id: number; status: number }) => {
  return request.put({
    url: `${REQUEST_BASE}/config/set_status/${params.id}/${params.status}`
  })
}
export const putClassConfig = (params: classConfigUp) => {
  return request.put({ url: `${REQUEST_BASE}/config/${params.id}`, data: params })
}
export const getHeaderBasics = (params: { pid: number }) => {
  return request.get({ url: `${REQUEST_BASE}/config/header_basics`, params })
}
export const getClassConfig = (params: { id: number }): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/config/read/${params.id}` })
}
export const configSave = (data): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/config/save`, data })
}
