import BaseStore from '@src/stores/base';

export default class MyStore extends BaseStore {
  /**
   * 绑定邮箱
   * @param {*} email 邮箱
   */
  bindEmail(email) {
    return this.apiPost('/auth/email', { email });
  }

  /**
   * 修改用户信息
   * @param {*} info  nickname avatar
   */
  editInfo(info) {
    return this.apiPost('/auth/info', { ...info });
  }

  /**
   * 实名认证
   * @param {*} file
   */
  real(file) {
    return this.apiForm('/auth/real', { file });
  }

  /**
   * 用户站内信
   * @param {*} page
   * @param {*} size
   * @param {*} type
   * @param {*} read
   */
  message(page, size, type, read) {
    return this.apiGet('/auth/message', { page, size, type, read });
  }

  /**
   * 读取用户消息/全部
   */
  readAllMessage() {
    return this.apiPut('/auth/message/read', { all: true });
  }

  /**
   * 读取用户消息
   */
  readMessage(id) {
    return this.apiPut('/auth/message/read', { all: false, id });
  }

  /**
   * 修改备考信息
   * @param {*} info prepareStatus: 身份  prepareGoal: 目标分数 prepareExaminationTime: 考试时间 prepareScoreTime: 出分时间
   */
  editPrepare(info) {
    return this.apiPut('/auth/prepare', { ...info });
  }

  /**
   * 获取备考信息
   */
  getPrepare() {
    return this.apiGet('/auth/prepare');
  }

  /**
   * 获取学习记录
   * @param {*} date 时间
   */
  getStudy(date) {
    return this.apiGet('/auth/study', { date });
  }

  /**
   * 添加收藏
   * @param {*} questionNoId
   */
  addCollect(module, questionNoId) {
    return this.apiPut('/auth/collect', { module, questionNoId });
  }

  /**
   * 删除收藏
   * @param {*} questionNoId
   */
  delCollect(module, questionNoId) {
    return this.apiDel('/auth/collect', { module, id: questionNoId });
  }

  /**
   * 收藏卷组
   * @param {*} ids
   */
  bindCollect(ids) {
    return this.apiPost('/auth/collect/bind', { questionNoIds: ids });
  }

  /**
   * 获取收藏题目列表
   * @param {*} module
   * @param {*} type
   * @param {*} page
   * @param {*} size
   * @param {*} startTime
   * @param {*} endTime
   * @param {*} order
   * @param {*} direction
   */
  listCollect(module, type, page, size, startTime, endTime, order, direction) {
    return this.apiGet('/auth/collect/question', { module, type, page, size, startTime, endTime, order, direction });
  }

  /**
   * 获取错题列表
   * @param {*} module
   * @param {*} type
   * @param {*} page
   * @param {*} size
   */
  listError(module, type, page, size) {
    return this.apiGet('/auth/error/list', { module, type, page, size });
  }

  /**
   * 错题组卷
   * @param {*} ids
   * @param {*} times
   */
  bindError(ids, times) {
    return this.apiPost('/auth/error/bind', { questionNoIds: ids, filterTimes: times });
  }

  /**
   * 错题移除
   * @param {*} ids
   */
  clearError(ids) {
    return this.apiPost('/auth/error/clear', { questionNoIds: ids });
  }

  /**
   * 更新笔记
   * @param {*} questionNoId
   * @param {*} content
   */
  updateNote(questionNoId, content) {
    return this.apiPut('/auth/note', { questionNoId, content });
  }

  /**
   * 获取笔记列表
   * @param {*} module
   * @param {*} type
   * @param {*} page
   * @param {*} size
   * @param {*} startTime
   * @param {*} endTime
   * @param {*} order
   * @param {*} direction
   */
  noteList(module, type, page, size, startTime, endTime, order, direction) {
    return this.apiGet('/auth/note/list', { module, type, page, size, startTime, endTime, order, direction });
  }

  /**
   * 获取报告列表
   * @param {*} module
   * @param {*} type
   * @param {*} page
   * @param {*} size
   * @param {*} startTime
   * @param {*} endTime
   * @param {*} order
   * @param {*} direction
   */
  reportList(module, type, page, size, startTime, endTime, order, direction) {
    return this.apiGet('/auth/report/list', { module, type, page, size, startTime, endTime, order, direction });
  }
}

export const My = new MyStore({ key: 'my' });