From 8ae91ff55813d70d847bf22a2e8bd2b2e3512e05 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 7 May 2024 14:08:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=92=8C=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/node_inputs_controller.rb | 75 +++++++++++++++++ .../action/node_selects_controller.rb | 76 +++++++++++++++++ .../action/node_types_controller.rb | 64 +++++++++++++++ app/controllers/action/nodes_controller.rb | 69 ++++++++++++++++ .../action/templates_controller.rb | 68 +++++++++++++++ app/helpers/action/node_helper.rb | 2 + app/models/action/node.rb | 71 ++++++++++++++++ app/models/action/node_input.rb | 27 ++++++ app/models/action/node_select.rb | 39 +++++++++ app/models/action/node_type.rb | 18 ++++ app/models/action/template.rb | 20 +++++ app/views/action/node_inputs/_form.html.erb | 39 +++++++++ .../node_inputs/_node_input.json.jbuilder | 6 ++ .../node_inputs/_node_select.json.jbuilder | 4 + app/views/action/node_inputs/edit.html.erb | 47 +++++++++++ app/views/action/node_inputs/index.html.erb | 46 +++++++++++ .../action/node_inputs/index.json.jbuilder | 20 +++++ app/views/action/node_inputs/new.html.erb | 5 ++ .../action/node_inputs/show.json.jbuilder | 7 ++ app/views/action/node_selects/_form.html.erb | 39 +++++++++ app/views/action/node_selects/edit.html.erb | 46 +++++++++++ app/views/action/node_selects/index.html.erb | 43 ++++++++++ app/views/action/node_selects/new.html.erb | 5 ++ app/views/action/node_types/_form.html.erb | 31 +++++++ app/views/action/node_types/edit.html.erb | 7 ++ app/views/action/node_types/index.html.erb | 37 +++++++++ app/views/action/node_types/new.html.erb | 5 ++ app/views/action/nodes/_form.html.erb | 63 ++++++++++++++ .../action/nodes/_node_input.json.jbuilder | 6 ++ .../action/nodes/_node_select.json.jbuilder | 4 + app/views/action/nodes/edit.html.erb | 7 ++ app/views/action/nodes/index.html.erb | 49 +++++++++++ app/views/action/nodes/index.json.jbuilder | 20 +++++ app/views/action/nodes/new.html.erb | 5 ++ app/views/action/nodes/show.json.jbuilder | 7 ++ app/views/action/templates/_form.html.erb | 43 ++++++++++ app/views/action/templates/edit.html.erb | 6 ++ app/views/action/templates/index.html.erb | 37 +++++++++ .../action/templates/index.json.jbuilder | 3 + app/views/action/templates/new.html.erb | 5 ++ app/views/action/templates/show.json.jbuilder | 1 + config/routes.rb | 31 +++++-- ...20240408010101_create_action_node_types.rb | 10 +++ .../20240408010102_create_action_nodes.rb | 18 ++++ ...240408010213_create_action_node_selects.rb | 17 ++++ ...0240408010227_create_action_node_inputs.rb | 14 ++++ .../20240408010233_create_action_templates.rb | 13 +++ lib/tasks/actions_download.rake | 82 +++++++++++++++++++ 48 files changed, 1348 insertions(+), 9 deletions(-) create mode 100644 app/controllers/action/node_inputs_controller.rb create mode 100644 app/controllers/action/node_selects_controller.rb create mode 100644 app/controllers/action/node_types_controller.rb create mode 100644 app/controllers/action/nodes_controller.rb create mode 100644 app/controllers/action/templates_controller.rb create mode 100644 app/helpers/action/node_helper.rb create mode 100644 app/models/action/node.rb create mode 100644 app/models/action/node_input.rb create mode 100644 app/models/action/node_select.rb create mode 100644 app/models/action/node_type.rb create mode 100644 app/models/action/template.rb create mode 100644 app/views/action/node_inputs/_form.html.erb create mode 100644 app/views/action/node_inputs/_node_input.json.jbuilder create mode 100644 app/views/action/node_inputs/_node_select.json.jbuilder create mode 100644 app/views/action/node_inputs/edit.html.erb create mode 100644 app/views/action/node_inputs/index.html.erb create mode 100644 app/views/action/node_inputs/index.json.jbuilder create mode 100644 app/views/action/node_inputs/new.html.erb create mode 100644 app/views/action/node_inputs/show.json.jbuilder create mode 100644 app/views/action/node_selects/_form.html.erb create mode 100644 app/views/action/node_selects/edit.html.erb create mode 100644 app/views/action/node_selects/index.html.erb create mode 100644 app/views/action/node_selects/new.html.erb create mode 100644 app/views/action/node_types/_form.html.erb create mode 100644 app/views/action/node_types/edit.html.erb create mode 100644 app/views/action/node_types/index.html.erb create mode 100644 app/views/action/node_types/new.html.erb create mode 100644 app/views/action/nodes/_form.html.erb create mode 100644 app/views/action/nodes/_node_input.json.jbuilder create mode 100644 app/views/action/nodes/_node_select.json.jbuilder create mode 100644 app/views/action/nodes/edit.html.erb create mode 100644 app/views/action/nodes/index.html.erb create mode 100644 app/views/action/nodes/index.json.jbuilder create mode 100644 app/views/action/nodes/new.html.erb create mode 100644 app/views/action/nodes/show.json.jbuilder create mode 100644 app/views/action/templates/_form.html.erb create mode 100644 app/views/action/templates/edit.html.erb create mode 100644 app/views/action/templates/index.html.erb create mode 100644 app/views/action/templates/index.json.jbuilder create mode 100644 app/views/action/templates/new.html.erb create mode 100644 app/views/action/templates/show.json.jbuilder create mode 100644 db/migrate/20240408010101_create_action_node_types.rb create mode 100644 db/migrate/20240408010102_create_action_nodes.rb create mode 100644 db/migrate/20240408010213_create_action_node_selects.rb create mode 100644 db/migrate/20240408010227_create_action_node_inputs.rb create mode 100644 db/migrate/20240408010233_create_action_templates.rb create mode 100644 lib/tasks/actions_download.rake diff --git a/app/controllers/action/node_inputs_controller.rb b/app/controllers/action/node_inputs_controller.rb new file mode 100644 index 000000000..65227c657 --- /dev/null +++ b/app/controllers/action/node_inputs_controller.rb @@ -0,0 +1,75 @@ +class Action::NodeInputsController < ApplicationController + before_action :require_admin, except: [:index] + before_action :find_action_node + + def index + @node_inputs = @node.action_node_inputs + respond_to do |format| + format.html + format.json + end + end + + def create + @node_input = Action::NodeInput.new(node_input_params) + @node_input.action_node = @node + respond_to do |format| + if @node_input.save + format.html { redirect_to action_node_node_inputs_path(@node), notice: '创建成功.' } + format.json { render_ok(data: @node_input.as_json) } + else + format.html { render :new } + format.json { render json: @node_input.errors, status: -1 } + end + end + end + + def new + + end + + def show + + end + + def edit + + end + + def update + @node_input.update(node_input_params) + respond_to do |format| + format.html { redirect_to action_node_node_inputs_path(@node), notice: '更新成功.' } + format.json { render_ok(data: @node_input.as_json) } + end + end + + def destroy + if @node_input.destroy! + flash[:success] = '删除成功' + else + flash[:danger] = '删除失败' + end + redirect_to "api/actions/nodes" + end + + private + + def find_action_node + @node = Action::Node.find(params[:node_id]) + if params[:id].present? + @node_input = @node.action_node_inputs.find(params[:id]) + else + @node_input = Action::NodeInput.new + end + + end + + def node_input_params + if params.require(:action_node_input) + params.require(:action_node_input).permit(:name, :input_type, :description, :is_required, :sort_no) + else + params.permit(:name, :input_type, :description, :is_required, :sort_no) + end + end +end diff --git a/app/controllers/action/node_selects_controller.rb b/app/controllers/action/node_selects_controller.rb new file mode 100644 index 000000000..9acd6fc5f --- /dev/null +++ b/app/controllers/action/node_selects_controller.rb @@ -0,0 +1,76 @@ +class Action::NodeSelectsController < ApplicationController + + before_action :require_admin, except: [:index] + before_action :find_action_node + + def index + @node_selects = @node.action_node_selects + respond_to do |format| + format.html + format.json + end + end + + def create + @node_select = Action::NodeSelect.new(node_select_params) + @node_select.action_node = @node + respond_to do |format| + if @node_select.save + format.html { redirect_to action_node_node_selects_path(@node), notice: '创建成功.' } + format.json { render_ok(data: @node_select.as_json) } + else + format.html { render :new } + format.json { render json: @node_select.errors, status: -1 } + end + end + end + + def new + + end + + def show + + end + + def edit + + end + + def update + @node_select.update(node_select_params) + respond_to do |format| + format.html { redirect_to action_node_node_selects_path(@node), notice: '更新成功.' } + format.json { render_ok(data: @node_select.as_json) } + end + end + + def destroy + if @node_select.destroy! + flash[:success] = '删除成功' + else + flash[:danger] = '删除失败' + end + redirect_to "api/actions/nodes" + end + + private + + def find_action_node + @node = Action::Node.find(params[:node_id]) + if params[:id].present? + @node_select = @node.action_node_selects.find(params[:id]) + else + @node_select = Action::NodeSelect.new + end + + end + + def node_select_params + if params.require(:action_node_select) + params.require(:action_node_select).permit(:name, :val, :val_ext, :description, :sort_no) + else + params.permit(:name, :val, :val_ext, :description, :sort_no) + end + end +end diff --git a/app/controllers/action/node_types_controller.rb b/app/controllers/action/node_types_controller.rb new file mode 100644 index 000000000..32508d942 --- /dev/null +++ b/app/controllers/action/node_types_controller.rb @@ -0,0 +1,64 @@ +class Action::NodeTypesController < ApplicationController + before_action :require_admin, except: [:index] + before_action :find_node_type, except: [:index, :create, :new] + + def index + @node_types = Action::NodeType.all + end + + def create + @node_type = Action::NodeType.new(node_types_params) + respond_to do |format| + if @node_type.save + format.html { redirect_to action_node_types_path, notice: '创建成功.' } + format.json { render_ok(data: @node_type.as_json) } + else + format.html { render :new } + format.json { render json: @node_type.errors, status: -1 } + end + end + end + + def show + + end + + def new + @node_type = Action::NodeType.new + end + + def edit + + end + + def update + @node_type.update(node_types_params) + respond_to do |format| + format.html { redirect_to action_node_types_path, notice: '更新成功.' } + format.json { render_ok(data: @node_type.as_json) } + end + end + + def destroy + if @node_type.destroy! + flash[:success] = '删除成功' + else + flash[:danger] = '删除失败' + end + redirect_to action_node_types_path + end + + private + + def find_node_type + @node_type = Action::NodeType.find(params[:id]) + end + + def node_types_params + if params.require(:action_node_type) + params.require(:action_node_type).permit(:name, :description, :sort_no) + else + params.permit(:name, :description, :sort_no) + end + end +end diff --git a/app/controllers/action/nodes_controller.rb b/app/controllers/action/nodes_controller.rb new file mode 100644 index 000000000..e1e7799f4 --- /dev/null +++ b/app/controllers/action/nodes_controller.rb @@ -0,0 +1,69 @@ +class Action::NodesController < ApplicationController + before_action :require_admin, except: [:index] + before_action :find_action_node, except: [:index, :create, :new] + + def index + @node_types = Action::NodeType.all + @no_type_nodes = Action::Node.where(action_node_types_id: nil) + respond_to do |format| + format.html { @nodes = Action::Node.all } + format.json + end + end + + def create + @node = Action::Node.new(node_params) + respond_to do |format| + if @node.save + format.html { redirect_to action_nodes_path, notice: '创建成功.' } + format.json { render_ok(data: @node.as_json) } + else + format.html { render :new } + format.json { render json: @node.errors, status: -1 } + end + end + end + + def new + @node = Action::Node.new + end + + def show + + end + + def edit + + end + + def update + @node.update(node_params) + respond_to do |format| + format.html { redirect_to action_nodes_path, notice: '更新成功.' } + format.json { render_ok(data: @node.as_json) } + end + end + + def destroy + if @node.destroy! + flash[:success] = '删除成功' + else + flash[:danger] = '删除失败' + end + redirect_to action_nodes_path + end + + private + + def find_action_node + @node = Action::Node.find(params[:id]) + end + + def node_params + if params.require(:action_node) + params.require(:action_node).permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no) + else + params.permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no) + end + end +end diff --git a/app/controllers/action/templates_controller.rb b/app/controllers/action/templates_controller.rb new file mode 100644 index 000000000..092d38d64 --- /dev/null +++ b/app/controllers/action/templates_controller.rb @@ -0,0 +1,68 @@ +class Action::TemplatesController < ApplicationController + before_action :require_admin, except: [:index] + before_action :find_action_template, except: [:index, :create, :new] + + def index + @templates = Action::Template.all + respond_to do |format| + format.html + format.json + end + end + + def create + @template = Action::Template.new(templates_params) + respond_to do |format| + if @template.save + format.html { redirect_to action_templates_path, notice: '创建成功.' } + format.json { render_ok(data: @template.as_json) } + else + format.html { render :new } + format.json { render json: @template.errors, status: -1 } + end + end + end + + def show + + end + + def new + @template = Action::Template.new + end + + def edit + + end + + def update + @template.update(templates_params) + respond_to do |format| + format.html { redirect_to action_templates_path, notice: '更新成功.' } + format.json { render_ok(data: @template.as_json) } + end + end + + def destroy + if @template.destroy! + flash[:success] = '删除成功' + else + flash[:danger] = '删除失败' + end + redirect_to action_templates_path + end + + private + + def find_action_template + @template = Action::Template.find(params[:id]) + end + + def templates_params + if params.require(:action_template) + params.require(:action_template).permit(:name, :description, :img, :sort_no, :json, :yaml) + else + params.permit(:name, :description, :img, :sort_no, :json, :yaml) + end + end +end diff --git a/app/helpers/action/node_helper.rb b/app/helpers/action/node_helper.rb new file mode 100644 index 000000000..05d08da2f --- /dev/null +++ b/app/helpers/action/node_helper.rb @@ -0,0 +1,2 @@ +module Action::NodeHelper +end diff --git a/app/models/action/node.rb b/app/models/action/node.rb new file mode 100644 index 000000000..69e45b3a8 --- /dev/null +++ b/app/models/action/node.rb @@ -0,0 +1,71 @@ +# == Schema Information +# +# Table name: action_nodes +# +# id :integer not null, primary key +# name :string(255) +# full_name :string(255) +# description :string(255) +# icon :string(255) +# action_node_types_id :integer +# is_local :boolean default("0") +# local_url :string(255) +# yaml :text(65535) +# sort_no :integer default("0") +# use_count :integer default("0") +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_action_nodes_on_action_types_id (action_node_types_id) +# index_action_nodes_on_user_id (user_id) +# + +class Action::Node < ApplicationRecord + self.table_name = 'action_nodes' + default_scope { order(sort_no: :asc) } + + has_many :action_node_inputs, :class_name => 'Action::NodeInput', foreign_key: "action_nodes_id" + has_many :action_node_selects, :class_name => 'Action::NodeSelect', foreign_key: "action_nodes_id" + belongs_to :action_node_type, :class_name => 'Action::NodeType', foreign_key: "action_node_types_id" + + belongs_to :user, optional: true + + + # def content_yaml + # "foo".to_yaml + # <<~YAML + # - name: Set up JDK ${{ matrix.java }} + # uses: actions/setup-java@v3 + # with: + # distribution: 'temurin' + # java-version: ${{ matrix.java }} + # YAML + # end + + def yaml_hash + <<~YAML + name: Check dist + + on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + workflow_dispatch: + + jobs: + call-check-dist: + name: Check dist/ + uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main + with: + node-version: '20.x' + YAML + end +end diff --git a/app/models/action/node_input.rb b/app/models/action/node_input.rb new file mode 100644 index 000000000..4f3825170 --- /dev/null +++ b/app/models/action/node_input.rb @@ -0,0 +1,27 @@ +# == Schema Information +# +# Table name: action_node_inputs +# +# id :integer not null, primary key +# action_nodes_id :integer +# name :string(255) +# input_type :string(255) +# description :string(255) +# is_required :boolean default("0") +# sort_no :string(255) default("0") +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_action_node_inputs_on_action_nodes_id (action_nodes_id) +# index_action_node_inputs_on_user_id (user_id) +# + +class Action::NodeInput < ApplicationRecord + self.table_name = 'action_node_inputs' + default_scope { order(sort_no: :asc) } + + belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" +end diff --git a/app/models/action/node_select.rb b/app/models/action/node_select.rb new file mode 100644 index 000000000..25be51f99 --- /dev/null +++ b/app/models/action/node_select.rb @@ -0,0 +1,39 @@ +# == Schema Information +# +# Table name: action_node_selects +# +# id :integer not null, primary key +# action_nodes_id :integer +# name :string(255) +# val :string(255) +# val_ext :string(255) +# description :string(255) +# download_url :string(255) +# sort_no :integer default("0") +# use_count :integer default("0") +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_action_node_selects_on_action_nodes_id (action_nodes_id) +# index_action_node_selects_on_name (name) +# index_action_node_selects_on_user_id (user_id) +# + +class Action::NodeSelect < ApplicationRecord + self.table_name = 'action_node_selects' + default_scope { order(sort_no: :asc) } + + belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" + belongs_to :user, optional: true + + def value + if self.val_ext.blank? + self.val + else + "#{self.val}@#{self.val_ext}" + end + end +end diff --git a/app/models/action/node_type.rb b/app/models/action/node_type.rb new file mode 100644 index 000000000..7ce78b0fb --- /dev/null +++ b/app/models/action/node_type.rb @@ -0,0 +1,18 @@ +# == Schema Information +# +# Table name: action_node_types +# +# id :integer not null, primary key +# name :string(255) +# description :string(255) +# sort_no :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +class Action::NodeType < ApplicationRecord + self.table_name = 'action_node_types' + default_scope { order(sort_no: :asc) } + + has_many :action_nodes, :class_name => 'Action::Node', foreign_key: "action_node_types_id" +end diff --git a/app/models/action/template.rb b/app/models/action/template.rb new file mode 100644 index 000000000..34b669f66 --- /dev/null +++ b/app/models/action/template.rb @@ -0,0 +1,20 @@ +# == Schema Information +# +# Table name: action_templates +# +# id :integer not null, primary key +# name :string(255) +# description :string(255) +# img :string(255) +# sort_no :string(255) default("0") +# json :text(65535) +# yaml :text(65535) +# created_at :datetime not null +# updated_at :datetime not null +# + +class Action::Template < ApplicationRecord + self.table_name = 'action_templates' + default_scope { order(sort_no: :asc) } + +end diff --git a/app/views/action/node_inputs/_form.html.erb b/app/views/action/node_inputs/_form.html.erb new file mode 100644 index 000000000..deccfa69e --- /dev/null +++ b/app/views/action/node_inputs/_form.html.erb @@ -0,0 +1,39 @@ +<%= form_with(model: node_input, url: action_node_node_inputs_path(@node), local: true) do |form| %> + <% if node_input.errors.any? %> +
+

<%= pluralize(node_input.errors.count, "error") %> prohibited this node_input from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :name, "参数名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :input_type, "参数类型" %> + <%= form.text_field :input_type %> +
+
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+
+ <%= form.label :is_required, "是否必填项" %> + <%= form.check_box("is_required", {}, "true", "false") %> +
+
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+ +
+ + <%= form.submit("保存") %> +
+<% end %> diff --git a/app/views/action/node_inputs/_node_input.json.jbuilder b/app/views/action/node_inputs/_node_input.json.jbuilder new file mode 100644 index 000000000..9f0a6074b --- /dev/null +++ b/app/views/action/node_inputs/_node_input.json.jbuilder @@ -0,0 +1,6 @@ +json.extract! node_input, :id, :name, :input_type, :description +if node_input.input_type.to_s == "select" + json.select node.action_node_selects do |node_select| + json.partial! "node_select", locals: { node_select: node_select, node: node } + end +end diff --git a/app/views/action/node_inputs/_node_select.json.jbuilder b/app/views/action/node_inputs/_node_select.json.jbuilder new file mode 100644 index 000000000..4e90508e9 --- /dev/null +++ b/app/views/action/node_inputs/_node_select.json.jbuilder @@ -0,0 +1,4 @@ +json.extract! node_select, :id, :version +if node.is_local? + json.local_url node.local_url +end diff --git a/app/views/action/node_inputs/edit.html.erb b/app/views/action/node_inputs/edit.html.erb new file mode 100644 index 000000000..6ae9f8a78 --- /dev/null +++ b/app/views/action/node_inputs/edit.html.erb @@ -0,0 +1,47 @@ +

编辑 + +

+ +<%= form_with(model: @node_input, url: action_node_node_input_path(@node,@node_input), local: true) do |form| %> + <% if @node_input.errors.any? %> +
+

<%= pluralize(@node_input.errors.count, "error") %> prohibited this node_input from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :name, "参数名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :input_type, "参数类型" %> + <%= form.text_field :input_type %> +
+
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+
+ <%= form.label :is_required, "是否必填项" %> + <%= form.check_box("is_required", {}, "true", "false") %> +
+ +
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+ +
+ + <%= form.submit("保存赛事") %> +
+<% end %> + + +<%= link_to 'Back', action_node_node_inputs_path(@node) %> diff --git a/app/views/action/node_inputs/index.html.erb b/app/views/action/node_inputs/index.html.erb new file mode 100644 index 000000000..f070b3dd7 --- /dev/null +++ b/app/views/action/node_inputs/index.html.erb @@ -0,0 +1,46 @@ +<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + +

action 节点参数配置<%= link_to '>>>Back action节点首页', action_nodes_path %> + +

+

说明:该界面适用于action 节点参数配置

+ + + + + + + + + + + + + + + + + <% @node_inputs.each do |info| %> + + + + + + + + + + + + <% end %> + +
ID参数名称参数输入类型参数描述是否必填项排序号更新时间操作
<%= info.id %><%= info.name %><%= info.input_type %> + <% if info.input_type == "select" %> + <%= select_tag(:version, options_for_select(@node.action_node_selects.map(&:value)), class: 'form-control') %> + <%= link_to '修改选择项', edit_action_node_node_input_path(@node.id, info) %> + <% end %> + <%= info.description %><%= info.is_required %><%= info.sort_no %><%= info.updated_at&.strftime('%Y-%m-%d %H:%M') %><%= link_to '编辑', edit_action_node_node_input_path(@node.id, info) %><%= link_to 'Destroy', action_node_node_input_path(@node, info), method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to '新增', new_action_node_node_input_path(@node) %> diff --git a/app/views/action/node_inputs/index.json.jbuilder b/app/views/action/node_inputs/index.json.jbuilder new file mode 100644 index 000000000..3909639ce --- /dev/null +++ b/app/views/action/node_inputs/index.json.jbuilder @@ -0,0 +1,20 @@ +json.types @node_types.each do |node_type| + if node_type.name.to_s == "未分类" + json.extract! node_type, :id, :name + json.nodes @no_type_nodes do |node| + json.extract! node, :id, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count + json.inputs node.action_node_inputs do |node_input| + json.partial! "node_input", locals: { node_input: node_input, node: node } + end + end + else + json.extract! node_type, :id, :name + json.nodes node_type.action_nodes do |node| + json.extract! node, :id, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count + json.inputs node.action_node_inputs do |node_input| + json.partial! "node_input", locals: { node_input: node_input, node: node } + end + end + end + +end diff --git a/app/views/action/node_inputs/new.html.erb b/app/views/action/node_inputs/new.html.erb new file mode 100644 index 000000000..965ae9378 --- /dev/null +++ b/app/views/action/node_inputs/new.html.erb @@ -0,0 +1,5 @@ +

新增

+ +<%= render 'form', node_input: @node_input %> + +<%= link_to 'Back', action_node_node_inputs_path(@node) %> \ No newline at end of file diff --git a/app/views/action/node_inputs/show.json.jbuilder b/app/views/action/node_inputs/show.json.jbuilder new file mode 100644 index 000000000..64548544d --- /dev/null +++ b/app/views/action/node_inputs/show.json.jbuilder @@ -0,0 +1,7 @@ +json.status 0 +json.message "success" + +json.extract! @node, :id, :name, :full_name, :description, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no, :use_count +json.inputs @node.action_node_inputs do |node_input| + json.partial! "node_input", locals: { node_input: node_input, node: @node } +end \ No newline at end of file diff --git a/app/views/action/node_selects/_form.html.erb b/app/views/action/node_selects/_form.html.erb new file mode 100644 index 000000000..7dd4a6637 --- /dev/null +++ b/app/views/action/node_selects/_form.html.erb @@ -0,0 +1,39 @@ +<%= form_with(model: node_select, url: action_node_node_selects_path(@node), local: true) do |form| %> + <% if node_select.errors.any? %> +
+

<%= pluralize(node_select.errors.count, "error") %> prohibited this node select from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :name, "选择项名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :val, "选择项值" %> + <%= form.text_field :val %> +
+
+ <%= form.label :val_ext, "选择项值扩展" %> + <%= form.text_field :val_ext %> +
+
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+ +
+ + <%= form.submit("保存") %> +
+<% end %> diff --git a/app/views/action/node_selects/edit.html.erb b/app/views/action/node_selects/edit.html.erb new file mode 100644 index 000000000..fca5b3ce7 --- /dev/null +++ b/app/views/action/node_selects/edit.html.erb @@ -0,0 +1,46 @@ +

编辑 + +

+ +<%= form_with(model: @node_select, url: action_node_node_select_path(@node,@node_select), local: true) do |form| %> + <% if @node_select.errors.any? %> +
+

<%= pluralize(@node_select.errors.count, "error") %> prohibited this node select from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :name, "选择项名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :val, "选择项值" %> + <%= form.text_field :val %> +
+
+ <%= form.label :val_ext, "选择项值扩展" %> + <%= form.text_field :val_ext %> +
+
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+ +
+ + <%= form.submit("保存") %> +
+<% end %> + + +<%= link_to 'Back', action_node_node_inputs_path(@node) %> diff --git a/app/views/action/node_selects/index.html.erb b/app/views/action/node_selects/index.html.erb new file mode 100644 index 000000000..09d427d97 --- /dev/null +++ b/app/views/action/node_selects/index.html.erb @@ -0,0 +1,43 @@ +<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + +

action 节点参数配置<%= link_to '>>>Back action节点首页', action_nodes_path %> + +

+

说明:该界面适用于action 节点参数配置

+ + + + + + + + + + + + + + + + + + <% @node_selects.each do |info| %> + + + + + + + + + + + + + <% end %> + +
ID选择项名称选择项值选择项值扩展描述下载地址排序号更新时间操作
<%= info.id %><%= info.name %><%= info.val %><%= info.val_ext %><%= info.description %><%= info.download_url %><%= info.sort_no %><%= info.updated_at&.strftime('%Y-%m-%d %H:%M') %><%= link_to '编辑', edit_action_node_node_select_path(@node.id, info) %><%= link_to 'Destroy', action_node_node_select_path(@node, info), method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to '新增', new_action_node_node_input_path(@node) %> diff --git a/app/views/action/node_selects/new.html.erb b/app/views/action/node_selects/new.html.erb new file mode 100644 index 000000000..c2fcaf123 --- /dev/null +++ b/app/views/action/node_selects/new.html.erb @@ -0,0 +1,5 @@ +

新增

+ +<%= render 'form', node_select: @node_select %> + +<%= link_to 'Back', action_node_node_selects_path(@node) %> \ No newline at end of file diff --git a/app/views/action/node_types/_form.html.erb b/app/views/action/node_types/_form.html.erb new file mode 100644 index 000000000..9a6a5d693 --- /dev/null +++ b/app/views/action/node_types/_form.html.erb @@ -0,0 +1,31 @@ +<%= form_with(model: node_type, local: true) do |form| %> + <% if node_type.errors.any? %> +
+

<%= pluralize(node_type.errors.count, "error") %> prohibited this node type from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :name, "分类名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+ +
+ + <%= form.submit("保存") %> +
+<% end %> diff --git a/app/views/action/node_types/edit.html.erb b/app/views/action/node_types/edit.html.erb new file mode 100644 index 000000000..9a44930a4 --- /dev/null +++ b/app/views/action/node_types/edit.html.erb @@ -0,0 +1,7 @@ +

编辑 + +

+<%= render 'form', node_type: @node_type %> + + +<%= link_to 'Back', action_node_types_path %> diff --git a/app/views/action/node_types/index.html.erb b/app/views/action/node_types/index.html.erb new file mode 100644 index 000000000..812d06a24 --- /dev/null +++ b/app/views/action/node_types/index.html.erb @@ -0,0 +1,37 @@ +<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + +

action 节点分类配置<%= link_to '>>>Back action节点首页', action_nodes_path %> + +

+

说明:该界面适用于action 节点分类配置

+ + + + + + + + + + + + + + + <% @node_types.each do |info| %> + + + + + + + + + + <% end %> + +
ID分类名称描述排序号更新时间操作
<%= info.id %><%= info.name %><%= info.description %><%= info.sort_no %><%= info.updated_at&.strftime('%Y-%m-%d %H:%M') %><%= link_to '编辑', edit_action_node_type_path(info) %><%= link_to 'Destroy', action_node_type_path(info), method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to '新增', new_action_node_type_path %> diff --git a/app/views/action/node_types/new.html.erb b/app/views/action/node_types/new.html.erb new file mode 100644 index 000000000..1e053b9da --- /dev/null +++ b/app/views/action/node_types/new.html.erb @@ -0,0 +1,5 @@ +

新增

+ +<%= render 'form', node_type: @node_type %> + +<%= link_to 'Back', action_node_types_path %> \ No newline at end of file diff --git a/app/views/action/nodes/_form.html.erb b/app/views/action/nodes/_form.html.erb new file mode 100644 index 000000000..4e40f0ff0 --- /dev/null +++ b/app/views/action/nodes/_form.html.erb @@ -0,0 +1,63 @@ +<%= form_with(model: node, local: true) do |form| %> + <%# if node.errors.any? %> + + + + + <%# node.errors.full_messages.each do |message| %> + + <%# end %> + + + <%# end %> +
+ + <%= form.select :action_node_types_id, options_for_select(Action::NodeType.all.map { |key| [key.name, key.id]}, node.action_node_types_id), {}, class: "form-control" %> +
+ +
+ <%= form.label :name, "节点名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :full_name, "节点全称" %> + <%= form.text_field :full_name %> +
+ +
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+ +
+ <%= form.label :icon, "Icon图标" %> + <%= form.text_field :icon %> +
+ +
+ <%= form.label :is_local, "是否本地化" %> + <%= form.check_box("is_local", {}, "true", "false") %> +
+ +
+ <%= form.label :local_url, "本地化地址" %> + <%= form.text_field :local_url, :style => 'width:1200px;' %> +
+ + + +
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+ +
+ <%= form.label :yaml, "yaml语法代码" %> + <%= form.text_area :yaml, rows: 5, :style => 'width:1200px;' %> +
+ +
+ + <%= form.submit("保存") %> +
+<% end %> diff --git a/app/views/action/nodes/_node_input.json.jbuilder b/app/views/action/nodes/_node_input.json.jbuilder new file mode 100644 index 000000000..9f0a6074b --- /dev/null +++ b/app/views/action/nodes/_node_input.json.jbuilder @@ -0,0 +1,6 @@ +json.extract! node_input, :id, :name, :input_type, :description +if node_input.input_type.to_s == "select" + json.select node.action_node_selects do |node_select| + json.partial! "node_select", locals: { node_select: node_select, node: node } + end +end diff --git a/app/views/action/nodes/_node_select.json.jbuilder b/app/views/action/nodes/_node_select.json.jbuilder new file mode 100644 index 000000000..897e3f8ef --- /dev/null +++ b/app/views/action/nodes/_node_select.json.jbuilder @@ -0,0 +1,4 @@ +json.extract! node_select, :id, :val +if node.is_local? + json.local_url node.local_url +end diff --git a/app/views/action/nodes/edit.html.erb b/app/views/action/nodes/edit.html.erb new file mode 100644 index 000000000..ee9cb0947 --- /dev/null +++ b/app/views/action/nodes/edit.html.erb @@ -0,0 +1,7 @@ +

编辑 + +

+ +<%= render 'form', node: @node %> + +<%= link_to 'Back', action_nodes_path %> diff --git a/app/views/action/nodes/index.html.erb b/app/views/action/nodes/index.html.erb new file mode 100644 index 000000000..763a8e467 --- /dev/null +++ b/app/views/action/nodes/index.html.erb @@ -0,0 +1,49 @@ +<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + +

action 节点配置

+

>>前往节点分类配置

+

>>前往模板配置

+

说明:该界面适用于action 节点配置参数配置

+ + + + + + + + + + + + + + + + + + + + + <% @nodes.each do |info| %> + + + + + + + + + + + + + + + + <% end %> + +
ID节点名称节点全称节点描述分类排序号更新时间操作
<%= info.id %><%= info.name %><%= info.full_name %><%= info.description %><%= info.action_node_type&.name %><%= info.sort_no %><%= info.updated_at&.strftime('%Y-%m-%d %H:%M') %><%= link_to '编辑', edit_action_node_path(info) %><%= link_to '参数列表', action_node_node_inputs_path(info) %><%= link_to 'Destroy', info, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to '新增', new_action_node_path %> diff --git a/app/views/action/nodes/index.json.jbuilder b/app/views/action/nodes/index.json.jbuilder new file mode 100644 index 000000000..3909639ce --- /dev/null +++ b/app/views/action/nodes/index.json.jbuilder @@ -0,0 +1,20 @@ +json.types @node_types.each do |node_type| + if node_type.name.to_s == "未分类" + json.extract! node_type, :id, :name + json.nodes @no_type_nodes do |node| + json.extract! node, :id, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count + json.inputs node.action_node_inputs do |node_input| + json.partial! "node_input", locals: { node_input: node_input, node: node } + end + end + else + json.extract! node_type, :id, :name + json.nodes node_type.action_nodes do |node| + json.extract! node, :id, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count + json.inputs node.action_node_inputs do |node_input| + json.partial! "node_input", locals: { node_input: node_input, node: node } + end + end + end + +end diff --git a/app/views/action/nodes/new.html.erb b/app/views/action/nodes/new.html.erb new file mode 100644 index 000000000..4a5d2fae9 --- /dev/null +++ b/app/views/action/nodes/new.html.erb @@ -0,0 +1,5 @@ +

新增

+ +<%= render 'form', node: @node %> + +<%= link_to 'Back', action_nodes_path %> \ No newline at end of file diff --git a/app/views/action/nodes/show.json.jbuilder b/app/views/action/nodes/show.json.jbuilder new file mode 100644 index 000000000..64548544d --- /dev/null +++ b/app/views/action/nodes/show.json.jbuilder @@ -0,0 +1,7 @@ +json.status 0 +json.message "success" + +json.extract! @node, :id, :name, :full_name, :description, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no, :use_count +json.inputs @node.action_node_inputs do |node_input| + json.partial! "node_input", locals: { node_input: node_input, node: @node } +end \ No newline at end of file diff --git a/app/views/action/templates/_form.html.erb b/app/views/action/templates/_form.html.erb new file mode 100644 index 000000000..7d93cb76d --- /dev/null +++ b/app/views/action/templates/_form.html.erb @@ -0,0 +1,43 @@ +<%= form_with(model: template, local: true) do |form| %> + <% if template.errors.any? %> +
+

<%= pluralize(template.errors.count, "error") %> prohibited this node type from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :name, "模板名称" %> + <%= form.text_field :name %> +
+
+ <%= form.label :description, "描述" %> + <%= form.text_area :description, rows: 5, :style => 'width:800px;' %> +
+
+ <%= form.label :img, "配图" %> + <%= form.text_field :img %> +
+
+ <%= form.label :sort_no, "排序号" %> + <%= form.text_field :sort_no %> +
+
+ <%= form.label :yaml, "yaml语法代码" %> + <%= form.text_area :yaml, rows: 5, :style => 'width:1200px;' %> +
+
+ <%= form.label :json, "json语法代码" %> + <%= form.text_area :json, rows: 5, :style => 'width:1200px;' %> +
+ +
+ + <%= form.submit("保存") %> +
+<% end %> diff --git a/app/views/action/templates/edit.html.erb b/app/views/action/templates/edit.html.erb new file mode 100644 index 000000000..f9c1effc1 --- /dev/null +++ b/app/views/action/templates/edit.html.erb @@ -0,0 +1,6 @@ +

编辑 + +

+<%= render 'form', template: @template %> + +<%= link_to 'Back', action_templates_path %> diff --git a/app/views/action/templates/index.html.erb b/app/views/action/templates/index.html.erb new file mode 100644 index 000000000..b71aaede9 --- /dev/null +++ b/app/views/action/templates/index.html.erb @@ -0,0 +1,37 @@ +<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + +

action 模板配置<%= link_to '>>>Back action节点首页', action_nodes_path %> + +

+

说明:该界面适用于action 模板配置

+ + + + + + + + + + + + + + + <% @templates.each do |info| %> + + + + + + + + + + <% end %> + +
ID模板名称描述排序号更新时间操作
<%= info.id %><%= info.name %><%= info.description %><%= info.sort_no %><%= info.updated_at&.strftime('%Y-%m-%d %H:%M') %><%= link_to '编辑', edit_action_template_path(info) %><%= link_to 'Destroy', action_template_path(info), method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to '新增', new_action_template_path %> diff --git a/app/views/action/templates/index.json.jbuilder b/app/views/action/templates/index.json.jbuilder new file mode 100644 index 000000000..da534c842 --- /dev/null +++ b/app/views/action/templates/index.json.jbuilder @@ -0,0 +1,3 @@ +json.templates @templates.each do |tpl| + json.extract! tpl, :id, :name, :description, :img, :sort_no, :json, :yaml +end diff --git a/app/views/action/templates/new.html.erb b/app/views/action/templates/new.html.erb new file mode 100644 index 000000000..e67c6a674 --- /dev/null +++ b/app/views/action/templates/new.html.erb @@ -0,0 +1,5 @@ +

新增

+ +<%= render 'form', template: @template %> + +<%= link_to 'Back', action_templates_path %> \ No newline at end of file diff --git a/app/views/action/templates/show.json.jbuilder b/app/views/action/templates/show.json.jbuilder new file mode 100644 index 000000000..5db67424b --- /dev/null +++ b/app/views/action/templates/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @template, :id, :name, :description, :img, :sort_no, :json, :yaml \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b5f5c75ca..478531d2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -510,6 +510,19 @@ Rails.application.routes.draw do end end + # scope module: :action do + # + # end + + namespace :action do + resources :nodes do + resources :node_inputs + resources :node_selects + end + resources :node_types + resources :templates + end + # Project Area START scope "/:owner/:repo",constraints: { repo: /[^\/]+/ } do scope do @@ -1095,15 +1108,15 @@ Rails.application.routes.draw do resources :sub_repertoires, only: [:index, :create, :edit, :update, :destroy] resources :tag_repertoires, only: [:index, :create, :edit, :update, :destroy] - resources :salesmans, only: [:index, :create, :edit, :update, :destroy] do - post :batch_add, on: :collection - end - resources :salesman_channels, only: [:index, :create, :edit, :update, :destroy] do - post :batch_add, on: :collection - end - resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do - post :batch_add, on: :collection - end + # resources :salesmans, only: [:index, :create, :edit, :update, :destroy] do + # post :batch_add, on: :collection + # end + # resources :salesman_channels, only: [:index, :create, :edit, :update, :destroy] do + # post :batch_add, on: :collection + # end + # resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do + # post :batch_add, on: :collection + # end end diff --git a/db/migrate/20240408010101_create_action_node_types.rb b/db/migrate/20240408010101_create_action_node_types.rb new file mode 100644 index 000000000..b9c530784 --- /dev/null +++ b/db/migrate/20240408010101_create_action_node_types.rb @@ -0,0 +1,10 @@ +class CreateActionNodeTypes < ActiveRecord::Migration[5.2] + def change + create_table :action_node_types do |t| + t.string :name + t.string :description + t.integer :sort_no, default: 0 + t.timestamps + end + end +end diff --git a/db/migrate/20240408010102_create_action_nodes.rb b/db/migrate/20240408010102_create_action_nodes.rb new file mode 100644 index 000000000..67331e4db --- /dev/null +++ b/db/migrate/20240408010102_create_action_nodes.rb @@ -0,0 +1,18 @@ +class CreateActionNodes < ActiveRecord::Migration[5.2] + def change + create_table :action_nodes do |t| + t.string :name + t.string :full_name + t.string :description + t.string :icon + t.references :action_node_types + t.boolean :is_local, default: false + t.string :local_url + t.text :yaml + t.integer :sort_no, default: 0 + t.integer :use_count, default: 0 + t.references :user + t.timestamps + end + end +end diff --git a/db/migrate/20240408010213_create_action_node_selects.rb b/db/migrate/20240408010213_create_action_node_selects.rb new file mode 100644 index 000000000..5f49bcd8b --- /dev/null +++ b/db/migrate/20240408010213_create_action_node_selects.rb @@ -0,0 +1,17 @@ +class CreateActionNodeSelects < ActiveRecord::Migration[5.2] + def change + create_table :action_node_selects do |t| + t.references :action_nodes + t.string :name + t.string :val + t.string :val_ext + t.string :description + t.string :download_url + t.integer :sort_no, default: 0 + t.integer :use_count, default: 0 + t.references :user + t.timestamps + t.index :name + end + end +end diff --git a/db/migrate/20240408010227_create_action_node_inputs.rb b/db/migrate/20240408010227_create_action_node_inputs.rb new file mode 100644 index 000000000..501844e28 --- /dev/null +++ b/db/migrate/20240408010227_create_action_node_inputs.rb @@ -0,0 +1,14 @@ +class CreateActionNodeInputs < ActiveRecord::Migration[5.2] + def change + create_table :action_node_inputs do |t| + t.references :action_nodes + t.string :name + t.string :input_type + t.string :description + t.boolean :is_required, default: false + t.string :sort_no, default: 0 + t.references :user + t.timestamps + end + end +end diff --git a/db/migrate/20240408010233_create_action_templates.rb b/db/migrate/20240408010233_create_action_templates.rb new file mode 100644 index 000000000..47d335094 --- /dev/null +++ b/db/migrate/20240408010233_create_action_templates.rb @@ -0,0 +1,13 @@ +class CreateActionTemplates < ActiveRecord::Migration[5.2] + def change + create_table :action_templates do |t| + t.string :name + t.string :description + t.string :img + t.string :sort_no, default: 0 + t.text :json + t.text :yaml + t.timestamps + end + end +end diff --git a/lib/tasks/actions_download.rake b/lib/tasks/actions_download.rake new file mode 100644 index 000000000..bad2d535e --- /dev/null +++ b/lib/tasks/actions_download.rake @@ -0,0 +1,82 @@ +# actions 下载包 +# node go java +namespace :actions_download do + + task go: :environment do + # curl -X GET --header 'Content-Type: application/json;charset=UTF-8' 'https://gitee.com/api/v5/repos/mindspore/mindspore/issues?access_token=5ccebd935915fb6cfcae634b161047a2&state=open&sort=created&direction=desc&page=1&per_page=10' + # api_url = "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json" + api_url = "https://testgitea2.trustie.net/actions/go-versions/raw/branch/main/versions-manifest.json" + uri = URI.parse(api_url) + response = Net::HTTP.get_response(uri) + puts "gitee api response.code ===== #{response.code}" + lists = JSON.parse(response.body) + puts "lists.size =====#{lists.size}" + lists.each do |data| + version_arr = data['version'].to_s.split(".") + if version_arr[0].to_i == 1 && version_arr[1].to_i >= 18 + action_node_select = Action::NodeSelect.find_or_initialize_by(name: "go-version", val: data["version"]) + puts data["version"] + data['files'].each do |file| + if file['platform'] == "linux" + puts "download_url==#{file['download_url']}" + action_node_select.download_url = file['download_url'] + end + end + action_node_select.action_nodes_id=1 + action_node_select.save + end + end + end + + task node: :environment do + # curl -X GET --header 'Content-Type: application/json;charset=UTF-8' 'https://gitee.com/api/v5/repos/mindspore/mindspore/issues?access_token=5ccebd935915fb6cfcae634b161047a2&state=open&sort=created&direction=desc&page=1&per_page=10' + # api_url = "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json" + api_url = "https://testgitea2.trustie.net/actions/node-versions/raw/branch/main/versions-manifest.json" + uri = URI.parse(api_url) + response = Net::HTTP.get_response(uri) + puts "gitee api response.code ===== #{response.code}" + lists = JSON.parse(response.body) + puts "lists.size =====#{lists.size}" + lists.each do |data| + version_arr = data['version'].to_s.split(".") + if version_arr[0].to_i >= 16 + puts data["version"] + action_node_select = Action::NodeSelect.find_or_initialize_by(name: "node-version", val: data["version"]) + data['files'].each do |file| + if file['platform'] == "linux" + puts "download_url==#{file['download_url']}" + action_node_select.download_url = file['download_url'] + end + end + action_node_select.action_nodes_id=2 + action_node_select.save + end + end + end + + task java: :environment do + # curl -X GET --header 'Content-Type: application/json;charset=UTF-8' 'https://gitee.com/api/v5/repos/mindspore/mindspore/issues?access_token=5ccebd935915fb6cfcae634b161047a2&state=open&sort=created&direction=desc&page=1&per_page=10' + # api_url = "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json" + [0, 1, 2].each do |page| + api_url = "https://api.adoptium.net/v3/assets/version/%5B1.0,100.0%5D?project=jdk&vendor=adoptium&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&os=linux&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=#{page}" + uri = URI.parse(api_url) + response = Net::HTTP.get_response(uri) + puts "gitee api response.code ===== #{response.code}" + lists = JSON.parse(response.body) + puts "lists.size =====#{lists.size}" + lists.each do |data| + puts data["release_name"] + puts "#{data['version_data']['major']}@#{data['version_data']['openjdk_version']}" + action_node_select = Action::NodeSelect.find_or_initialize_by(name: "java-version", val: "#{data['version_data']['major']}", val_ext: "#{data['version_data']['openjdk_version']}") + data['binaries'].each do |file| + puts "download_url==#{file['package']['link']}" + action_node_select.download_url = file['package']['link'] + end + action_node_select.action_nodes_id=5 + action_node_select.save + end + end + + end + +end \ No newline at end of file