add: platform communicate
This commit is contained in:
parent
0a00a4bc0e
commit
4a7878d16e
|
@ -0,0 +1,7 @@
|
|||
class Home::PlatformCommunicatesController < ApplicationController
|
||||
|
||||
def index
|
||||
scope = PlatformCommunicate.order(created_at: :desc)
|
||||
@communicates = kaminari_paginate(scope)
|
||||
end
|
||||
end
|
|
@ -1,4 +1,30 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: competitions
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# title :string(255)
|
||||
# start_time :datetime
|
||||
# end_time :datetime
|
||||
# identifier :string(255)
|
||||
# available :boolean default("0")
|
||||
# online_time :datetime
|
||||
# visits :integer default("0")
|
||||
# competition_lists_count :integer default("0")
|
||||
# min_num :integer default("1")
|
||||
# max_num :integer default("1")
|
||||
# enroll_end_time :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# status :integer default("0")
|
||||
# subtitle :string(255)
|
||||
# team_members_count :integer default("0")
|
||||
# limit_type :integer default("0")
|
||||
# show_top :integer default("0")
|
||||
# content :text(65535)
|
||||
#
|
||||
|
||||
class Competition < ApplicationRecord
|
||||
|
||||
enum status: {archived: 0, active: 1}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: platform_communicates
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# title :string(255)
|
||||
# content :string(255)
|
||||
# tag_field :text(65535)
|
||||
# fake_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class PlatformCommunicate < ApplicationRecord
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
json.total_count @communicates.total_count
|
||||
json.communicates do
|
||||
json.array! @communicates.each do |communicate|
|
||||
json.(communicate, :id, :title, :content, :fake_id)
|
||||
json.tag communicate.tag_field.include?(',') ? communicate.tag_field.split(",") : communicate.tag_field
|
||||
json.created_time format_time(communicate.created_at)
|
||||
end
|
||||
end
|
|
@ -105,6 +105,7 @@ Rails.application.routes.draw do
|
|||
namespace :home do
|
||||
resources :platform_statistics, only: [:index]
|
||||
resources :competitions, only:[:index]
|
||||
resources :platform_communicates, only: [:index]
|
||||
end
|
||||
get 'home/index'
|
||||
get 'home/search'
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class CreatePlatformCommunicates < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :platform_communicates do |t|
|
||||
t.string :title
|
||||
t.string :content
|
||||
t.text :tag_field
|
||||
t.integer :fake_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue