diff --git a/app/controllers/library_tags_controller.rb b/app/controllers/library_tags_controller.rb new file mode 100644 index 000000000..0b11027a5 --- /dev/null +++ b/app/controllers/library_tags_controller.rb @@ -0,0 +1,6 @@ +class LibraryTagsController < ApplicationController + def index + library_tags = LibraryTag.all + render_ok(library_tags: library_tags.as_json(only: %i[id name]), count: library_tags.size) + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index af7e0ee3b..f111d4894 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -791,6 +791,7 @@ Rails.application.routes.draw do end resources :libraries, only: [:index, :show, :create, :update, :destroy] + resources :library_tags, only: [:index] scope module: :projects do resources :project_applies, only: [:create] diff --git a/db/migrate/20190926024819_add_library_tag_data.rb b/db/migrate/20190926024819_add_library_tag_data.rb new file mode 100644 index 000000000..b2b40bbf5 --- /dev/null +++ b/db/migrate/20190926024819_add_library_tag_data.rb @@ -0,0 +1,9 @@ +class AddLibraryTagData < ActiveRecord::Migration[5.2] + def up + execute 'INSERT INTO library_tags(id, name) VALUES(4, "高校案例")' + end + + def down + execute 'DELETE FROM library_tags WHERE id = 4 and name = "高校案例"' + end +end