"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.commentsService = exports.CommentsService = void 0;
const models_1 = require("../../models");
/**
 * 评论服务
 */
class CommentsService {
    /**
     * 获取章节的所有评论
     */
    async getCommentsByChapterId(chapterId) {
        return await models_1.prisma.comment.findMany({
            where: { chapterId },
            orderBy: { createdAt: 'desc' },
        });
    }
    /**
     * 添加评论
     */
    async addComment(userId, chapterId, content, rating) {
        return await models_1.prisma.comment.create({
            data: {
                userId,
                chapterId,
                content,
                rating,
            },
        });
    }
}
exports.CommentsService = CommentsService;
exports.commentsService = new CommentsService();
