mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
37
app/controllers/contents_controller.rb
Normal file
37
app/controllers/contents_controller.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class ContentsController < ApplicationController
|
||||
before_action :find_user, :find_repository
|
||||
before_action :require_login, only: %i[create update_file delete_file]
|
||||
|
||||
def create
|
||||
interactor = Gitea::CreateFileInteractor.call(current_user, content_params)
|
||||
if interactor.success?
|
||||
@file = interactor.result
|
||||
else
|
||||
render_error(interactor.error)
|
||||
end
|
||||
end
|
||||
|
||||
def update_file
|
||||
interactor = Gitea::UpdateFileInteractor.call(current_user, params)
|
||||
if interactor.success?
|
||||
@file = interactor.result
|
||||
else
|
||||
render_error(interactor.error)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_file
|
||||
interactor = Gitea::DeleteFileInteractor.call(current_user, params)
|
||||
if interactor.success?
|
||||
@file = interactor.result
|
||||
else
|
||||
render_error(interactor.error)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def content_params
|
||||
params.permit(:login, :repo_identifier, :filepath, :branch, :content, :message, :new_branch)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user