新增:pms_product_module_relates关系及搜索编辑

This commit is contained in:
yystopf 2026-02-04 15:14:41 +08:00
parent 9a596621b1
commit 3112ad20b8
7 changed files with 47 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
end
json.pms_product_module_ids issue.pms_product_module_relates.pluck(:pms_product_module_id)

View File

@ -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
json.current_depth issue.depth
json.pms_product_module_ids issue.pms_product_module_relates.pluck(:pms_product_module_id)

View File

@ -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