notification.ts
2.27 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { AttributeData, QueryForParams, ServiceResponse } from '@/types/global';
// eslint-disable-next-line import/no-cycle
import { Notification } from '@/utils/model';
import axios from 'axios';
export default class useNotificationApi {
static typeOption = [
{ value: 1, label: '文本' },
{ value: 2, label: '图文' },
];
static alertOption = [
{ value: 1, label: '弹出' },
{ value: 0, label: '不弹出' },
];
static statusOption = [
{ value: 0, label: '待发送' },
{ value: 1, label: '处理中' },
{ value: 2, label: '已发送' },
{ value: -1, label: '发送失败' },
{ value: -2, label: '取消发送' },
{ value: 3, label: '已撤销' },
];
static publishTypeOption = [
{ value: 1, label: '立即发送' },
{ value: 2, label: '定时发送' },
];
static linkTypeOption = [
{ value: 'none', label: '无' },
{ value: 'user', label: '用户' },
{ value: 'activity', label: '歌曲' },
{ value: 'project', label: '厂牌' },
{ value: 'rich', label: '自定义H5页面' },
];
static get(params?: QueryForParams): Promise<ServiceResponse<Notification[]>> {
return axios.get('system/notification', { params });
}
static async create(data?: AttributeData): Promise<Notification> {
return axios.post('system/notification', data).then((res) => Promise.resolve(res.data));
}
static async show(id: number): Promise<Notification> {
return axios.get(`system/notification/${id}`).then((res) => Promise.resolve(res.data));
}
static async update(id: number, data = {}): Promise<Notification> {
return axios.put(`system/notification/${id}`, data).then((res) => Promise.resolve(res.data));
}
static async user(id: number, params?: QueryForParams) {
return axios.get(`system/notification/${id}/users`, { params });
}
static async send(id: number): Promise<unknown> {
return axios.put(`system/notification/${id}/send`).then((res) => Promise.resolve(res.data));
}
static async cancel(id: number): Promise<unknown> {
return axios.put(`system/notification/${id}/cancel`).then((res) => Promise.resolve(res.data));
}
static async rollback(id: number): Promise<unknown> {
return axios.put(`system/notification/${id}/rollback`).then((res) => Promise.resolve(res.data));
}
}