Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(friends-service): wrong comment details api #751

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/comments-service/src/comments-service.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export class CommentsController {
return await this.commentsService.getCommentsByPid(input.pid, input.master);
}

@MessagePattern({ cmd: CommentsEvents.CommentGetById })
async getCommentById(id: string) {
return await this.commentsService.getCommentById(id);
}

@MessagePattern({ cmd: CommentsEvents.CommentCreate })
async createComment(input: { data: CommentsModel; master: boolean }) {
if (!input.master) {
Expand Down
4 changes: 4 additions & 0 deletions apps/comments-service/src/comments-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export class CommentsService {
};
}

async getCommentById(id: string) {
return await this.CommentsModel.findById(id);
}

async createComment(data: CommentsModel, isMaster: boolean) {
if (isMaster) {
data.status = CommentStatus.Approved; // 默认审核通过主人的评论
Expand Down
12 changes: 11 additions & 1 deletion apps/core/src/modules/comments/comments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ export class CommentsController {
);
}

@Get('/:id')
@Get("/:id")
@ApiOperation({ summary: "根据 ID 获取评论" })
async getCommentById(@Param("id") id: string) {
return transportReqToMicroservice(
this.comments,
CommentsEvents.CommentGetById,
id
);
}

@Get('/post/:id')
@ApiOperation({ summary: '根据 PID 获取评论列表' })
async getCommentsByPid(
@Param('id') pid: string,
Expand Down
1 change: 1 addition & 0 deletions shared/constants/event.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export enum PageEvents {
export enum CommentsEvents {
CommentsGetAll = 'sudo.comments.get.all',
CommentsGetList = 'comments.get.list',
CommentGetById = 'comment.get.with.id',
CommentsGetWithPostId = 'comments.get.with.postid',
CommentsDeleteWithPostId = 'comments.delete.with.postid',

Expand Down