添加粉丝关注页面
This commit is contained in:
94
src/services/commentService.ts
Normal file
94
src/services/commentService.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import httpService from "./httpService";
|
||||
import type { ApiResponse } from "./httpService";
|
||||
|
||||
// 评论项接口定义
|
||||
export interface CommentActivity {
|
||||
id: number;
|
||||
type: "comment" | "reply";
|
||||
activity_type: string;
|
||||
game_id: number;
|
||||
parent_id: number | null;
|
||||
content: string;
|
||||
like_count: number;
|
||||
reply_count: number;
|
||||
create_time: string;
|
||||
user: {
|
||||
id: number;
|
||||
nickname: string;
|
||||
province: string;
|
||||
avatar_url: string;
|
||||
};
|
||||
game: {
|
||||
id: number;
|
||||
title: string;
|
||||
start_time: string;
|
||||
location_name: string;
|
||||
image_list?: string[];
|
||||
};
|
||||
reply_to_user: {
|
||||
id: number;
|
||||
nickname: string;
|
||||
avatar_url: string;
|
||||
} | null;
|
||||
parent_comment: {
|
||||
id: number;
|
||||
content: string;
|
||||
user_id: number;
|
||||
user_nickname: string;
|
||||
} | null;
|
||||
}
|
||||
|
||||
// 获取评论动态请求参数
|
||||
export interface GetMyActivitiesParams {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
// 评论动态列表响应
|
||||
export interface CommentActivitiesResponse {
|
||||
rows: CommentActivity[];
|
||||
count: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
class CommentService {
|
||||
// 获取当前用户的评论和回复动态
|
||||
async getMyActivities(params: GetMyActivitiesParams = {}): Promise<ApiResponse<CommentActivitiesResponse>> {
|
||||
const { page = 1, pageSize = 10 } = params;
|
||||
return httpService.post("/comments/my_activities", { page, pageSize }, { showLoading: false });
|
||||
}
|
||||
|
||||
// 发表评论
|
||||
async createComment(game_id: number, content: string): Promise<ApiResponse<any>> {
|
||||
return httpService.post("/comments/create", { game_id, content });
|
||||
}
|
||||
|
||||
// 回复评论
|
||||
async replyComment(parent_id: number, reply_to_user_id: number, content: string): Promise<ApiResponse<any>> {
|
||||
return httpService.post("/comments/reply", { parent_id, reply_to_user_id, content });
|
||||
}
|
||||
|
||||
// 获取评论列表
|
||||
async getCommentList(game_id: number, page: number = 1, pageSize: number = 10): Promise<ApiResponse<any>> {
|
||||
return httpService.post("/comments/list", { game_id, page, pageSize });
|
||||
}
|
||||
|
||||
// 点赞/取消点赞评论
|
||||
async likeComment(comment_id: number): Promise<ApiResponse<any>> {
|
||||
return httpService.post("/comments/like", { comment_id });
|
||||
}
|
||||
|
||||
// 删除评论
|
||||
async deleteComment(comment_id: number): Promise<ApiResponse<any>> {
|
||||
return httpService.post("/comments/delete", { comment_id });
|
||||
}
|
||||
|
||||
// 获取评论的所有回复
|
||||
async getCommentReplies(comment_id: number, page: number = 1, pageSize: number = 10): Promise<ApiResponse<any>> {
|
||||
return httpService.post("/comments/replies", { comment_id, page, pageSize });
|
||||
}
|
||||
}
|
||||
|
||||
export default new CommentService();
|
||||
@@ -84,6 +84,34 @@ export class FollowService {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取新增粉丝列表(新关注的人)
|
||||
static async get_new_fans_list(
|
||||
page: number = 1,
|
||||
page_size: number = 20
|
||||
): Promise<FollowListResponse> {
|
||||
try {
|
||||
const response = await httpService.post<FollowListResponse>(
|
||||
'/user_follow/new_fans_list',
|
||||
{ page, page_size },
|
||||
{ showLoading: false }
|
||||
);
|
||||
|
||||
if (response.code === 0) {
|
||||
// 为数据添加 follow_status 标识
|
||||
const list = response.data.list.map(user => ({
|
||||
...user,
|
||||
follow_status: user.is_mutual ? 'mutual_follow' as const : 'follower' as const
|
||||
}));
|
||||
return { ...response.data, list };
|
||||
} else {
|
||||
throw new Error(response.message || '获取新增粉丝列表失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取新增粉丝列表失败:', error);
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
}
|
||||
|
||||
// 获取我的关注列表
|
||||
static async get_following_list(
|
||||
page: number = 1,
|
||||
|
||||
Reference in New Issue
Block a user