Browse Source

add: platform person

pull/278/head
viletyy 4 years ago
parent
commit
d94b3ff2f4
7 changed files with 44 additions and 2 deletions
  1. +7
    -0
      app/controllers/home/platform_people_controller.rb
  2. +1
    -1
      app/models/platform_communicate.rb
  3. +15
    -0
      app/models/platform_person.rb
  4. +7
    -0
      app/views/home/platform_people/index.json.jbuilder
  5. +1
    -0
      config/routes.rb
  6. +1
    -1
      db/migrate/20211202083700_create_platform_communicates.rb
  7. +12
    -0
      db/migrate/20211202090334_create_platform_people.rb

+ 7
- 0
app/controllers/home/platform_people_controller.rb View File

@@ -0,0 +1,7 @@
class Home::PlatformPeopleController < ApplicationController

def index
scope = PlatformPerson.order(created_at: :desc)
@people = kaminari_paginate(scope)
end
end

+ 1
- 1
app/models/platform_communicate.rb View File

@@ -4,7 +4,7 @@
# #
# id :integer not null, primary key # id :integer not null, primary key
# title :string(255) # title :string(255)
# content :string(255)
# content :text(65535)
# tag_field :text(65535) # tag_field :text(65535)
# fake_id :integer # fake_id :integer
# created_at :datetime not null # created_at :datetime not null


+ 15
- 0
app/models/platform_person.rb View File

@@ -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

+ 7
- 0
app/views/home/platform_people/index.json.jbuilder View File

@@ -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

+ 1
- 0
config/routes.rb View File

@@ -106,6 +106,7 @@ Rails.application.routes.draw do
resources :platform_statistics, only: [:index] resources :platform_statistics, only: [:index]
resources :competitions, only:[:index] resources :competitions, only:[:index]
resources :platform_communicates, only: [:index] resources :platform_communicates, only: [:index]
resources :platform_people, only: [:index]
end end
get 'home/index' get 'home/index'
get 'home/search' get 'home/search'


+ 1
- 1
db/migrate/20211202083700_create_platform_communicates.rb View File

@@ -2,7 +2,7 @@ class CreatePlatformCommunicates < ActiveRecord::Migration[5.2]
def change def change
create_table :platform_communicates do |t| create_table :platform_communicates do |t|
t.string :title t.string :title
t.string :content
t.text :content
t.text :tag_field t.text :tag_field
t.integer :fake_id t.integer :fake_id




+ 12
- 0
db/migrate/20211202090334_create_platform_people.rb View File

@@ -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

Loading…
Cancel
Save