新增:专家智享相关模型

This commit is contained in:
yystopf 2026-03-23 14:39:28 +08:00
parent e638c741c5
commit 63fc16a4be
7 changed files with 50 additions and 1 deletions

View File

@ -43,4 +43,5 @@
class Memo < ApplicationRecord
end
belongs_to :author, :class_name => "User", foreign_key: :author_id, counter_cache: true
end

View File

@ -0,0 +1,2 @@
class ResidentExpert < ApplicationRecord
end

View File

@ -0,0 +1,2 @@
class ResidentExpertAction < ApplicationRecord
end

View File

@ -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]) }

View File

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

View File

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

View File

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