mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
CloudIDEA文件标记已读未读
This commit is contained in:
29
app/controllers/mark_files_controller.rb
Normal file
29
app/controllers/mark_files_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
class MarkFilesController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :load_project
|
||||
before_action :load_pull_request
|
||||
|
||||
def index
|
||||
@files_result = Gitea::PullRequest::FilesService.call(@owner.login, @project.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||
|
||||
MarkFile.bulk_insert(*%i[pull_request_id, file_path_sha file_path created_at updated_at]) do |worker|
|
||||
@files_result['Files'].echo do |file|
|
||||
worker.add(pull_request_id: @pull_request.id, file_path_sha: SecureRandom.uuid.gsub("-", ""), file_path: file['Name'])
|
||||
end
|
||||
end
|
||||
@mark_files = MarkFile.where(pull_request_id: @pull_request.id)
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
private
|
||||
def review_params
|
||||
params.require(:review).permit(:content, :commit_id, :status)
|
||||
end
|
||||
|
||||
def load_pull_request
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
5
app/models/mark_file.rb
Normal file
5
app/models/mark_file.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class MarkFile < ApplicationRecord
|
||||
belongs_to :pull_request
|
||||
|
||||
|
||||
end
|
||||
@@ -43,6 +43,7 @@ class PullRequest < ApplicationRecord
|
||||
has_many :reviews, dependent: :destroy
|
||||
has_many :pull_requests_reviewers, dependent: :destroy
|
||||
has_many :reviewers, through: :pull_requests_reviewers
|
||||
has_many :mark_files, dependent: :destroy
|
||||
|
||||
scope :merged_and_closed, ->{where.not(status: 0)}
|
||||
scope :opening, -> {where(status: 0)}
|
||||
|
||||
12
app/views/mark_files/index.json.jbuilder
Normal file
12
app/views/mark_files/index.json.jbuilder
Normal file
@@ -0,0 +1,12 @@
|
||||
json.status 0
|
||||
json.message 'success'
|
||||
json.count @mark_files.count
|
||||
json.files do
|
||||
json.array! @mark_files do |file|
|
||||
json.sha file.file_path_sha
|
||||
json.name file.file_path
|
||||
json.mark_as_read file.mark_as_read
|
||||
json.updated_after_read file.updated_after_read
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user