import { get, post, put, del } from '../../http'

/**
 * @description: 获取书籍列表-查询列表
 * @param {*} params
 * @returns {*}
 */
export const getBookList = async (params: Record<string, any>) => {
  return await get<any>('/book/list', params)
}

/**
 * @description: 获取阶段
 * @returns {*}
 */
export const getStageParams = async () => {
  return await get<any>('/sysDictType/listSysDictData/book_stage')
}

/**
 * @description: 获取主题
 * @returns {*}
 */
export const getTopicParams = async () => {
  return await get<any>('/sysDictType/listSysDictData/book_topic')
}

/**
 * @description: 获取类型
 * @returns {*}
 */
export const getTypeParams = async () => {
  return await get<any>('/sysDictType/listSysDictData/book_type')
}

/**
 * @description: 新增书籍
 * @param {*} data
 * @returns {*}
 */
export const addBook = async (data: Record<string, any>) => {
  return await post<any>('/book', data)
}

/**
 * @description: 通过id删除书籍
 * @param {*} id
 * @returns {*}
 */
export const handleDeleteBook = async (id: string) => {
  return await del(`/book/${id}`)
}

/**
 * @description: 获取书籍详情
 * @param {*} id
 * @returns {*}
 */
export const getBookDetailAPI = async (id: string) => {
  return await get<any>(`book/getSeriesOrBookInfo/${id}`)
}

/**
 * @description: 更新书籍
 * @param {*} data
 * @returns {*}
 */
export const handleResetBook = async (data: Record<string, any>) => {
  return await put('/book', data)
}

/**
 * @description: 更新书籍状态
 * @param {*} data
 * @returns {*}
 */
export const updataBookState = async (data: Record<string, any>) => {
  return await put('/book/updateStatus', data)
}

/**
 * @description: 更新书籍审核状态
 * @param {*} data
 * @returns {*}
 */
export const updataBookCensorFlag = async (params: Record<string, any>) => {
  return await post<any>('/book/updateAdminCensorFlag', params)
}
