forked from Gitlink/forgeplus
新增:专家智享相关模型
This commit is contained in:
parent
e638c741c5
commit
63fc16a4be
|
|
@ -43,4 +43,5 @@
|
|||
|
||||
class Memo < ApplicationRecord
|
||||
|
||||
end
|
||||
belongs_to :author, :class_name => "User", foreign_key: :author_id, counter_cache: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
class ResidentExpert < ApplicationRecord
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
class ResidentExpertAction < ApplicationRecord
|
||||
end
|
||||
|
|
@ -195,6 +195,7 @@ class User < Owner
|
|||
|
||||
has_many :user_vote_options, dependent: :destroy
|
||||
has_many :vote_options, through: :user_vote_options
|
||||
has_many :memos, foreign_key: :author_id, dependent: :destroy
|
||||
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
class CreateResidentExperts < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :resident_experts do |t|
|
||||
t.references :user
|
||||
t.string :name
|
||||
t.string :gender
|
||||
t.integer :expert_category
|
||||
t.integer :academic_degree
|
||||
t.string :department
|
||||
t.string :title
|
||||
t.string :territory_area1
|
||||
t.string :territory_area2
|
||||
t.string :territory_area3
|
||||
t.text :introduction
|
||||
t.integer :status, default: 0
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
class CreateResidentExpertActions < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :resident_expert_actions do |t|
|
||||
t.references :resident_expert
|
||||
t.integer :action_type, default: 0
|
||||
t.string :action_name
|
||||
t.string :action_description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
class AddMemosCountToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :memos_count, :integer, default: 0
|
||||
|
||||
User.find_each do |user|
|
||||
User.reset_counters(user.id, :memos_count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue