mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-13 08:15:55 +08:00
修复:删除、更改逻辑测试修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Api::V1::IssuesController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index, :show, :create, :update, :destroy]
|
||||
before_action :require_public_and_member_above, only: [:index, :show, :create, :update, :destroy, :batch_update, :batch_destroy]
|
||||
|
||||
def index
|
||||
@object_results = Api::V1::Issues::ListService.call(@project, query_params, current_user)
|
||||
@@ -22,17 +22,31 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
||||
|
||||
def destroy
|
||||
@object_result = Api::V1::Issues::DeleteService.call(@project, @issue, current_user)
|
||||
if @object_result
|
||||
render_ok
|
||||
else
|
||||
render_error("删除疑修失败!")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
before_action :load_issues, only: [:batch_update, :batch_destroy]
|
||||
|
||||
def batch_update
|
||||
@object_result = Api::V1::Issues::BatchUpdateService.call(@project, @issues, batch_issue_params, current_user)
|
||||
if @object_result
|
||||
render_ok
|
||||
else
|
||||
render_error("批量更新疑修失败!")
|
||||
end
|
||||
end
|
||||
|
||||
def batch_destroy
|
||||
@object_result = Api::V1::Issues::BatchDeleteService.call(@project, @issues, current_user)
|
||||
if @object_result
|
||||
render_ok
|
||||
else
|
||||
render_error("批量删除疑修失败!")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
@@ -55,7 +69,8 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
||||
:subject, :description,
|
||||
:issue_tag_ids => [],
|
||||
:assigner_ids => [],
|
||||
:attachment_ids => [])
|
||||
:attachment_ids => [],
|
||||
:receivers_login => [])
|
||||
end
|
||||
|
||||
def batch_issue_params
|
||||
@@ -77,14 +92,14 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
||||
def load_issues
|
||||
return render_error("请输入正确的ID数组!") unless params[:ids].is_a?(Array)
|
||||
params[:ids].each do |id|
|
||||
@issue = @project.issues.where(project_issues_index: id).where.not(id: id).take || Issue.find_by_id(id)
|
||||
@issue = Issue.find_by_id(id)
|
||||
if @issue.blank?
|
||||
return render_not_found("ID为#{id}的疑修不存在!")
|
||||
elsif if @issue.present? && @issue.is_lock &&!(@project.member?(current_user) || current_user.admin?)
|
||||
elsif @issue.present? && @issue.is_lock &&!(@project.member?(current_user) || current_user.admin?)
|
||||
return render_forbidden("ID为#{id}的疑修您没有权限操作!")
|
||||
end
|
||||
end
|
||||
@issues = @project.issues.where(project_issues_index: params[:ids]).where.not(id: params[:ids]) || Issue.where(id: params[:ids])
|
||||
@issues = Issue.where(id: params[:ids])
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user