
import { request } from '../request';

export interface BookPageQuestionAddInput {
  bookId: number;
  bookPageId: number;
  no: string;
  type: number;
  score: number;
  subjectId?: number;
  answerTime: number;
}

export interface BookReviewInput {
  bookId: number;
  bookPageId: number;
  id?: number; // questionId
  [key: string]: any;
}

export interface QuestionFromInfo {
  [key: string]: any;
}

export interface BookPageQuestion {
  id: number;
  type?: number;
  [key: string]: any;
}

export interface QuestionsImages {
  [key: string]: any;
}

export interface BookCatalog {
  name: string;
  type: number;
  url?: string;
}

export interface BookCatalogImportInput {
  bookId: number;
  bookCatalogs: BookCatalog[];
  index: number;
  pdfUrl: string;
}

export interface BookBaseData {
  width?: number;
  height?: number;
}

export interface CatalogTree {
  id: number;
  name: string;
  type: number;
  verifyStatus?: number;
  childs?: CatalogTree[];
  [key: string]: any;
}

export function importBookPageAxios(data: BookCatalogImportInput) {
  return request<any>({
    url: '/admin/v1/book/page/import',
    method: 'post',
    data,
  });
}

export function editBookCatalogAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/catalog/edit',
    method: 'post',
    data,
  });
}

export function getBookCatalogTreeAxios(params: { bookId: number }) {
  return request<any>({
    url: '/admin/v1/book/catalog/tree',
    method: 'get',
    params,
  });
}

export function getBookBaseInfoAxios(params: { id: number }) {
  return request<any>({
    url: '/admin/v1/book/base/info',
    method: 'get',
    params,
  });
}

export function getBookPageDetailAxios(params: { pageId: number }) {
  return request<any>({
    url: '/admin/v1/book/page/detail',
    method: 'get',
    params,
  });
}

export function setStartPageAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/page/start/set',
    method: 'post',
    data,
  });
}

export function addBookQuestionAxios(data: BookPageQuestionAddInput) {
  return request<any>({
    url: '/admin/v1/book/question/add',
    method: 'post',
    data,
  });
}

export function delBookQuestionAxios(id: number) {
  return request<any>({
    url: `/admin/v1/book/question/delete`,
    method: 'post',
    data: { id },
  });
}

export function updateBookPageLayoutAxios(data: { id: number; layout: string; questionsImages?: any[] }) {
  return request<any>({
    url: '/admin/v1/book/page/layout/update',
    method: 'post',
    data,
  });
}

export function getQuestionInfoAxios(id: number) {
  return request<any>({
    url: `/admin/v1/book/question/info`,
    method: 'get',
    params: { id },
  });
}

export function editQuestionInfoAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/question/edit',
    method: 'post',
    data,
  });
}

export function getQuestionBankNavAxios() {
  return request<any>({
    url: '/admin/v1/book/question/nav',
    method: 'get',
  });
}

export function getKnowledgePointDetailsAxios(params: any) {
  return request<any>({
    url: '/admin/v1/knowledge/point/details',
    method: 'get',
    params,
  });
}

export function updateKeywordAnalysisAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/question/analysis/update',
    method: 'post',
    data,
  });
}

export function releaseTaskAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/task/release',
    method: 'post',
    data,
  });
}

export function fetchBookCategoryList(params: any) {
  return request<any>({
    url: '/admin/v1/book/category/list',
    method: 'post', // Assuming post based on usage pattern, or get? Original didn't specify method in prop, usually list is get or post. Let's assume post for list with search params.
    data: params,
  });
}

export function addBookAreaAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/area/add',
    method: 'post',
    data,
  });
}

export function updateBookAreaAxios(data: any) {
  return request<any>({
    url: '/admin/v1/book/area/update',
    method: 'post',
    data,
  });
}

export function delBookAreaAxios(id: number) {
  return request<any>({
    url: '/admin/v1/book/area/delete',
    method: 'post',
    data: { id },
  });
}

export function fetchSubjectList(params: any) {
  return request<any>({
    url: '/admin/v1/subject/pagelist',
    method: 'post',
    data: params,
  });
}
