import FetchRequest from "@/api/FetchRequest"; import type Collect from "@/mode/Collect"; class CollectApi { static url = "/api/sys/collects"; /** * 获取当前用户所有收藏 */ static list(type: string): Promise { return FetchRequest.get(`${this.url}?type=${type}`, true); } /** * 获取收藏 */ static get(id: string): Promise { return FetchRequest.get(`${this.url}/${id}`, true); } /** * 保存收藏 * @param collect 收藏 */ static save(collect: Collect): Promise { return FetchRequest.post(this.url, JSON.stringify(collect), true); } /** * 修改收藏 * @param collect 收藏 */ static update(collect: Collect): Promise { return FetchRequest.put(this.url, JSON.stringify(collect), true); } /** * 删除收藏 * @param id 收藏id */ static delete(id: string): Promise { return FetchRequest.del(`${this.url}/${id}`, "", true); } } export default CollectApi;