import { prisma } from '../../models'; /** * 评论服务 */ export class CommentsService { /** * 获取音频的所有评论 */ async getCommentsByAudioId(audioId: number) { return await prisma.comment.findMany({ where: { audioId }, orderBy: { createdAt: 'desc' }, }); } /** * 添加评论 */ async addComment(userId: number, audioId: number, content: string, rating: number) { return await prisma.comment.create({ data: { userId, audioId, content, rating, }, }); } } export const commentsService = new CommentsService();