blob: 46a5209384092b0bc3bc11c08d8ed803c8c1a4ed [file] [log] [blame]
ybt02e716d2025-04-15 17:19:32 +08001import Mock from 'mockjs'
2
3// 模拟延迟
4Mock.setup({
5 timeout: '300-600'
6})
7
8// 模拟用户数据
9const users = [
10 {
11 id: 1,
ybtda5978b2025-05-31 15:58:05 +080012 username: 'LukasWu',
13 password: '060050bbb',
14 email: '22301102@bjtu.edu.cn',
15 role: 'user',
16 userType: 0, // 普通用户
17 avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=LukasWu',
18 createTime: '2025-05-13 17:51:08'
ybt02e716d2025-04-15 17:19:32 +080019 },
20 {
21 id: 2,
ybtda5978b2025-05-31 15:58:05 +080022 username: 'IcyIron',
23 password: '111111',
24 email: 'icyiron@example.com',
25 role: 'admin',
26 userType: 1, // 管理员
27 avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=IcyIron',
28 createTime: '2025-05-13 18:00:00'
ybt02e716d2025-04-15 17:19:32 +080029 },
30 {
31 id: 3,
ybtda5978b2025-05-31 15:58:05 +080032 username: 'tanzhennan727',
33 password: 'password123',
34 email: 'tanzhennan727@example.com',
35 role: 'user',
36 userType: 0,
37 avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=tanzhennan727',
38 createTime: '2025-05-14 10:00:00'
ybt02e716d2025-04-15 17:19:32 +080039 },
40 {
41 id: 4,
ybtda5978b2025-05-31 15:58:05 +080042 username: 'ybt',
43 password: 'ybt123',
44 email: 'ybt@example.com',
45 role: 'user',
46 userType: 0,
47 avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=ybt',
48 createTime: '2025-05-15 14:30:00'
ybt02e716d2025-04-15 17:19:32 +080049 }
50]
51
ybtda5978b2025-05-31 15:58:05 +080052// 模拟帖子数据
53const posts = [
54 {
55 id: 1,
56 title: '如何成为云顶高手',
57 content: '向icyiron学习',
58 author: 'LukasWu',
59 createTime: '2025-05-18 16:43:51',
60 views: 256,
61 likes: 57
62 },
63 {
64 id: 101,
65 title: '北京交通大学实训心得',
66 content: '实训非常有趣,学到了很多知识',
67 author: 'LukasWu',
68 createTime: '2025-05-17 09:30:00',
69 views: 128,
70 likes: 32
71 },
72 {
73 id: 102,
74 title: '前端开发技巧分享',
75 content: 'React和Vue的使用经验总结...',
76 author: 'IcyIron',
77 createTime: '2025-05-16 15:20:00',
78 views: 345,
79 likes: 89
80 },
81 {
82 id: 103,
83 title: '后端接口设计规范',
84 content: 'RESTful API设计的最佳实践...',
85 author: 'tanzhennan727',
86 createTime: '2025-05-15 11:10:00',
87 views: 210,
88 likes: 45
89 },
90 {
91 id: 104,
92 title: '数据库优化技巧',
93 content: 'MySQL索引优化与查询性能提升...',
94 author: 'ybt',
95 createTime: '2025-05-14 16:40:00',
96 views: 178,
97 likes: 36
98 },
99 {
100 id: 105,
101 title: '云顶之弈攻略',
102 content: '最强阵容搭配与装备选择...',
103 author: 'IcyIron',
104 createTime: '2025-05-13 20:15:00',
105 views: 567,
106 likes: 120
107 }
108]
109
110// 模拟评论数据
111const comments = [
112 {
113 id: 1001,
114 postId: 105,
115 content: '感谢分享,学到了很多!',
116 author: 'LukasWu',
117 createTime: '2025-05-19 12:30:15'
118 },
119 {
120 id: 1002,
121 postId: 105,
122 content: '这个阵容我试了,确实很强',
123 author: 'tanzhennan727',
124 createTime: '2025-05-19 14:25:30'
125 },
126 {
127 id: 1003,
128 postId: 101,
129 content: '实训课程安排得很合理',
130 author: 'ybt',
131 createTime: '2025-05-18 10:15:45'
132 },
133 {
134 id: 1004,
135 postId: 102,
136 content: 'React Hooks确实好用',
137 author: 'LukasWu',
138 createTime: '2025-05-17 16:40:20'
139 },
140 {
141 id: 1005,
142 postId: 103,
143 content: '接口文档写得很清晰',
144 author: 'IcyIron',
145 createTime: '2025-05-16 09:35:10'
146 }
147]
148
149// 生成JWT格式的token
150const generateToken = (username, userType) => {
151 const header = { alg: 'HS256', typ: 'JWT' };
152 const payload = {
153 username: username,
154 userType: userType,
155 exp: Math.floor(Date.now() / 1000) + 86400 // 24小时后过期
156 };
157
158 // Base64编码
159 const encodeBase64 = (obj) => {
160 return btoa(JSON.stringify(obj)).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
161 };
162
163 const headerEncoded = encodeBase64(header);
164 const payloadEncoded = encodeBase64(payload);
165
166 // 在实际应用中应该使用正确的签名算法,这里简化处理
167 const signature = encodeBase64(`${username}-${Date.now()}`);
168
169 return `${headerEncoded}.${payloadEncoded}.${signature}`;
170};
171
172// 验证token
173const verifyToken = (token) => {
174 if (!token) return false;
175
176 try {
177 // 解析token的payload部分
178 const parts = token.split('.');
179 if (parts.length !== 3) return false;
180
181 const payload = JSON.parse(atob(parts[1].replace(/-/g, '+').replace(/_/g, '/')));
182 const now = Math.floor(Date.now() / 1000);
183
184 // 检查过期时间
185 if (payload.exp <= now) return false;
186
187 // 检查用户是否存在
188 const user = users.find(u => u.username === payload.username);
189 if (!user) return false;
190
191 return { valid: true, user, userType: payload.userType };
192 } catch (e) {
193 return false;
194 }
195};
196
197// 用户信息相关接口
198
199// 1. 用户登录
200Mock.mock('/user/login', 'post', (options) => {
201 const body = JSON.parse(options.body);
202 const { username, password } = body;
203
204 const user = users.find(u => u.username === username && u.password === password);
ybt02e716d2025-04-15 17:19:32 +0800205
206 if (user) {
ybtda5978b2025-05-31 15:58:05 +0800207 const token = generateToken(user.username, user.userType);
208
ybt02e716d2025-04-15 17:19:32 +0800209 return {
210 code: 200,
211 message: '登录成功',
ybtda5978b2025-05-31 15:58:05 +0800212 success: true,
ybt02e716d2025-04-15 17:19:32 +0800213 data: {
ybtda5978b2025-05-31 15:58:05 +0800214 token,
215 user: {
216 id: user.id,
217 username: user.username,
218 email: user.email,
219 role: user.role,
220 userType: user.userType,
221 avatar: user.avatar
222 }
ybt02e716d2025-04-15 17:19:32 +0800223 }
ybtda5978b2025-05-31 15:58:05 +0800224 };
ybt02e716d2025-04-15 17:19:32 +0800225 } else {
226 return {
227 code: 401,
228 message: '用户名或密码错误',
ybtda5978b2025-05-31 15:58:05 +0800229 success: false
230 };
ybt02e716d2025-04-15 17:19:32 +0800231 }
ybtda5978b2025-05-31 15:58:05 +0800232});
ybt02e716d2025-04-15 17:19:32 +0800233
ybtda5978b2025-05-31 15:58:05 +0800234// 2. 用户注册
235Mock.mock('/user/register', 'post', (options) => {
236 const body = JSON.parse(options.body);
237 const { username, password, email } = body;
ybt02e716d2025-04-15 17:19:32 +0800238
239 // 检查用户名是否已存在
240 if (users.some(u => u.username === username)) {
241 return {
242 code: 400,
243 message: '用户名已存在',
ybtda5978b2025-05-31 15:58:05 +0800244 success: false
245 };
ybt02e716d2025-04-15 17:19:32 +0800246 }
247
248 // 检查邮箱是否已存在
249 if (users.some(u => u.email === email)) {
250 return {
251 code: 400,
252 message: '邮箱已被注册',
ybtda5978b2025-05-31 15:58:05 +0800253 success: false
254 };
ybt02e716d2025-04-15 17:19:32 +0800255 }
256
257 // 创建新用户
258 const newUser = {
259 id: users.length + 1,
260 username,
261 password,
262 email,
ybtda5978b2025-05-31 15:58:05 +0800263 role: 'user',
264 userType: 0, // 普通用户
265 avatar: `https://api.dicebear.com/7.x/avataaars/svg?seed=${username}`,
266 createTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
267 };
ybt02e716d2025-04-15 17:19:32 +0800268
ybtda5978b2025-05-31 15:58:05 +0800269 users.push(newUser);
270
271 const token = generateToken(newUser.username, newUser.userType);
ybt02e716d2025-04-15 17:19:32 +0800272
273 return {
274 code: 200,
275 message: '注册成功',
ybtda5978b2025-05-31 15:58:05 +0800276 success: true,
277 data: {
278 token,
279 user: {
280 id: newUser.id,
281 username: newUser.username,
282 email: newUser.email,
283 role: newUser.role,
284 userType: newUser.userType,
285 avatar: newUser.avatar
286 }
287 }
288 };
289});
ybt02e716d2025-04-15 17:19:32 +0800290
ybtda5978b2025-05-31 15:58:05 +0800291// 3. 修改用户名
292Mock.mock('/user/update/username', 'post', (options) => {
293 const headers = options.headers || {};
294 const token = headers.token;
295 const auth = verifyToken(token);
ybt02e716d2025-04-15 17:19:32 +0800296
ybtda5978b2025-05-31 15:58:05 +0800297 if (!auth || !auth.valid) {
298 return {
299 code: 401,
300 message: '未授权访问',
301 success: false
302 };
303 }
304
305 const body = JSON.parse(options.body);
306 const { username, newUsername } = body;
307
308 // 检查用户名是否存在
309 const userIndex = users.findIndex(u => u.username === username);
310 if (userIndex === -1) {
311 return {
312 code: 404,
313 message: '用户不存在',
314 success: false
315 };
316 }
317
318 // 检查新用户名是否已被使用
319 if (users.some(u => u.username === newUsername && u.id !== users[userIndex].id)) {
320 return {
321 code: 400,
322 message: '用户名已存在',
323 success: false
324 };
325 }
326
327 // 更新用户名
328 users[userIndex].username = newUsername;
329 users[userIndex].avatar = `https://api.dicebear.com/7.x/avataaars/svg?seed=${newUsername}`;
330
331 return {
332 code: 200,
333 message: '用户名修改成功',
334 success: true,
335 data: {
336 user: {
337 id: users[userIndex].id,
338 username: users[userIndex].username,
339 email: users[userIndex].email,
340 role: users[userIndex].role,
341 userType: users[userIndex].userType,
342 avatar: users[userIndex].avatar
343 }
344 }
345 };
346});
347
348// 4. 修改密码
349Mock.mock('/user/update/password', 'post', (options) => {
350 const headers = options.headers || {};
351 const token = headers.token;
352 const auth = verifyToken(token);
353
354 if (!auth || !auth.valid) {
355 return {
356 code: 401,
357 message: '未授权访问',
358 success: false
359 };
360 }
361
362 const body = JSON.parse(options.body);
363 const { username, newPassword } = body;
364
365 // 检查用户名是否存在
366 const userIndex = users.findIndex(u => u.username === username);
367 if (userIndex === -1) {
368 return {
369 code: 404,
370 message: '用户不存在',
371 success: false
372 };
373 }
374
375 // 更新密码
376 users[userIndex].password = newPassword;
377
378 return {
379 code: 200,
380 message: '密码修改成功',
381 success: true
382 };
383});
384
385// 5. 修改邮箱
386Mock.mock('/user/update/email', 'post', (options) => {
387 const headers = options.headers || {};
388 const token = headers.token;
389 const auth = verifyToken(token);
390
391 if (!auth || !auth.valid) {
392 return {
393 code: 401,
394 message: '未授权访问',
395 success: false
396 };
397 }
398
399 const body = JSON.parse(options.body);
400 const { username, newEmail } = body;
401
402 // 检查用户名是否存在
403 const userIndex = users.findIndex(u => u.username === username);
404 if (userIndex === -1) {
405 return {
406 code: 404,
407 message: '用户不存在',
408 success: false
409 };
410 }
411
412 // 检查邮箱是否已被使用
413 if (users.some(u => u.email === newEmail && u.id !== users[userIndex].id)) {
414 return {
415 code: 400,
416 message: '邮箱已被注册',
417 success: false
418 };
419 }
420
421 // 更新邮箱
422 users[userIndex].email = newEmail;
423
424 return {
425 code: 200,
426 message: '邮箱修改成功',
427 success: true,
428 data: {
429 user: {
430 id: users[userIndex].id,
431 username: users[userIndex].username,
432 email: users[userIndex].email,
433 role: users[userIndex].role,
434 userType: users[userIndex].userType,
435 avatar: users[userIndex].avatar
436 }
437 }
438 };
439});
440
441// 6. 获取用户信息
442Mock.mock(new RegExp('/user/get/info\\?username=.+'), 'get', (options) => {
443 const headers = options.headers || {};
444 const token = headers.token;
445 const auth = verifyToken(token);
446
447 if (!auth || !auth.valid) {
448 return {
449 code: 401,
450 message: '未授权访问',
451 success: false
452 };
453 }
454
455 const url = options.url;
456 const username = url.split('username=')[1];
457
458 const user = users.find(u => u.username === username);
459 if (!user) {
460 return {
461 code: 404,
462 message: '用户不存在',
463 success: false
464 };
465 }
466
467 return {
468 code: 200,
469 message: '获取用户信息成功',
470 success: true,
471 data: {
472 user: {
473 id: user.id,
474 username: user.username,
475 email: user.email,
476 role: user.role,
477 userType: user.userType,
478 avatar: user.avatar,
479 createTime: user.createTime
480 }
481 }
482 };
483});
484
485// 帖子相关接口
486
487// 7. 新建帖子
488Mock.mock('/posts/create', 'post', (options) => {
489 const headers = options.headers || {};
490 const token = headers.token;
491 const auth = verifyToken(token);
492
493 if (!auth || !auth.valid) {
494 return {
495 code: 401,
496 message: '未授权访问',
497 success: false
498 };
499 }
500
501 const body = JSON.parse(options.body);
502 const { title, content, author } = body;
503
504 // 生成新帖子ID
505 const id = posts.length > 0 ? Math.max(...posts.map(p => p.id)) + 1 : 1;
506
507 const newPost = {
508 id,
509 title,
510 content,
511 author,
512 createTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
513 views: 0,
514 likes: 0
515 };
516
517 posts.push(newPost);
518
519 return {
520 code: 200,
521 message: '帖子发布成功',
522 success: true,
523 data: { post: newPost }
524 };
525});
526
527// 8. 查询帖子
528Mock.mock(new RegExp('/posts/list\\?.*'), 'get', (options) => {
529 const headers = options.headers || {};
530 const token = headers.token;
531 const auth = verifyToken(token);
532
533 if (!auth || !auth.valid) {
534 return {
535 code: 401,
536 message: '未授权访问',
537 success: false
538 };
539 }
540
541 const url = options.url;
542 const params = new URLSearchParams(url.split('?')[1]);
543
544 const username = params.get('username');
545 const title = params.get('title');
546 const author = params.get('author');
547 const date = params.get('date');
548
549 // 过滤帖子
550 let filteredPosts = [...posts];
551
552 if (title) {
553 filteredPosts = filteredPosts.filter(p => p.title.includes(title));
554 }
555
556 if (author) {
557 filteredPosts = filteredPosts.filter(p => p.author.includes(author));
558 }
559
560 if (date) {
561 filteredPosts = filteredPosts.filter(p => p.createTime.startsWith(date));
562 }
563
564 return {
565 code: 200,
566 message: '查询帖子成功',
567 success: true,
568 data: {
569 total: filteredPosts.length,
570 posts: filteredPosts
571 }
572 };
573});
574
575// 评论相关接口
576
577// 9. 获取帖子评论
578Mock.mock(new RegExp('/comment/get\\?.*'), 'get', (options) => {
579 const headers = options.headers || {};
580 const token = headers.token;
581 const auth = verifyToken(token);
582
583 if (!auth || !auth.valid) {
584 return {
585 code: 401,
586 message: '未授权访问',
587 success: false
588 };
589 }
590
591 const url = options.url;
592 const params = new URLSearchParams(url.split('?')[1]);
593
594 const postId = params.get('postId');
595
596 if (!postId) {
597 return {
598 code: 400,
599 message: '参数错误',
600 success: false
601 };
602 }
603
604 // 查找帖子
605 const post = posts.find(p => p.id === parseInt(postId));
606 if (!post) {
607 return {
608 code: 404,
609 message: '帖子不存在',
610 success: false
611 };
612 }
613
614 // 获取帖子的评论
615 const postComments = comments.filter(c => c.postId === parseInt(postId));
616
617 return {
618 code: 200,
619 message: '获取评论成功',
620 success: true,
621 data: {
622 total: postComments.length,
623 comments: postComments
624 }
625 };
626});
627
628// 10. 发布帖子评论
629Mock.mock('/comment/add', 'post', (options) => {
630 const headers = options.headers || {};
631 const token = headers.token;
632 const auth = verifyToken(token);
633
634 if (!auth || !auth.valid) {
635 return {
636 code: 401,
637 message: '未授权访问',
638 success: false
639 };
640 }
641
642 const body = JSON.parse(options.body);
643 const { content, username, postId } = body;
644
645 // 检查帖子是否存在
646 const post = posts.find(p => p.id === parseInt(postId));
647 if (!post) {
648 return {
649 code: 404,
650 message: '帖子不存在',
651 success: false
652 };
653 }
654
655 // 检查用户是否存在
656 const user = users.find(u => u.username === username);
657 if (!user) {
658 return {
659 code: 404,
660 message: '用户不存在',
661 success: false
662 };
663 }
664
665 // 生成评论ID
666 const id = comments.length > 0 ? Math.max(...comments.map(c => c.id)) + 1 : 1001;
667
668 const newComment = {
669 id,
670 postId: parseInt(postId),
671 content,
672 author: username,
673 createTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
674 };
675
676 comments.push(newComment);
677
678 return {
679 code: 200,
680 message: '评论发布成功',
681 success: true,
682 data: { comment: newComment }
683 };
684});
685
686// 管理员相关接口
687
688// 11. 管理员登录
689Mock.mock('/admin/login', 'post', (options) => {
690 const body = JSON.parse(options.body);
691 const { username, password } = body;
692
693 // 查找管理员用户
694 const admin = users.find(u => u.username === username && u.password === password && u.userType === 1);
695
696 if (admin) {
697 const token = generateToken(admin.username, admin.userType);
698
ybt02e716d2025-04-15 17:19:32 +0800699 return {
700 code: 200,
ybtda5978b2025-05-31 15:58:05 +0800701 message: '管理员登录成功',
702 success: true,
703 data: {
704 token,
705 user: {
706 id: admin.id,
707 username: admin.username,
708 email: admin.email,
709 role: admin.role,
710 userType: admin.userType,
711 avatar: admin.avatar
712 }
713 }
714 };
ybt02e716d2025-04-15 17:19:32 +0800715 } else {
716 return {
717 code: 401,
ybtda5978b2025-05-31 15:58:05 +0800718 message: '用户名或密码错误,或无管理员权限',
719 success: false
720 };
ybt02e716d2025-04-15 17:19:32 +0800721 }
ybtda5978b2025-05-31 15:58:05 +0800722});
723
724// 12. 获取用户列表 (管理员)
725Mock.mock(new RegExp('/user/list\\?.*'), 'get', (options) => {
726 const headers = options.headers || {};
727 const token = headers.token;
728 const auth = verifyToken(token);
729
730 if (!auth || !auth.valid || auth.userType !== 1) {
731 return {
732 code: 403,
733 message: '无权限访问',
734 success: false
735 };
736 }
737
738 // 返回除密码外的用户信息
739 const userList = users.map(user => ({
740 id: user.id,
741 username: user.username,
742 email: user.email,
743 role: user.role,
744 userType: user.userType,
745 avatar: user.avatar,
746 createTime: user.createTime
747 }));
748
749 return {
750 code: 200,
751 message: '获取用户列表成功',
752 success: true,
753 data: {
754 total: userList.length,
755 users: userList
756 }
757 };
758});
759
760// 13. 删除指定用户 (管理员)
761Mock.mock('/user/delete', 'delete', (options) => {
762 const headers = options.headers || {};
763 const token = headers.token;
764 const auth = verifyToken(token);
765
766 if (!auth || !auth.valid || auth.userType !== 1) {
767 return {
768 code: 403,
769 message: '无权限访问',
770 success: false
771 };
772 }
773
774 const body = JSON.parse(options.body);
775 const { username, targetUsername } = body;
776
777 // 确保操作者是管理员
778 const admin = users.find(u => u.username === username && u.userType === 1);
779 if (!admin) {
780 return {
781 code: 403,
782 message: '无权限操作',
783 success: false
784 };
785 }
786
787 // 查找要删除的用户
788 const userIndex = users.findIndex(u => u.username === targetUsername);
789 if (userIndex === -1) {
790 return {
791 code: 404,
792 message: '用户不存在',
793 success: false
794 };
795 }
796
797 // 不允许删除管理员
798 if (users[userIndex].userType === 1) {
799 return {
800 code: 403,
801 message: '不能删除管理员账户',
802 success: false
803 };
804 }
805
806 // 删除用户
807 const deletedUser = users.splice(userIndex, 1)[0];
808
809 return {
810 code: 200,
811 message: '用户删除成功',
812 success: true,
813 data: {
814 username: deletedUser.username
815 }
816 };
817});
818
819// 14. 删除帖子 (管理员)
820Mock.mock('/posts/delete', 'delete', (options) => {
821 const headers = options.headers || {};
822 const token = headers.token;
823 const auth = verifyToken(token);
824
825 if (!auth || !auth.valid || auth.userType !== 1) {
826 return {
827 code: 403,
828 message: '无权限访问',
829 success: false
830 };
831 }
832
833 const body = JSON.parse(options.body);
834 const { username, pid } = body;
835
836 // 确保操作者是管理员
837 const admin = users.find(u => u.username === username && u.userType === 1);
838 if (!admin) {
839 return {
840 code: 403,
841 message: '无权限操作',
842 success: false
843 };
844 }
845
846 // 查找要删除的帖子
847 const postIndex = posts.findIndex(p => p.id === parseInt(pid));
848 if (postIndex === -1) {
849 return {
850 code: 404,
851 message: '帖子不存在',
852 success: false
853 };
854 }
855
856 // 删除帖子
857 const deletedPost = posts.splice(postIndex, 1)[0];
858
859 // 同时删除该帖子的所有评论
860 const relatedComments = comments.filter(c => c.postId === parseInt(pid));
861 relatedComments.forEach(comment => {
862 const commentIndex = comments.findIndex(c => c.id === comment.id);
863 if (commentIndex !== -1) {
864 comments.splice(commentIndex, 1);
865 }
866 });
867
868 return {
869 code: 200,
870 message: '帖子删除成功',
871 success: true,
872 data: {
873 title: deletedPost.title,
874 deletedComments: relatedComments.length
875 }
876 };
877});
878
879// 15. 删除帖子评论 (管理员)
880Mock.mock('/comment/delete', 'delete', (options) => {
881 const headers = options.headers || {};
882 const token = headers.token;
883 const auth = verifyToken(token);
884
885 if (!auth || !auth.valid || auth.userType !== 1) {
886 return {
887 code: 403,
888 message: '无权限访问',
889 success: false
890 };
891 }
892
893 const body = JSON.parse(options.body);
894 const { username, commentId } = body;
895
896 // 确保操作者是管理员
897 const admin = users.find(u => u.username === username && u.userType === 1);
898 if (!admin) {
899 return {
900 code: 403,
901 message: '无权限操作',
902 success: false
903 };
904 }
905
906 // 查找要删除的评论
907 const commentIndex = comments.findIndex(c => c.id === parseInt(commentId));
908 if (commentIndex === -1) {
909 return {
910 code: 404,
911 message: '评论不存在',
912 success: false
913 };
914 }
915
916 // 删除评论
917 const deletedComment = comments.splice(commentIndex, 1)[0];
918
919 return {
920 code: 200,
921 message: '评论删除成功',
922 success: true,
923 data: {
924 commentId: deletedComment.id,
925 postId: deletedComment.postId
926 }
927 };
928});
ybt02e716d2025-04-15 17:19:32 +0800929
930export default Mock