diff --git a/app/models/topic.rb b/app/models/topic.rb new file mode 100644 index 000000000..a859d9029 --- /dev/null +++ b/app/models/topic.rb @@ -0,0 +1,17 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +class Topic < ApplicationRecord + + default_scope { order(order_index: :desc)} +end diff --git a/app/models/topic/activity_forum.rb b/app/models/topic/activity_forum.rb new file mode 100644 index 000000000..8cf9adf83 --- /dev/null +++ b/app/models/topic/activity_forum.rb @@ -0,0 +1,17 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页平台动态 +class Topic::ActivityForum < Topic + +end diff --git a/app/models/topic/banner.rb b/app/models/topic/banner.rb new file mode 100644 index 000000000..e5b77bec0 --- /dev/null +++ b/app/models/topic/banner.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页banner +class Topic::Banner < Topic +end diff --git a/app/models/topic/card.rb b/app/models/topic/card.rb new file mode 100644 index 000000000..6a54e17ea --- /dev/null +++ b/app/models/topic/card.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页卡片内容 +class Topic::Card < Topic +end diff --git a/app/models/topic/cooperator.rb b/app/models/topic/cooperator.rb new file mode 100644 index 000000000..a023d3656 --- /dev/null +++ b/app/models/topic/cooperator.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页合作伙伴 +class Topic::Cooperator < Topic +end diff --git a/app/models/topic/excellent_project.rb b/app/models/topic/excellent_project.rb new file mode 100644 index 000000000..ac08863c7 --- /dev/null +++ b/app/models/topic/excellent_project.rb @@ -0,0 +1,17 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页优秀项目 +class Topic::ExcellentProject < Topic + +end diff --git a/app/models/topic/experience_forum.rb b/app/models/topic/experience_forum.rb new file mode 100644 index 000000000..855a56809 --- /dev/null +++ b/app/models/topic/experience_forum.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页经验分享 +class Topic::ExperienceForum < Topic +end diff --git a/app/models/topic/pinned_forum.rb b/app/models/topic/pinned_forum.rb new file mode 100644 index 000000000..c5a2c8572 --- /dev/null +++ b/app/models/topic/pinned_forum.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# uuid :integer +# image_url :string(255) +# url :string(255) +# order_index :integer +# + +# 首页精选文章 +class Topic::PinnedForum < Topic +end diff --git a/db/migrate/20211102065736_create_topics.rb b/db/migrate/20211102065736_create_topics.rb new file mode 100644 index 000000000..57f21a0ac --- /dev/null +++ b/db/migrate/20211102065736_create_topics.rb @@ -0,0 +1,12 @@ +class CreateTopics < ActiveRecord::Migration[5.2] + def change + create_table :topics do |t| + t.string :type + t.string :title + t.integer :uuid + t.string :image_url + t.string :url + t.integer :order_index + end + end +end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb new file mode 100644 index 000000000..b8c5a8e0c --- /dev/null +++ b/spec/models/topic_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Topic, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end