<?php
 namespace Module\Question\Util; use ModStart\Core\Dao\ModelUtil; use Module\Member\Util\MemberUtil; class QuestionCommentUtil { public static function updateQuestionCommentCount($questionId) { $commentCount = ModelUtil::count('question_comment', [ 'questionId' => $questionId ]); ModelUtil::update('question', $questionId, [ 'commentCount' => $commentCount ]); } public static function paginate($questionId, $page, $pageSize) { $option = [ 'where' => ['questionId' => $questionId], 'order' => ['id', 'desc'], ]; $paginateData = ModelUtil::paginate('question_comment', $page, $pageSize, $option); MemberUtil::mergeMemberUserBasics($paginateData['records']); return $paginateData; } public static function post($memberUserId, $questionId, $content) { return ModelUtil::insert('question_comment', [ 'memberUserId' => $memberUserId, 'questionId' => $questionId, 'content' => $content, ]); } public static function delete($commentId) { ModelUtil::delete('question_comment', ['id' => $commentId]); } }