From b5383bfa5a8dffb1a661ec7dc5524f9320960bab Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 3 Mar 2023 18:43:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/issues_controller.rb | 7 +++++-- app/models/message_template/issue_changed.rb | 12 ++++++------ app/views/api/v1/issues/index.json.jbuilder | 6 +++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/v1/issues_controller.rb b/app/controllers/api/v1/issues_controller.rb index 84f4dd722..6f615e498 100644 --- a/app/controllers/api/v1/issues_controller.rb +++ b/app/controllers/api/v1/issues_controller.rb @@ -9,8 +9,11 @@ class Api::V1::IssuesController < Api::V1::BaseController @total_issues_count = @object_result[:total_issues_count] @opened_issues_count = @object_result[:opened_issues_count] @closed_issues_count = @object_result[:closed_issues_count] - - @issues = kaminari_paginate(@object_result[:data]) + if params[:only_name].present? + @issues = kaminary_select_paginate(@object_result[:data].pluck(:id, :subject)) + else + @issues = kaminari_paginate(@object_result[:data]) + end end def create diff --git a/app/models/message_template/issue_changed.rb b/app/models/message_template/issue_changed.rb index f5e8c7628..5ac3a120f 100644 --- a/app/models/message_template/issue_changed.rb +++ b/app/models/message_template/issue_changed.rb @@ -31,16 +31,16 @@ class MessageTemplate::IssueChanged < MessageTemplate change_count = change_params.keys.size # 疑修负责人修改 if change_params[:assigned_to_id].present? - assigner1 = User.find_by_id(change_params[:assigned_to_id][0]) - assigner2 = User.find_by_id(change_params[:assigned_to_id][1]) + assigner1 = User.where(id: change_params[:assigned_to_id][0]) + assigner2 = User.where(id: change_params[:assigned_to_id][1]) if change_count > 1 content.sub!('{ifassigner}', '
') else content.sub!('{ifassigner}', '') end content.sub!('{endassigner}', '') - content.gsub!('{assigner1}', assigner1.present? ? assigner1&.real_name : '未指派成员') - content.gsub!('{assigner2}', assigner2.present? ? assigner2&.real_name : '未指派成员') + content.gsub!('{assigner1}', assigner1.present? ? assigner1.map{|a| a&.real_name}.join("、") : '未指派成员') + content.gsub!('{assigner2}', assigner2.present? ? assigner2.map{|a| a&.real_name}.join("、") : '未指派成员') else content.gsub!(/({ifassigner})(.*)({endassigner})/, '') end @@ -217,8 +217,8 @@ class MessageTemplate::IssueChanged < MessageTemplate content.sub!('{ifassigner}', '') end content.sub!('{endassigner}', '') - content.gsub!('{assigner1}', assigner1.present? ? assigner1.map{|a| a&.real_name}.join("、") : '无') - content.gsub!('{assigner2}', assigner2.present? ? assigner2.map{|a| a&.real_name}.join("、") : '无') + content.gsub!('{assigner1}', assigner1.present? ? assigner1.map{|a| a&.real_name}.join("、") : '未指派成员') + content.gsub!('{assigner2}', assigner2.present? ? assigner2.map{|a| a&.real_name}.join("、") : '未指派成员') else content.gsub!(/({ifassigner})(.*)({endassigner})/, '') end diff --git a/app/views/api/v1/issues/index.json.jbuilder b/app/views/api/v1/issues/index.json.jbuilder index 6a04c56ac..ddc36ffb7 100644 --- a/app/views/api/v1/issues/index.json.jbuilder +++ b/app/views/api/v1/issues/index.json.jbuilder @@ -4,5 +4,9 @@ json.closed_count @closed_issues_count json.total_count @issues.total_count json.has_created_issues @project.issues.size > 0 json.issues @issues.each do |issue| - json.partial! "simple_detail", locals: {issue: issue} + if params[:only_name].present? + json.partial! "simple_detail", locals: {issue: issue} + else + json.(issue, :id, :subject) + end end \ No newline at end of file