From 2437bda410e69d71c6aa4f2f01ae1e5baaa80dee Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Nov 2023 10:17:30 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=A0=B9=E6=8D=AEroot=5Fid=E6=9F=A5=E8=AF=A2=E5=88=B0?= =?UTF-8?q?=E5=AF=B9=E5=BA=94issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/v1/issues/list_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/api/v1/issues/list_service.rb b/app/services/api/v1/issues/list_service.rb index c9d9b2bb1..3d5488bba 100644 --- a/app/services/api/v1/issues/list_service.rb +++ b/app/services/api/v1/issues/list_service.rb @@ -71,8 +71,8 @@ class Api::V1::Issues::ListService < ApplicationService #pm相关 # root_id - if pm_project_id.present? - issues = issues.where(root_id: root_id.present? ? nil : root_id) + if root_id.present? + issues = issues.where(root_id: root_id).or(issues.where(id: root_id)) end # pm_issue_type From 32386c2f66ca265aa4ef44164dd79293644c8cdb Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Nov 2023 10:37:16 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=88=A0=E9=99=A4ids=E4=B8=BA=E7=A9=BA=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=85=A8=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/issues_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/pm/issues_controller.rb b/app/controllers/api/pm/issues_controller.rb index 02e1736e1..52411d5db 100644 --- a/app/controllers/api/pm/issues_controller.rb +++ b/app/controllers/api/pm/issues_controller.rb @@ -120,7 +120,11 @@ class Api::Pm::IssuesController < Api::Pm::BaseController return render_not_found("ID为#{id}的疑修不存在!") end end - @issues = Issue.where(id: params[:ids], pm_project_id: params[:pm_project_id]) + if params[:ids].blank? + @issues = Issue.where(pm_project_id: params[:pm_project_id]) + else + @issues = Issue.where(id: params[:ids], pm_project_id: params[:pm_project_id]) + end end From 0c553203c1005f1a4b2e8d1595a6bf9c3e7f268d Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Nov 2023 10:52:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Aissue=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=80=85=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 3 +++ app/services/api/v1/issues/create_service.rb | 1 + app/services/api/v1/issues/update_service.rb | 1 + app/views/api/v1/issues/_detail.json.jbuilder | 7 +++++++ db/migrate/20231114023928_add_changer_to_issues.rb | 5 +++++ 5 files changed, 17 insertions(+) create mode 100644 db/migrate/20231114023928_add_changer_to_issues.rb diff --git a/app/models/issue.rb b/app/models/issue.rb index 640d7300b..67e65593f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -39,12 +39,14 @@ # pm_issue_type :integer # time_scale :decimal(10, 2) default("0.00") # child_count :integer default("0") +# changer_id :integer # # Indexes # # index_issues_on_assigned_to_id (assigned_to_id) # index_issues_on_author_id (author_id) # index_issues_on_category_id (category_id) +# index_issues_on_changer_id (changer_id) # index_issues_on_created_on (created_on) # index_issues_on_fixed_version_id (fixed_version_id) # index_issues_on_priority_id (priority_id) @@ -90,6 +92,7 @@ class Issue < ApplicationRecord has_many :attach_pull_requests, through: :pull_attached_issues, source: :pull_request # PM 关联工作项目 has_many :pm_links, as: :linkable, dependent: :destroy + belongs_to :changer, class_name: 'User', foreign_key: :changer_id, optional: true scope :issue_includes, ->{includes(:user)} scope :issue_many_includes, ->{includes(journals: :user)} diff --git a/app/services/api/v1/issues/create_service.rb b/app/services/api/v1/issues/create_service.rb index 69e2e9464..1a5e309a8 100644 --- a/app/services/api/v1/issues/create_service.rb +++ b/app/services/api/v1/issues/create_service.rb @@ -67,6 +67,7 @@ class Api::V1::Issues::CreateService < ApplicationService @created_issue.root_id = @root_id @created_issue.time_scale = @time_scale @created_issue.issue_tags_value = @issue_tags.order("id asc").pluck(:id).join(",") unless issue_tag_ids.blank? + @created_issue.changer_id = @current_user.id @created_issue.save! if Site.has_blockchain? && @project.use_blockchain diff --git a/app/services/api/v1/issues/update_service.rb b/app/services/api/v1/issues/update_service.rb index 8f1fe303b..25f5b7d39 100644 --- a/app/services/api/v1/issues/update_service.rb +++ b/app/services/api/v1/issues/update_service.rb @@ -79,6 +79,7 @@ class Api::V1::Issues::UpdateService < ApplicationService @updated_issue.time_scale = @time_scale unless @time_scale.nil? @updated_issue.updated_on = Time.now + @updated_issue.changer_id = current_user.id @updated_issue.save! build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 diff --git a/app/views/api/v1/issues/_detail.json.jbuilder b/app/views/api/v1/issues/_detail.json.jbuilder index 6e86b6d92..b01f6058e 100644 --- a/app/views/api/v1/issues/_detail.json.jbuilder +++ b/app/views/api/v1/issues/_detail.json.jbuilder @@ -33,6 +33,13 @@ json.author do json.nil! end end +json.changer do + if issue.changer.present? + json.partial! "api/v1/users/simple_user", locals: {user: issue.changer} + else + json.nil! + end +end json.assigners issue.show_assigners.each do |assigner| json.partial! "api/v1/users/simple_user", locals: {user: assigner} end diff --git a/db/migrate/20231114023928_add_changer_to_issues.rb b/db/migrate/20231114023928_add_changer_to_issues.rb new file mode 100644 index 000000000..4dff74ed1 --- /dev/null +++ b/db/migrate/20231114023928_add_changer_to_issues.rb @@ -0,0 +1,5 @@ +class AddChangerToIssues < ActiveRecord::Migration[5.2] + def change + add_reference :issues, :changer + end +end From 7080b74ebe27efce9812b66510041864111a5dec Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Nov 2023 10:56:44 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E8=BF=94=E5=9B=9E=E7=BB=9D=E5=AF=B9=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/users/_simple_user.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index ef45bcd94..5e8e970e7 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -3,7 +3,7 @@ if user.present? json.type user.type json.name user.real_name json.login user.login - json.image_url url_to_avatar(user) + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(user).to_s else json.nil! end \ No newline at end of file From 85322819047a22906d5c14f1b89b25a5f13d31bd Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Nov 2023 11:03:58 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/create.json.jbuilder | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/attachments/create.json.jbuilder b/app/views/attachments/create.json.jbuilder index 3c0ef3559..6ddc5ced2 100644 --- a/app/views/attachments/create.json.jbuilder +++ b/app/views/attachments/create.json.jbuilder @@ -1,2 +1,7 @@ json.id @attachment.id -json.filesize @attachment.filesize +json.title @attachment.title +json.filesize number_to_human_size(@attachment.filesize) +json.is_pdf @attachment.is_pdf? +json.url Rails.application.config_for(:configuration)['platform_url'] + (@attachment.is_pdf? ? download_url(@attachment,disposition:"inline") : download_url(@attachment)).to_s +json.created_on @attachment.created_on.strftime("%Y-%m-%d %H:%M") +json.content_type @attachment.content_type