mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
Merge branch 'standalone_develop' into pm_project_develop
This commit is contained in:
@@ -76,10 +76,22 @@ class Api::V1::Issues::ListService < ApplicationService
|
||||
issues = issues.where(author_id: author_id) if author_id.present?
|
||||
|
||||
# issue_tag_ids
|
||||
issues = issues.ransack(issue_tags_value_cont: issue_tag_ids.sort!.join(',')).result unless issue_tag_ids.blank?
|
||||
if issue_tag_ids.present?
|
||||
if issue_tag_ids.include?('-1')
|
||||
issues = issues.where(issue_tags_value: nil).or(issues.where(issue_tags_value: ""))
|
||||
else
|
||||
issues = issues.ransack(issue_tags_value_cont: issue_tag_ids.sort!.join(',')).result
|
||||
end
|
||||
end
|
||||
|
||||
# milestone_id
|
||||
issues = issues.where(fixed_version_id: milestone_id) if milestone_id.present?
|
||||
if milestone_id.present?
|
||||
if milestone_id.to_i == -1
|
||||
issues = issues.where(fixed_version_id: nil)
|
||||
else
|
||||
issues = issues.where(fixed_version_id: milestone_id)
|
||||
end
|
||||
end
|
||||
|
||||
#pm相关
|
||||
# root_id# -1 查一级目录
|
||||
@@ -102,7 +114,13 @@ class Api::V1::Issues::ListService < ApplicationService
|
||||
issues = issues.where(pm_sprint_id: pm_sprint_id) if pm_sprint_id.present?
|
||||
|
||||
# assigner_id
|
||||
issues = issues.joins(:assigners).where(users: {id: assigner_id}) if assigner_id.present?
|
||||
if assigner_id.present?
|
||||
if assigner_id.to_i == -1
|
||||
issues = issues.left_joins(:assigners).where(users: {id: nil})
|
||||
else
|
||||
issues = issues.joins(:assigners).where(users: {id: assigner_id})
|
||||
end
|
||||
end
|
||||
|
||||
# status_id
|
||||
issues = issues.where(status_id: status_id) if status_id.present? && category != 'closed'
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
class Api::V1::Projects::Actions::Runs::JobShowService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_reader :project, :token, :owner, :repo, :run, :job, :log_cursors
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :run, :job, :log_cursors, presence: true
|
||||
|
||||
def initialize(project, run, job, log_cursors, token = nil)
|
||||
@project = project
|
||||
@owner = project&.owner.login
|
||||
@repo = project&.identifier
|
||||
@run = run
|
||||
@job = job
|
||||
@log_cursors = log_cursors
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
load_gitea_data
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
logCursors: log_cursors
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_hat_client.post_repos_actions_runs_jobs_by_owner_repo_run_job(owner, repo, run, job, {query: request_params, body: request_body.to_json})
|
||||
end
|
||||
end
|
||||
40
app/services/api/v1/projects/actions/runs/list_service.rb
Normal file
40
app/services/api/v1/projects/actions/runs/list_service.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
class Api::V1::Projects::Actions::Runs::ListService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_reader :project, :token, :owner, :repo, :workflow, :page, :limit
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :workflow, presence: true
|
||||
|
||||
def initialize(project, params, token =nil)
|
||||
@project = project
|
||||
@owner = project&.owner.login
|
||||
@repo = project&.identifier
|
||||
@workflow = params[:workflow]
|
||||
@page = params[:page] || 1
|
||||
@limit = params[:limit] || 15
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
load_gitea_data
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token,
|
||||
workflow: workflow,
|
||||
page: page,
|
||||
limit: limit
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_hat_client.get_repos_actions_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
raise Error, '获取流水线执行记录失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
|
||||
attr_accessor :project, :token, :owner, :repo, :name, :page, :limit
|
||||
attr_accessor :project, :token, :owner, :repo, :name, :state, :page, :limit
|
||||
attr_accessor :gitea_data, :gitea_repo_data
|
||||
|
||||
def initialize(project, params, token=nil)
|
||||
@@ -9,6 +9,7 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
@repo = project&.identifier
|
||||
@token = token
|
||||
@name = params[:name]
|
||||
@state = params[:state]
|
||||
@page = params[:page]
|
||||
@limit = params[:limit]
|
||||
end
|
||||
@@ -18,7 +19,6 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
load_default_branch
|
||||
|
||||
@gitea_data[:default_branch] = @gitea_repo_data["default_branch"]
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
@@ -30,7 +30,8 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
limit: limit
|
||||
}
|
||||
params.merge!({name: name}) if name.present?
|
||||
|
||||
params.merge!({state: state}) if state.present?
|
||||
|
||||
params
|
||||
end
|
||||
|
||||
|
||||
47
app/services/api/v1/projects/branches/restore_service.rb
Normal file
47
app/services/api/v1/projects/branches/restore_service.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
class Api::V1::Projects::Branches::RestoreService < ApplicationService
|
||||
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :project, :token, :owner, :repo, :branch_id, :branch_name
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :branch_id, :branch_name, presence: true
|
||||
|
||||
def initialize(project, branch_id, branch_name, token= nil)
|
||||
@project = project
|
||||
@owner = project&.owner&.login
|
||||
@repo = project&.identifier
|
||||
@branch_id = branch_id
|
||||
@branch_name = branch_name
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
excute_data_to_gitea
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
branch_id: branch_id,
|
||||
name: branch_name,
|
||||
}
|
||||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
begin
|
||||
@gitea_data = $gitea_hat_client.post_repos_branches_restore_by_owner_repo(owner, repo, {query: request_params, body: request_body.to_json})
|
||||
rescue => e
|
||||
raise Error, '恢复分支失败!'
|
||||
end
|
||||
end
|
||||
end
|
||||
37
app/services/api/v1/projects/commits/recent_service.rb
Normal file
37
app/services/api/v1/projects/commits/recent_service.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class Api::V1::Projects::Commits::RecentService < ApplicationService
|
||||
|
||||
attr_reader :project, :page, :limit, :owner, :repo, :token
|
||||
attr_accessor :gitea_data
|
||||
|
||||
def initialize(project, params, token=nil)
|
||||
@project = project
|
||||
@page = params[:page] || 1
|
||||
@limit = params[:limit] || 15
|
||||
@owner = project&.owner&.login
|
||||
@repo = project&.identifier
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
load_gitea_data
|
||||
|
||||
gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
param = {
|
||||
access_token: token,
|
||||
page: page,
|
||||
limit: limit
|
||||
}
|
||||
|
||||
param
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_hat_client.get_repos_recent_commits_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -29,6 +29,6 @@ class Api::V1::Projects::CompareService < ApplicationService
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_compare_by_owner_repo_from_to(owner, repo, from, to, {query: request_params}) rescue nil
|
||||
@gitea_data = $gitea_hat_client.get_repos_compare_by_owner_repo_baseref_headref(owner, repo, to, from, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user