From d87f44e9395676c85223ea17ab015d71b75eb9d5 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Wed, 27 May 2020 18:25:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=9A=84=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9/=E5=88=A0=E9=99=A4=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 39 +++++++++++++++++++++++++++- app/forms/contents/update_form.rb | 2 +- config/routes.rb | 2 ++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 633d973b5..e4e37fd2c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -251,13 +251,50 @@ class IssuesController < ApplicationController end def destroy - if @issue.delete + if @issue.destroy normal_status(0, "删除成功") else normal_status(-1, "删除失败") end end + def clean + begin + issue_ids = params[:ids] + if issue_ids.present? + if Issue.where(id: issue_ids).destroy_all + normal_status(0, "删除成功") + else + normal_status(-1, "删除失败") + end + else + normal_status(-1, "请选择任务") + end + rescue Exception => e + normal_status(-1, "批量删除失败") + raise ActiveRecord::Rollback + end + end + + def series_update + begin + issue_ids = params[:ids] + update_params = params[:update_params] + if issue_ids.present? + if Issue.where(id: issue_ids).update_all(update_params) + normal_status(0, "批量更新成功") + else + normal_status(-1, "批量更新失败") + end + else + normal_status(-1, "请选择任务") + end + rescue Exception => e + normal_status(-1, "批量更新失败") + raise ActiveRecord::Rollback + end + end + def copy @new_issue = @issue.dup if @new_issue.save diff --git a/app/forms/contents/update_form.rb b/app/forms/contents/update_form.rb index 8600f0fde..75ae6fc58 100644 --- a/app/forms/contents/update_form.rb +++ b/app/forms/contents/update_form.rb @@ -7,7 +7,7 @@ class Contents::UpdateForm < BaseForm def check_branch raise "branch和new_branch必须存在一个 " if branch.blank? && new_branch.blank? - raise "branch和new_branch只能存在一个" if !branch.blank? && !new_branch.blank? + # raise "branch和new_branch只能存在一个" if !branch.blank? && !new_branch.blank? end end diff --git a/config/routes.rb b/config/routes.rb index f9f932cdd..d9dba0b92 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,8 @@ Rails.application.routes.draw do collection do get :commit_issues get :index_chosen + post :clean + post :series_update end member do post :copy