import request from "@/utils/request";
import axios from "axios";
const CancelToken = axios.CancelToken;
export let cancel;
export default {
  /**
   *
   * @param {*} data
   * @returns
   * 查询商品推荐列表
   */
  appCommonActivityRecommendList(data) {
    return request({
      url: "/bs/app/common/activity/recommend/list",
      method: "get",
      params: data,
    });
  },
  /**
   *
   * @param {*} data
   * @returns
   * 获取课程教育类型
   */
  educationTypeList(data) {
    return request({
      url: "/bs/app/common/course/educationType/list",
      method: "get",
      params: data,
    });
  },

  /**
   *
   * @param {*} data
   * @returns
   * 根据教育类型获取业务层级
   */
  businessList(data) {
    return request({
      url: "/bs/app/common/course/business/list",
      method: "get",
      params: data,
    });
  },

  /**
   *
   * @param {*} data
   * @returns
   * 根据业务层级获取科目分类
   */
  subjectList(data) {
    return request({
      url: "/bs/app/common/course/subject/list",
      method: "get",
      params: data,
    });
  },

  /**
   *
   * @param {*} data
   * @returns
   *
   * 根据科目分类获取商品列表
   */
  goodsList(data) {
    return request({
      url: "/bs/app/common/goods/list",
      method: "get",
      params: data,
      cancelToken: new CancelToken(function executor(c) {
        // executor 函数接收一个 cancel 函数作为参数
        cancel = c;
      }),
    });
  },

  /**
   *
   * @param {*} data
   * @returns
   * 通过商品id获取课程列表
   */
  goodsCourseList(data) {
    return request({
      url: "/bs/BsGoods/course/list/" + data,
      method: "get",
    });
  },

  /**
   *
   * @param {*} data
   * @returns
   * 通过课程id获取模块信息
   */
  menuList(data) {
    return request({
      url: "/bs/course/menu/list",
      method: "get",
      params: data,
    });
  },

  /**
   *
   * @param {*} data
   * @returns
   * 通过模块id获取章id
   */
  chapterList(data) {
    return request({
      url: "/bs/course/module/chapter/allList/" + data,
      method: "get",
    });
  },
  /**
   *
   * @param {*} data
   * @returns
   * 通过章id获取节id列表
   */
  sectionList(data) {
    return request({
      url: "/bs/course/chapter/section/list/" + data,
      method: "get",
    });
  },

  /**
   * 获取商品题库列表
   */
  goodsBankList(params) {
    return request({
      url: "/bs/app/common/bank/list",
      method: "get",
      params: params
    });
  },

  /**
   * 查询题库章卷列表
   */
  bankChapterList(params) {
    return request({
      url: "/bs/app/common/bank/chapter/list",
      method: "get",
      params: params,
    });
  },

  /**
   * 查询题库试卷列表
   */
  bankExamList(params) {
    return request({
      url: "/bs/app/common/bank/exam/list",
      method: "get",
      params: params,
    });
  },
};
