diff --git a/app/controllers/api/pm/issues_controller.rb b/app/controllers/api/pm/issues_controller.rb index e00c5d055..b9484571b 100644 --- a/app/controllers/api/pm/issues_controller.rb +++ b/app/controllers/api/pm/issues_controller.rb @@ -41,9 +41,8 @@ class Api::Pm::IssuesController < Api::Pm::BaseController @issues = @issues.where(status_id: status_ids) unless status_ids.blank? @issues = @issues.where(priority_id: params[:priority_id]) if params[:priority_id].present? @issues = @issues.where(author_id: params[:author_id]) if params[:author_id].present? - @issues = @issues.joins(:requirement_issue_ext).where(requirement_issue_exts: {pms_product_module_id: params[:pms_product_module_id]}) if params[:pms_product_module_id].present? pms_product_module_ids = params[:pms_product_module_ids].present? ? params[:pms_product_module_ids].split(",") : [] - @issues = @issues.joins(:requirement_issue_ext).where(requirement_issue_exts: {pms_product_module_id: pms_product_module_ids}) if pms_product_module_ids.present? + @issues = @issues.joins(:pms_product_module_relates).where(pms_product_module_relates: {pms_product_module_id: pms_product_module_ids}) if pms_product_module_ids.present? # assigner_id if params[:assigner_id].present? @@ -380,7 +379,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController :update_begin_date, :update_end_date, :sort_by, :sort_direction, :root_id, :issue_tag_ids, :pm_project_id, :pm_sprint_id, :pm_issue_type, :pm_project_ids, - :pms_product_module_id, :need_type, :function_type, :identifier, :pms_product_module_ids, + :need_type, :function_type, :identifier, :pms_product_module_ids, :status_ids, :ids, :exclude_ids, :pm_issue_types, :participator_id, :enterprise_identifier ) end @@ -394,7 +393,8 @@ class Api::Pm::IssuesController < Api::Pm::BaseController :subject, :description, :blockchain_token_num, :root_subject, :pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :link_able_id, :project_id, :status_msg, :status_msg_type, :enterprise_identifier, - requirement_issue_ext: [:pms_product_module_id, :need_type, :function_type, :identifier], + requirement_issue_ext: [:need_type, :function_type, :identifier], + pms_product_module_ids: [], issue_tag_ids: [], assigner_ids: [], attachment_ids: [], @@ -406,6 +406,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController params.permit( :status_id, :priority_id, :milestone_id, :pm_sprint_id, :due_date, :pm_issue_type, :root_id, :target_pm_project_id, :project_id, requirement_issue_ext: [:pms_product_module_id, :need_type, :function_type, :identifier], + :pms_product_module_ids => [], :issue_tag_ids => [], :assigner_ids => [] ) end diff --git a/app/models/issue.rb b/app/models/issue.rb index 9e4b8ac27..50e4e9720 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -104,6 +104,7 @@ class Issue < ApplicationRecord # PM 关联工作项目 has_many :pm_links, as: :linkable, dependent: :destroy has_one :requirement_issue_ext, dependent: :destroy + has_many :pms_product_module_relates, dependent: :destroy belongs_to :changer, class_name: 'User', foreign_key: :changer_id, optional: true diff --git a/app/models/pms_product_module_relate.rb b/app/models/pms_product_module_relate.rb new file mode 100644 index 000000000..c286ee339 --- /dev/null +++ b/app/models/pms_product_module_relate.rb @@ -0,0 +1,18 @@ +# == Schema Information +# +# Table name: pms_product_module_relates +# +# id :integer not null, primary key +# issue_id :integer +# pms_product_module_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_pms_product_module_relates_on_issue_id (issue_id) +# + +class PmsProductModuleRelate < ApplicationRecord + belongs_to :issue +end diff --git a/app/services/api/v1/issues/list_service.rb b/app/services/api/v1/issues/list_service.rb index 8dcfe685c..84c74a8ce 100644 --- a/app/services/api/v1/issues/list_service.rb +++ b/app/services/api/v1/issues/list_service.rb @@ -5,7 +5,7 @@ class Api::V1::Issues::ListService < ApplicationService attr_reader :begin_date, :end_date, :update_begin_date, :update_end_date attr_reader :milestone_id, :assigner_id, :status_id, :priority_id, :sort_by, :sort_direction, :current_user, :enterprise_identifier attr_reader :pm_project_id, :pm_project_ids, :pm_sprint_id, :root_id, :pm_issue_type, :status_ids, :ids, :exclude_ids, :pm_issue_types - attr_reader :pms_product_module_id, :need_type, :function_type, :identifier, :pms_product_module_ids + attr_reader :need_type, :function_type, :identifier, :pms_product_module_ids attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count, :complete_issues_count, :participator validates :category, inclusion: { in: %w[all opened closed], message: '请输入正确的Category'} @@ -40,7 +40,6 @@ class Api::V1::Issues::ListService < ApplicationService @pm_issue_type = params[:pm_issue_type] @ids = params[:ids] @exclude_ids = params[:exclude_ids] - @pms_product_module_id = params[:pms_product_module_id] @need_type = params[:need_type] @function_type = params[:function_type] @identifier = params[:identifier] @@ -169,11 +168,6 @@ class Api::V1::Issues::ListService < ApplicationService # keyword issues = issues.ransack(subject_or_description_cont: keyword).result if keyword.present? - # pms_product_module_id - if pms_product_module_id.present? - issues = issues.joins(:requirement_issue_ext).where(requirement_issue_exts: {pms_product_module_id: pms_product_module_id}) - end - # need_type if need_type.present? issues = issues.joins(:requirement_issue_ext).where(requirement_issue_exts: {need_type: need_type}) @@ -191,7 +185,7 @@ class Api::V1::Issues::ListService < ApplicationService # pms_product_module_ids if pms_product_module_ids.present? - issues = issues.joins(:requirement_issue_ext).where(requirement_issue_exts: {pms_product_module_id: pms_product_module_ids}) + issues = issues.joins(:pms_product_module_relates).where(pms_product_module_relates: {pms_product_module_id: pms_product_module_ids}) end @closed_issues_count = issues.closed.distinct.size diff --git a/app/views/api/v1/issues/_detail.json.jbuilder b/app/views/api/v1/issues/_detail.json.jbuilder index 53cded8b5..49e705fcc 100644 --- a/app/views/api/v1/issues/_detail.json.jbuilder +++ b/app/views/api/v1/issues/_detail.json.jbuilder @@ -58,8 +58,8 @@ json.project do end end if issue.requirement_issue_ext.present? - json.pms_product_module_id issue.requirement_issue_ext.pms_product_module_id json.need_type issue.requirement_issue_ext.need_type json.function_type issue.requirement_issue_ext.function_type json.identifier issue.requirement_issue_ext.identifier -end \ No newline at end of file +end +json.pms_product_module_ids issue.pms_product_module_relates.pluck(:pms_product_module_id) \ No newline at end of file diff --git a/app/views/api/v1/issues/_simple_detail.json.jbuilder b/app/views/api/v1/issues/_simple_detail.json.jbuilder index 90331791b..28798a3ec 100644 --- a/app/views/api/v1/issues/_simple_detail.json.jbuilder +++ b/app/views/api/v1/issues/_simple_detail.json.jbuilder @@ -48,9 +48,9 @@ json.due_date issue.due_date json.plan_start_date issue.plan_start_date json.plan_end_date issue.plan_end_date if issue.requirement_issue_ext.present? - json.pms_product_module_id issue.requirement_issue_ext.pms_product_module_id json.need_type issue.requirement_issue_ext.need_type json.function_type issue.requirement_issue_ext.function_type json.identifier issue.requirement_issue_ext.identifier end -json.current_depth issue.depth \ No newline at end of file +json.current_depth issue.depth +json.pms_product_module_ids issue.pms_product_module_relates.pluck(:pms_product_module_id) \ No newline at end of file diff --git a/db/migrate/20260204055829_create_pms_product_module_relates.rb b/db/migrate/20260204055829_create_pms_product_module_relates.rb new file mode 100644 index 000000000..5d24031a5 --- /dev/null +++ b/db/migrate/20260204055829_create_pms_product_module_relates.rb @@ -0,0 +1,17 @@ +class CreatePmsProductModuleRelates < ActiveRecord::Migration[5.2] + def change + create_table :pms_product_module_relates do |t| + t.references :issue + t.integer :pms_product_module_id + + t.timestamps + end + + IssueRequirement.where.not(pms_product_module_id: nil) do |ir| + PmsProductModuleRelate.create!( + issue: ir.issue, + pms_product_module_id: ir.pms_product_module_id + ) + end + end +end