import FetchRequest from "@/api/FetchRequest";
import type Collect from "@/mode/Collect";

class CollectApi {
  static url = "/api/sys/collects";

  /**
   * 获取当前用户所有收藏
   */
  static list(type: string): Promise<any> {
    return FetchRequest.get(`${this.url}?type=${type}`, true);
  }

  /**
   * 获取收藏
   */
  static get(id: string): Promise<any> {
    return FetchRequest.get(`${this.url}/${id}`, true);
  }

  /**
   * 保存收藏
   * @param collect 收藏
   */
  static save(collect: Collect): Promise<any> {
    return FetchRequest.post(this.url, JSON.stringify(collect), true);
  }

  /**
   * 修改收藏
   *  @param collect 收藏
   */
  static update(collect: Collect): Promise<any> {
    return FetchRequest.put(this.url, JSON.stringify(collect), true);
  }

  /**
   *  删除收藏
   *  @param id 收藏id
   */
  static delete(id: string): Promise<any> {
    return FetchRequest.del(`${this.url}/${id}`, "", true);
  }
}

export default CollectApi;
