mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-07-13 21:44:32 +08:00
新增:疑修操作记录、评论列表接口以及更新疑修无法产生操作记录修复
This commit is contained in:
@@ -40,8 +40,11 @@ class Journal < ApplicationRecord
|
||||
belongs_to :journalized, polymorphic: true
|
||||
belongs_to :review, optional: true
|
||||
belongs_to :resolveer, class_name: 'User', foreign_key: :resolveer_id, optional: true
|
||||
belongs_to :parent_journal, class_name: 'Journal', foreign_key: :parent_id, optional: true
|
||||
belongs_to :reply_journal, class_name: 'Journal', foreign_key: :reply_id, optional: true
|
||||
has_many :journal_details, :dependent => :delete_all
|
||||
has_many :attachments, as: :container, dependent: :destroy
|
||||
has_many :first_ten_children_journals, -> { order(created_on: :asc).limit(10)}, class_name: 'Journal', foreign_key: :parent_id
|
||||
has_many :children_journals, class_name: 'Journal', foreign_key: :parent_id
|
||||
|
||||
scope :journal_includes, ->{includes(:user, :journal_details, :attachments)}
|
||||
@@ -54,6 +57,81 @@ class Journal < ApplicationRecord
|
||||
self.notes.blank? && self.journal_details.present?
|
||||
end
|
||||
|
||||
def operate_content
|
||||
content = ""
|
||||
detail = self.journal_details.take
|
||||
case detail.property
|
||||
when 'issue'
|
||||
return "创建了<b>疑修</b>"
|
||||
when 'attachment'
|
||||
old_value = Attachment.where(id: detail.old_value.split(",")).pluck(:filename).join("、")
|
||||
new_value = Attachment.where(id: detail.value.split(",")).pluck(:filename).join("、")
|
||||
if old_value.nil? || old_value.blank?
|
||||
content += "添加了<b>#{new_value}</b>附件"
|
||||
else
|
||||
new_value = "无" if new_value.blank?
|
||||
content += "将附件由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
|
||||
end
|
||||
when 'issue_tag'
|
||||
old_value = IssueTag.where(id: detail.old_value.split(",")).pluck(:name, :color).map{|t| "<span style='color: #{t[1]}'>#{t[0]}</span>"}.join(" ")
|
||||
new_value = IssueTag.where(id: detail.value.split(",")).pluck(:name, :color).map{|t| "<span style='color: #{t[1]}'>#{t[0]}</span>"}.join(" ")
|
||||
if old_value.nil? || old_value.blank?
|
||||
content += "添加了<b>#{new_value}</b>标记"
|
||||
else
|
||||
new_value = "无" if new_value.blank?
|
||||
content += "将标记由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
|
||||
end
|
||||
when 'assigner'
|
||||
old_value = User.where(id: detail.old_value.split(",")).pluck(:nickname).join("、")
|
||||
new_value = User.where(id: detail.value.split(",")).pluck(:nickname).join("、")
|
||||
if old_value.nil? || old_value.blank?
|
||||
content += "添加负责人<b>#{new_value}</b>"
|
||||
else
|
||||
new_value = "无" if new_value.blank?
|
||||
content += "将负责人由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
|
||||
end
|
||||
when 'attr'
|
||||
content = "将"
|
||||
case detail.prop_key
|
||||
when 'subject'
|
||||
return "修改了<b>标题</b>"
|
||||
when 'description'
|
||||
return "修改了<b>描述</b>"
|
||||
when 'status_id'
|
||||
old_value = IssueStatus.find_by_id(detail.old_value)&.name
|
||||
new_value = IssueStatus.find_by_id(detail.value)&.name
|
||||
content += "状态"
|
||||
when 'priority_id'
|
||||
old_value = IssuePriority.find_by_id(detail.old_value)&.name
|
||||
new_value = IssuePriority.find_by_id(detail.value)&.name
|
||||
content += "优先级"
|
||||
when 'fixed_version_id'
|
||||
old_value = Version.find_by_id(detail.old_value)&.name
|
||||
new_value = Version.find_by_id(detail.value)&.name
|
||||
content += "里程碑"
|
||||
when 'branch_name'
|
||||
old_value = detail.old_value
|
||||
new_value = detail.value
|
||||
content += "关联分支"
|
||||
when 'start_date'
|
||||
old_value = detail.old_value
|
||||
new_value = detail.value
|
||||
content += "开始日期"
|
||||
when 'due_date'
|
||||
old_value = detail.old_value
|
||||
new_value = detail.value
|
||||
content += "结束日期"
|
||||
end
|
||||
if old_value.nil? || old_value.blank?
|
||||
content += "设置为<b>#{new_value}</b>"
|
||||
else
|
||||
new_value = "无" if new_value.blank?
|
||||
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def journal_content
|
||||
send_details = []
|
||||
if self.is_journal_detail?
|
||||
|
||||
Reference in New Issue
Block a user