star-tag.ts 1.09 KB
import { AnyObject, QueryForParams, ServiceResponse } from '@/types/global';

import { Tag } from '@/types/star-tags';
import axios from 'axios';

export default class useTagApi {
  static frameOption = [
    { label: '需要边框', value: 1 },
    { label: '不需要边框', value: 2 },
  ];

  static indexFilterOption = [
    { label: '首页可筛选', value: 1 },
    { label: '首页不可筛选', value: 0 },
  ];

  static statusOption = [
    { label: '开启', value: 1 },
    { label: '禁用', value: 0 },
  ];

  static async get(params?: QueryForParams): Promise<ServiceResponse<Tag[]>> {
    return axios.get('system/user_tags', { params });
  }

  static async create(data: AnyObject): Promise<Tag> {
    return axios.post('system/user_tags', data).then((res) => Promise.resolve(res.data));
  }

  static async update(id: number, data: AnyObject): Promise<Tag> {
    return axios.put(`system/user_tags/${id}`, data).then((res) => Promise.resolve(res.data));
  }

  static async destroy(id: number) {
    return axios.delete(`system/user_tags/${id}`).then((res) => Promise.resolve(res.data));
  }
}