add blockchain operation after comments
This commit is contained in:
parent
f4f1aef365
commit
cbb666052c
|
@ -21,32 +21,44 @@ class JournalsController < ApplicationController
|
||||||
if notes.blank?
|
if notes.blank?
|
||||||
normal_status(-1, "评论内容不能为空")
|
normal_status(-1, "评论内容不能为空")
|
||||||
else
|
else
|
||||||
journal_params = {
|
ActiveRecord::Base.transaction do
|
||||||
journalized_id: @issue.id ,
|
journal_params = {
|
||||||
journalized_type: "Issue",
|
journalized_id: @issue.id ,
|
||||||
user_id: current_user.id ,
|
journalized_type: "Issue",
|
||||||
notes: notes.to_s.strip,
|
user_id: current_user.id ,
|
||||||
parent_id: params[:parent_id]
|
notes: notes.to_s.strip,
|
||||||
}
|
parent_id: params[:parent_id]
|
||||||
journal = Journal.new journal_params
|
}
|
||||||
if journal.save
|
journal = Journal.new journal_params
|
||||||
if params[:attachment_ids].present?
|
if journal.save
|
||||||
params[:attachment_ids].each do |id|
|
if params[:attachment_ids].present?
|
||||||
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
|
params[:attachment_ids].each do |id|
|
||||||
unless attachment.blank?
|
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
|
||||||
attachment.container = journal
|
unless attachment.blank?
|
||||||
attachment.author_id = current_user.id
|
attachment.container = journal
|
||||||
attachment.description = ""
|
attachment.author_id = current_user.id
|
||||||
attachment.save
|
attachment.description = ""
|
||||||
|
attachment.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# @issue.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "journal")
|
# author: zxh
|
||||||
render :json => { status: 0, message: "评论成功", id: journal.id}
|
# 调用上链API
|
||||||
# normal_status(0, "评论成功")
|
success_blockchain = push_activity_2_blockchain("issue_comment_create", journal)
|
||||||
else
|
if success_blockchain == false
|
||||||
normal_status(-1, "评论失败")
|
normal_status(-1, "评论失败")
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
else
|
||||||
|
render json: {status: 0, message: "评论成功", id: journal.id}
|
||||||
|
end
|
||||||
|
|
||||||
|
# @issue.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "journal")
|
||||||
|
# normal_status(0, "评论成功")
|
||||||
|
else
|
||||||
|
normal_status(-1, "评论失败")
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue