Merge branch 'dev_partners' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_partners

dev_local
cxt 6 years ago
commit 260cc5b598

@ -0,0 +1,5 @@
class Customer < ActiveRecord::Base
belongs_to :partner
has_one :scholl
has_many :users
end

@ -53,6 +53,7 @@ class Message < ActiveRecord::Base
has_many :tidings, :as => :container , :dependent => :destroy
belongs_to :reply, :class_name => 'Message', :foreign_key => 'reply_id'
has_one :message_detail, :dependent => :destroy
#转发表
has_many :forwards, :as => :from, :dependent => :destroy
@ -117,6 +118,10 @@ class Message < ActiveRecord::Base
self.content
end
def content
self.message_detail.try(:content)
end
def topic?
parent_id.nil?
end

@ -0,0 +1,5 @@
class Partner < ActiveRecord::Base
attr_accessible :name
has_one :school
has_many :customers
end

@ -15,6 +15,9 @@ class School < ActiveRecord::Base
has_many :ec_majors, :through => :ec_major_schools
has_many :ec_major_schools, :dependent => :destroy
belongs_to :partner
belongs_to :customer
# banner图片信息
has_many :school_images, :dependent => :destroy

@ -160,6 +160,7 @@ class User < Principal
## added by xianbo for delete
# has_many :biding_projects, :dependent => :destroy
belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy
belongs_to :partner
##ended by xianbo
#####fq

@ -0,0 +1,9 @@
class CreatePartners < ActiveRecord::Migration
def change
create_table :partners do |t|
t.string :name
t.timestamps
end
end
end

@ -0,0 +1,10 @@
class CreateCustomers < ActiveRecord::Migration
def change
create_table :customers do |t|
t.references :partner
t.timestamps
end
add_index :customers, :partner_id
end
end

@ -0,0 +1,8 @@
class AddPartnerIdAndCustomerIdToSchools < ActiveRecord::Migration
def change
add_column :schools, :partner_id, :integer
add_index :schools, :partner_id
add_column :schools, :customer_id, :integer
add_index :schools, :customer_id
end
end

@ -0,0 +1,6 @@
class AddPartnerIdToUsers < ActiveRecord::Migration
def change
add_column :users, :partner_id, :integer
add_index :users, :partner_id
end
end
Loading…
Cancel
Save