first commit
This commit is contained in:
50
libs/api/tracker/application/src/lib/comments.service.ts
Normal file
50
libs/api/tracker/application/src/lib/comments.service.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
||||
import { CommentReadModel } from '@task-stream/api/tracker/domain';
|
||||
import { AddCommentCommand } from './commands/add-comment.command';
|
||||
import { CommandResult } from './commands/command-result';
|
||||
import { DeleteCommentCommand } from './commands/delete-comment.command';
|
||||
import { EditCommentCommand } from './commands/edit-comment.command';
|
||||
import { Page } from './ports/find-issues.repository';
|
||||
import { GetCommentsQuery } from './queries/get-comments.query';
|
||||
|
||||
@Injectable()
|
||||
export class CommentsService {
|
||||
constructor(
|
||||
private readonly commandBus: CommandBus,
|
||||
private readonly queryBus: QueryBus,
|
||||
) {}
|
||||
|
||||
add(actorId: string, issueId: string, body: string): Promise<CommandResult> {
|
||||
return this.commandBus.execute(
|
||||
new AddCommentCommand(actorId, issueId, body),
|
||||
);
|
||||
}
|
||||
|
||||
edit(
|
||||
actorId: string,
|
||||
commentId: string,
|
||||
body: string,
|
||||
): Promise<CommandResult> {
|
||||
return this.commandBus.execute(
|
||||
new EditCommentCommand(actorId, commentId, body),
|
||||
);
|
||||
}
|
||||
|
||||
delete(actorId: string, commentId: string): Promise<CommandResult> {
|
||||
return this.commandBus.execute(
|
||||
new DeleteCommentCommand(actorId, commentId),
|
||||
);
|
||||
}
|
||||
|
||||
list(
|
||||
viewerId: string,
|
||||
issueId: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
): Promise<Page<CommentReadModel>> {
|
||||
return this.queryBus.execute(
|
||||
new GetCommentsQuery(viewerId, issueId, limit, offset),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user