From fe4f56dd3666aeb961061e0080451f024f1d7fea Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 29 Nov 2023 14:28:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=AD=E4=BB=A3=E4=B8=AD=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/sprint_issues_controller.rb | 28 +++++++++++++++++++ config/routes/api.rb | 1 + 2 files changed, 29 insertions(+) diff --git a/app/controllers/api/pm/sprint_issues_controller.rb b/app/controllers/api/pm/sprint_issues_controller.rb index 6abecfb13..72e0d367d 100644 --- a/app/controllers/api/pm/sprint_issues_controller.rb +++ b/app/controllers/api/pm/sprint_issues_controller.rb @@ -32,6 +32,34 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController end render_ok(data: data) end + + before_action :load_uncomplete_issues, only: [:complete] + + def complete + begin + case complete_params[:complete_type].to_i + when 1 + @issues.update_all(status_id: 5) + when 2 + @issues.update_all(pm_sprint_id: 0) + when 3 + @issues.update_all(pm_sprint_id: complete_params[:target_pm_project_sprint_id]) + end + render_ok + rescue => e + render_error(e.message) + end + end + + private + + def load_uncomplete_issues + @issues = Issue.where(pm_sprint_id: complete_params[:pm_project_sprint_id]).where.not(status_id: 5) + end + + def complete_params + params.permit(:pm_project_sprint_id, :complete_type, :target_pm_project_sprint_id) + end def query_params params.permit( diff --git a/config/routes/api.rb b/config/routes/api.rb index e04218143..bf38eceaf 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -24,6 +24,7 @@ defaults format: :json do resources :sprint_issues, only: [:index] do collection do get :statistics + post :complete end end resources :projects do