generated from nhcarrigan/template
feat: add art component
This commit is contained in:
@@ -63,6 +63,7 @@ export class CommentService {
|
||||
gameId: comment.gameId || undefined,
|
||||
bookId: comment.bookId || undefined,
|
||||
musicId: comment.musicId || undefined,
|
||||
artId: comment.artId || undefined,
|
||||
createdAt: comment.createdAt,
|
||||
updatedAt: comment.updatedAt,
|
||||
};
|
||||
@@ -146,6 +147,32 @@ export class CommentService {
|
||||
return this.mapComment(comment);
|
||||
}
|
||||
|
||||
async getCommentsForArt(artId: string): Promise<Comment[]> {
|
||||
const comments = await this.prisma.comment.findMany({
|
||||
where: { artId },
|
||||
include: { user: true },
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
return comments.map((c) => this.mapComment(c));
|
||||
}
|
||||
|
||||
async createCommentForArt(
|
||||
artId: string,
|
||||
userId: string,
|
||||
data: CreateCommentDto
|
||||
): Promise<Comment> {
|
||||
const sanitizedContent = this.sanitizeMarkdown(data.content);
|
||||
const comment = await this.prisma.comment.create({
|
||||
data: {
|
||||
content: sanitizedContent,
|
||||
userId,
|
||||
artId,
|
||||
},
|
||||
include: { user: true },
|
||||
});
|
||||
return this.mapComment(comment);
|
||||
}
|
||||
|
||||
async deleteComment(commentId: string): Promise<void> {
|
||||
await this.prisma.comment.delete({
|
||||
where: { id: commentId },
|
||||
|
||||
Reference in New Issue
Block a user