class Api::V1::Projects::Pulls::JournalsController < Api::V1::Projects::Pulls::BaseController def index @journals = Api::V1::Projects::Pulls::Journals::ListService.call(@project, @pull_request, params, current_user) @journals = @journals.limit(200) end def create @journal = Api::V1::Projects::Pulls::Journals::CreateService.call(@project, @pull_request, create_params, current_user) end before_action :find_journal, only: [:update, :destroy] def update @journal = Api::V1::Projects::Pulls::Journals::UpdateService.call(@project, @pull_request, @journal, update_params, current_user) end def destroy if @journal.destroy render_ok else render_error("删除评论失败!") end end private def create_params params.permit(:parent_id, :line_code, :note, :commit_id, :path, :type, :review_id, :diff => {}) end def update_params params.permit(:note, :commit_id, :state) end def find_journal @journal = @pull_request.journals.find_by_id(params[:id]) return render_not_found unless @journal.present? end end