Browse Source

更改:删除工作项需删除子工作项放到回调中

pull/347/head
yystopf 2 years ago
parent
commit
8030d7db1a
2 changed files with 1 additions and 8 deletions
  1. +1
    -0
      app/models/issue.rb
  2. +0
    -8
      app/services/api/v1/issues/delete_service.rb

+ 1
- 0
app/models/issue.rb View File

@@ -82,6 +82,7 @@ class Issue < ApplicationRecord
has_many :assigners, through: :issue_assigners
has_many :issue_participants, dependent: :destroy
has_many :participants, through: :issue_participants
has_many :children_issues, class_name: 'Issue', foreign_key: :root_id, dependent: :destroy
has_many :show_participants, -> {joins(:issue_participants).where.not(issue_participants: {participant_type: 'atme'}).distinct}, through: :issue_participants, source: :participant
has_many :show_assigners, -> {joins(:issue_assigners).distinct}, through: :issue_assigners, source: :assigner
has_many :show_issue_tags, -> {joins(:issue_tags_relates).distinct}, through: :issue_tags_relates, source: :issue_tag


+ 0
- 8
app/services/api/v1/issues/delete_service.rb View File

@@ -15,8 +15,6 @@ class Api::V1::Issues::DeleteService < ApplicationService
raise Error, errors.full_messages.join(", ") unless valid?
try_lock("Api::V1::Issues::DeleteService:#{project.id}") # 开始写数据,加锁

delete_zi_issues

delete_issue

project.incre_project_issue_cache_delete_count
@@ -39,10 +37,4 @@ class Api::V1::Issues::DeleteService < ApplicationService
def delete_issue
raise Error, "删除疑修失败!" unless issue.destroy!
end

def delete_zi_issues
zi_issues = Issue.where(pm_project_id:issue.pm_project_id, root_id: issue.id)
raise Error, "删除疑修关联项失败!" unless zi_issues.destroy_all
end

end

Loading…
Cancel
Save