blob: c1d8e2614b1ae3c7516febd791dfab8e2321beb6 [file] [log] [blame]
86133ec55c542025-04-21 11:51:32 +08001import { request } from '@umijs/max';
2import type {
3 BtTorrent,
4 BtTorrentFile,
5 BtTorrentAnnounce,
6 BtTorrentTag,
7} from '@/pages/Torrent/data'; // 假设你把 data.d.ts 放这里
8
9// ================================
10// 种子主表(bt_torrent)接口
11// ================================
12
13/** 查询种子列表 */
14export async function listBtTorrent(params?: Partial<BtTorrent>) {
15 const queryString = params ? `?${new URLSearchParams(params as any)}` : '';
16 return request(`/api/system/torrent/list${queryString}`, {
17 method: 'get',
18 });
19}
20
21/** 获取种子详情 */
22export async function getBtTorrent(torrentId: number) {
23 return request<BtTorrent>(`/api/system/torrent/${torrentId}`, {
24 method: 'get',
25 });
26}
27
28/** 新增种子 */
29export async function addBtTorrent(data: BtTorrent) {
30 return request('/api/system/torrent', {
31 method: 'post',
32 data,
33 });
34}
35
36/** 修改种子 */
37export async function updateBtTorrent(data: BtTorrent) {
38 return request('/api/system/torrent', {
39 method: 'put',
40 data,
41 });
42}
43
44/** 删除种子(支持批量) */
45export async function removeBtTorrent(torrentIds: number[]) {
46 return request(`/api/system/torrent/${torrentIds.join(',')}`, {
47 method: 'delete',
48 });
49}
50
51// ================================
52// 种子文件(bt_torrent_file)接口
53// ================================
54
55/** 查询种子文件列表 */
56export async function listBtTorrentFile(params?: Partial<BtTorrentFile>) {
57 const queryString = params ? `?${new URLSearchParams(params as any)}` : '';
58 return request(`/api/system/file/list${queryString}`, {
59 method: 'get',
60 });
61}
62
63/** 获取文件详情 */
64export async function getBtTorrentFile(id: number) {
65 return request<BtTorrentFile>(`/api/system/file/${id}`, {
66 method: 'get',
67 });
68}
69
70/** 新增文件 */
71export async function addBtTorrentFile(data: BtTorrentFile) {
72 return request('/api/system/file', {
73 method: 'post',
74 data,
75 });
76}
77
78/** 修改文件 */
79export async function updateBtTorrentFile(data: BtTorrentFile) {
80 return request('/api/system/file', {
81 method: 'put',
82 data,
83 });
84}
85
86/** 删除文件(支持批量) */
87export async function removeBtTorrentFile(ids: number[]) {
88 return request(`/api/system/file/${ids.join(',')}`, {
89 method: 'delete',
90 });
91}
92
93// ================================
94// Tracker 列表(bt_torrent_announce)接口
95// ================================
96
97/** 查询 Tracker 列表 */
98export async function listBtTorrentAnnounce(params?: Partial<BtTorrentAnnounce>) {
99 const queryString = params ? `?${new URLSearchParams(params as any)}` : '';
100 return request(`/api/system/announce/list${queryString}`, {
101 method: 'get',
102 });
103}
104
105/** 获取单个 Tracker */
106export async function getBtTorrentAnnounce(id: number) {
107 return request<BtTorrentAnnounce>(`/api/system/announce/${id}`, {
108 method: 'get',
109 });
110}
111
112/** 新增 Tracker */
113export async function addBtTorrentAnnounce(data: BtTorrentAnnounce) {
114 return request('/api/system/announce', {
115 method: 'post',
116 data,
117 });
118}
119
120/** 修改 Tracker */
121export async function updateBtTorrentAnnounce(data: BtTorrentAnnounce) {
122 return request('/api/system/announce', {
123 method: 'put',
124 data,
125 });
126}
127
128/** 删除 Tracker(支持批量) */
129export async function removeBtTorrentAnnounce(ids: number[]) {
130 return request(`/api/system/announce/${ids.join(',')}`, {
131 method: 'delete',
132 });
133}
134
135// ================================
136// 种子标签(bt_torrent_tags)接口
137// ================================
138
139/** 查询标签列表 */
140export async function listBtTorrentTags(params?: Partial<BtTorrentTag>) {
141 const queryString = params ? `?${new URLSearchParams(params as any)}` : '';
142 return request(`/api/system/tags/list${queryString}`, {
143 method: 'get',
144 });
145}
146
147/** 获取标签详情 */
148export async function getBtTorrentTag(id: number) {
149 return request<BtTorrentTag>(`/api/system/tags/${id}`, {
150 method: 'get',
151 });
152}
153
154/** 新增标签 */
155export async function addBtTorrentTag(data: BtTorrentTag) {
156 return request('/api/system/tags', {
157 method: 'post',
158 data,
159 });
160}
161
162/** 修改标签 */
163export async function updateBtTorrentTag(data: BtTorrentTag) {
164 return request('/api/system/tags', {
165 method: 'put',
166 data,
167 });
168}
169
170/** 删除标签(支持批量) */
171export async function removeBtTorrentTag(ids: number[]) {
172 return request(`/api/system/tags/${ids.join(',')}`, {
173 method: 'delete',
174 });
175}