Tag.ts
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { AnyObject, Option, QueryForParams, ServiceResponse } from '@/types/global';
import { Tag } from '@/types/tag';
import axios from 'axios';
export default class useTagApi {
static typeOption = [
{ label: '歌曲标签', value: 1 },
{ label: '身份标签', value: 2 },
{ label: '声音标签', value: 3 },
{ label: '认证标签', value: 4 },
];
static showOption = [
{ label: '显示', value: 1 },
{ label: '隐藏', value: 0 },
];
static filterOption = [
{ label: '允许', value: 1 },
{ label: '禁止', value: 0 },
];
static certifyPermissionOption = [
{ label: '听', value: 1 },
{ label: '唱', value: 2 },
];
static async get(params?: QueryForParams): Promise<ServiceResponse<Tag[]>> {
return axios.get('system/tags', { params });
}
static async create(data: AnyObject): Promise<Tag> {
return axios.post('system/tags', data).then((res) => Promise.resolve(res.data));
}
static async show(id: number, params?: QueryForParams): Promise<Tag> {
return axios.get(`system/tags/${id}`, { params }).then((res) => Promise.resolve(res.data));
}
static async update(id: number, data: AnyObject): Promise<Tag> {
return axios.put(`system/tags/${id}`, data).then((res) => Promise.resolve(res.data));
}
static async destroy(id: number) {
return axios.delete(`system/tags/${id}`).then((res) => Promise.resolve(res.data));
}
static async getOption(params?: QueryForParams): Promise<Option[]> {
return useTagApi.get({ ...params, fetchType: 'all' }).then(({ data }) =>
data?.map((item) => {
return { value: item.id, label: item.name };
})
);
}
}