From 2d99713cd0caa021dc3e00590358b29c7d850c4c Mon Sep 17 00:00:00 2001 From: moshenglv Date: Mon, 18 Jan 2021 09:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/pipelines_controller.rb | 9 ++++++--- app/models/ci/pipeline.rb | 1 + app/models/ci/template.rb | 15 ++++++++------- .../20210118011710_add_login_to_ci_pipelines.rb | 5 +++++ 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20210118011710_add_login_to_ci_pipelines.rb diff --git a/app/controllers/ci/pipelines_controller.rb b/app/controllers/ci/pipelines_controller.rb index 4cd7cf62..43b58e4c 100644 --- a/app/controllers/ci/pipelines_controller.rb +++ b/app/controllers/ci/pipelines_controller.rb @@ -1,13 +1,16 @@ -class Ci::PipelinesController < ApplicationController +class Ci::PipelinesController < Ci::BaseController + + before_action :require_login, only: %i[list create] + skip_before_action :connect_to_ci_db # ======流水线相关接口========== # def list - @pipelines = Ci::Pipeline.all + @pipelines = Ci::Pipeline.where('login=?', current_user.login) end def create ActiveRecord::Base.transaction do - pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name]) + pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name], login: current_user.login) pipeline.save! # 默认创建四个初始阶段 diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index c0c15838..842290d8 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -8,6 +8,7 @@ # created_at :datetime not null # updated_at :datetime not null # pipeline_status :string(50) default("unknown"), not null +# login :string(255) # class Ci::Pipeline < Ci::LocalBase diff --git a/app/models/ci/template.rb b/app/models/ci/template.rb index 34aab41d..e7be34a3 100644 --- a/app/models/ci/template.rb +++ b/app/models/ci/template.rb @@ -2,13 +2,14 @@ # # Table name: ci_templates # -# id :integer not null, primary key -# template_name :string(255) not null -# stage_type :string(255) not null -# category :string(255) not null -# content :text(65535) not null -# created_at :datetime not null -# updated_at :datetime not null +# id :integer not null, primary key +# template_name :string(255) not null +# stage_type :string(255) not null +# category :string(255) not null +# content :text(65535) not null +# created_at :datetime not null +# updated_at :datetime not null +# parent_category :string(255) # # Indexes # diff --git a/db/migrate/20210118011710_add_login_to_ci_pipelines.rb b/db/migrate/20210118011710_add_login_to_ci_pipelines.rb new file mode 100644 index 00000000..e1e914e5 --- /dev/null +++ b/db/migrate/20210118011710_add_login_to_ci_pipelines.rb @@ -0,0 +1,5 @@ +class AddLoginToCiPipelines < ActiveRecord::Migration[5.2] + def change + add_column :ci_pipelines, :login, :string + end +end