新增:根据id查询疑修

This commit is contained in:
yystopf 2023-12-11 16:07:24 +08:00
parent aac91538aa
commit 0cb38bce4f
3 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,6 @@
class Api::V1::IssuesController < Api::V1::BaseController
before_action :require_login, except: [:index, :show]
before_action :require_public_and_member_above, only: [:index, :show, :create, :update, :destroy]
before_action :require_login, except: [:index, :show, :show_by_id]
before_action :require_public_and_member_above, only: [:index, :show, :show_by_id, :create, :update, :destroy]
before_action :require_operate_above, only: [:batch_update, :batch_destroy]
def index
@ -22,6 +22,12 @@ class Api::V1::IssuesController < Api::V1::BaseController
before_action :load_issue, only: [:show, :update, :destroy]
before_action :check_issue_operate_permission, only: [:update, :destroy]
before_action :load_issue_by_id, only: [:show_by_id]
def show_by_id
@issue.associate_attachment_container
@user_permission = current_user.present? && current_user.logged? && (@project.member?(current_user) || current_user.admin? || @issue.user == current_user)
end
def show
@issue.associate_attachment_container
@ -70,6 +76,13 @@ class Api::V1::IssuesController < Api::V1::BaseController
end
end
def load_issue_by_id
@issue = Issue.find_by_id(params[:index])
if @issue.blank?
render_not_found("疑修不存在!")
end
end
def load_issues
return render_error("请输入正确的ID数组") unless params[:ids].is_a?(Array)
params[:ids].each do |id|

View File

@ -0,0 +1,2 @@
json.partial! "api/v1/issues/detail", locals: {issue: @issue}
json.user_permission @user_permission

View File

@ -47,6 +47,7 @@ defaults format: :json do
end
member do
get :show_by_id
resources :journals, module: :issues, only: [:index, :create, :update, :destroy] do
member do
get :children_journals