diff --git a/app/controllers/home/platform_people_controller.rb b/app/controllers/home/platform_people_controller.rb new file mode 100644 index 00000000..c3d66d5a --- /dev/null +++ b/app/controllers/home/platform_people_controller.rb @@ -0,0 +1,7 @@ +class Home::PlatformPeopleController < ApplicationController + + def index + scope = PlatformPerson.order(created_at: :desc) + @people = kaminari_paginate(scope) + end +end \ No newline at end of file diff --git a/app/models/platform_communicate.rb b/app/models/platform_communicate.rb index 35de9c02..c5c4ecde 100644 --- a/app/models/platform_communicate.rb +++ b/app/models/platform_communicate.rb @@ -4,7 +4,7 @@ # # id :integer not null, primary key # title :string(255) -# content :string(255) +# content :text(65535) # tag_field :text(65535) # fake_id :integer # created_at :datetime not null diff --git a/app/models/platform_person.rb b/app/models/platform_person.rb new file mode 100644 index 00000000..7ca91250 --- /dev/null +++ b/app/models/platform_person.rb @@ -0,0 +1,15 @@ +# == Schema Information +# +# Table name: platform_people +# +# id :integer not null, primary key +# name :string(255) +# image_url :string(255) +# announcement :string(255) +# content :text(65535) +# created_at :datetime not null +# updated_at :datetime not null +# + +class PlatformPerson < ApplicationRecord +end diff --git a/app/views/home/platform_people/index.json.jbuilder b/app/views/home/platform_people/index.json.jbuilder new file mode 100644 index 00000000..c3736e5e --- /dev/null +++ b/app/views/home/platform_people/index.json.jbuilder @@ -0,0 +1,7 @@ +json.total_count @people.total_count +json.people do + json.array! @people.each do |p| + json.(p, :id, :name, :image_url, :announcement, :content) + json.created_time format_time(p.created_at) + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 81805b51..8da53e6e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -106,6 +106,7 @@ Rails.application.routes.draw do resources :platform_statistics, only: [:index] resources :competitions, only:[:index] resources :platform_communicates, only: [:index] + resources :platform_people, only: [:index] end get 'home/index' get 'home/search' diff --git a/db/migrate/20211202083700_create_platform_communicates.rb b/db/migrate/20211202083700_create_platform_communicates.rb index 315f745e..a4e27917 100644 --- a/db/migrate/20211202083700_create_platform_communicates.rb +++ b/db/migrate/20211202083700_create_platform_communicates.rb @@ -2,7 +2,7 @@ class CreatePlatformCommunicates < ActiveRecord::Migration[5.2] def change create_table :platform_communicates do |t| t.string :title - t.string :content + t.text :content t.text :tag_field t.integer :fake_id diff --git a/db/migrate/20211202090334_create_platform_people.rb b/db/migrate/20211202090334_create_platform_people.rb new file mode 100644 index 00000000..2a25e1d1 --- /dev/null +++ b/db/migrate/20211202090334_create_platform_people.rb @@ -0,0 +1,12 @@ +class CreatePlatformPeople < ActiveRecord::Migration[5.2] + def change + create_table :platform_people do |t| + t.string :name + t.string :image_url + t.string :announcement + t.text :content + + t.timestamps + end + end +end