/*
 * @Author: jixiang
 * @Date: 2021-09-10 19:12:58
 * @Description:
 * @FilePath: /suqian_pc_new/src/api/book.ts
 * One World One Drefeel(56580223@qq.com)
 */
import { HttpResponse } from '@/@type';
import Axios from './axios';

const book = {
  bookRetrieval: '/fighter-library/book/bookRetrieval',
  viewBookDetails: '/fighter-library/book/viewBookDetails',
  getBookTypeDropDown: '/fighter-library/CateRelation/listTopCategory',
  listCategory: '/fighter-library/CateRelation/listChildCategory',
};

interface booklist {
  bookName: string;
  pageNum: number;
  pageSize: number;
  currentCateId: number | string;
}

interface viewParams {
  bookId: number;
}

class UserService {
  // 图书列表
  static async bookRetrieval(params: booklist): Promise<HttpResponse> {
    return Axios(book.bookRetrieval, {
      method: 'GET',
      // responseType: 'json',
      params: params,
    });
  }

  // 图书详情
  static async viewBookDetails(params: viewParams): Promise<HttpResponse> {
    return Axios(book.viewBookDetails, {
      method: 'POST',
      // responseType: 'json',
      params: params,
    });
  }

  // 图书type
  static async getBookTypeDropDown(): Promise<HttpResponse> {
    return Axios(book.getBookTypeDropDown, {
      method: 'post',
      // responseType: 'json',
    });
  }
  // 图书二级类型下拉选
  static async listCategory(params): Promise<HttpResponse> {
    return Axios(book.listCategory, {
      method: 'post',
      params: params,
    });
  }
}
export default UserService;
