change create function for issue controller, add invocation of blockchain related function and add ActiveRecord Rollback operation
This commit is contained in:
parent
f230c0d640
commit
fcc17eb07b
|
@ -105,6 +105,7 @@ class IssuesController < ApplicationController
|
|||
elsif params[:subject].to_s.size > 255
|
||||
normal_status(-1, "标题不能超过255个字符")
|
||||
else
|
||||
ActiveRecord::Base.transaction do
|
||||
issue_params = issue_send_params(params)
|
||||
|
||||
@issue = Issue.new(issue_params)
|
||||
|
@ -138,11 +139,21 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
@issue.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create")
|
||||
|
||||
# author: zxh
|
||||
# 调用上链API
|
||||
success_blockchain = push_activity_2_blockchain("issue_create", @issue)
|
||||
if success_blockchain == false
|
||||
normal_status(-1, "创建失败")
|
||||
raise ActiveRecord::Rollback
|
||||
else
|
||||
render json: {status: 0, message: "创建成", id: @issue.id}
|
||||
end
|
||||
else
|
||||
normal_status(-1, "创建失败")
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue