From ec139870233d4ebcc21c4dae84bc564d39794e95 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 19 Mar 2025 12:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BFpipeline=5Ftype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 1 + app/models/action/pipeline.rb | 4 ---- app/views/api/v1/projects/pipelines/create.json.jbuilder | 5 ++--- app/views/api/v1/projects/pipelines/show.json.jbuilder | 3 +-- db/migrate/202503180515147_add_pipelines_type.rb | 5 +++++ 5 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 db/migrate/202503180515147_add_pipelines_type.rb diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index af83fb15e..0e0956d9e 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -87,6 +87,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yml" @pipeline.branch = params[:branch] || @project.default_branch @pipeline.is_graphic_design = params[:pipeline_type] == 2 ? true : false + @pipeline.pipeline_type = params[:pipeline_type] if params[:pipeline_type].present? @pipeline.save! end diff --git a/app/models/action/pipeline.rb b/app/models/action/pipeline.rb index 7086886a1..c5a511168 100644 --- a/app/models/action/pipeline.rb +++ b/app/models/action/pipeline.rb @@ -36,8 +36,4 @@ class Action::Pipeline < ApplicationRecord validates :pipeline_name, presence: { message: "不能为空" } validates :json, length: { maximum: 65535, too_long: "不能超过65535个字符"} validates :yaml, length: { maximum: 65535, too_long: "不能超过65535个字符"} - - def pipeline_type - self.is_graphic_design? ? 2 : 1 - end end diff --git a/app/views/api/v1/projects/pipelines/create.json.jbuilder b/app/views/api/v1/projects/pipelines/create.json.jbuilder index d82015ade..83b3aabd9 100644 --- a/app/views/api/v1/projects/pipelines/create.json.jbuilder +++ b/app/views/api/v1/projects/pipelines/create.json.jbuilder @@ -1,5 +1,4 @@ json.status 0 json.message "success" -json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, - :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at -# json.project \ No newline at end of file +json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :pipeline_type, + :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at \ No newline at end of file diff --git a/app/views/api/v1/projects/pipelines/show.json.jbuilder b/app/views/api/v1/projects/pipelines/show.json.jbuilder index d82015ade..996bd0556 100644 --- a/app/views/api/v1/projects/pipelines/show.json.jbuilder +++ b/app/views/api/v1/projects/pipelines/show.json.jbuilder @@ -1,5 +1,4 @@ json.status 0 json.message "success" -json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, +json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :pipeline_type, :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at -# json.project \ No newline at end of file diff --git a/db/migrate/202503180515147_add_pipelines_type.rb b/db/migrate/202503180515147_add_pipelines_type.rb new file mode 100644 index 000000000..2f34900c0 --- /dev/null +++ b/db/migrate/202503180515147_add_pipelines_type.rb @@ -0,0 +1,5 @@ +class AddPipelinesType < ActiveRecord::Migration[5.2] + def change + add_column :action_pipelines, :pipeline_type, :integer, :default => 1 + end +end