# モデル大改造手術選手権 ## 元ネタ ``` thl = OperationCorporation.find_by(unique_name: "thl") thl.staffs thl.branches.first.staffs thl.branches.each do |branch| branch.partner_entry_services_corporations #> [conomy, smartmoushikomi] entry = branch.entries.first entry.owner_operation_corporation_branch entry.owner_operation_corporation Api::Repository::MoushikomiUketsukekun::EntryRepository.new(branch).where(datetime: from).result updated_entry_entity = Api::Repository::MoushikomiUketsukekun::EntryRepository.new(branch).update(entry) rooms = branch.rooms entry.to_external_service_entity.update end thl.entries entry = Entry.find(1) entry.owner_operation_corporation_branch entry.owner_operation_corporation guarantee_corporation = thl.branches.first.partner_guarantee_corporations.first guarantee_corporation.partner_operations_corporation_branchs entry.guarantees.first.guarantiee_corporations guarantee_corporation.guarantees ``` ## いじくるモデル - OperationCorporation(New!) - has_many :operation_corporation_baranches, as: :branches - has_many :operation_corporation_staffs, through: :branches - has_many :entry_services_corporations, through: :branches - has_many :guarantiee_corporations, through: :branches - has_many :entries, through: :operation_corporation_baranches - has_many :staffs, through: branches - OperationCorporationBranch(OperationCorporationをリニューアル) - belongs_to :operation_corporation - has_many :partner_entry_services_corporations - has_many :entry_services_corporations, through: :partner_entry_services_corporations - has_many :partner_guarantee_corporations - has_many :guarantee_corporations, through: :partner_guarantee_corporations - has_many :partner_vendor_corporations - has_many :vendor_corporations, through: :partner_vendor_corporations - has_many :entries - has_many :operation_corporation_staffs, as: :staffs - OperationCorporationStaff(ある) - belongs_to :operation_corporation_branch - EntryServiceCorporation(ある) - has_many :partner_entry_services_corporations - PartnerEntryServiceCorporation(LinkedEntryServiceCorporationをリニューアル) - belongs_to :operation_corporation - belongs_to :entry_services_corporation - has_many :entry_import_issues - GuaranteeCorporation(ある)   - has_many :管理会社と保証会社の中間テーブル   - has_many :partner_guarantee_corporations   - has_many :guarantees through: :partner_guarantee_corporations - PartnerGuaranteeCorporation(New!) - belongs_to :operation_corporation - belongs_to :guarantiee_corporation - has_many :guarantees - Guarantee(New!) - belongs_to :partner_guarantee_corporation - belongs_to :entry - VendorCorporation(ある) - has_many :vendor_services - VendorService(ある) - belongs_to :vendor_corporation - has_many :partner_vendor_services - PartnerVendorService(LinkedVendorServiceをリニューアル) - belongs_to :operation_corporation_branch - belongs_to :vendor_service - has_many :entry_import_issues - Entry(ある) - belongs_to :operation_corporation_branch, as: :owner_operation_corporation_branch - has_one :owner_operation_corporation, through: :owner_operation_corporation_branch ## 相談したいこと - 進め方 - インポーター部分の設計 - 1管理会社:1インポーター→1支店:1インポーター? - 後回し - 建物とか部屋とかどこに紐づけるか ## 作業中 ### うちがねさん - エントリサービスと繋げる ## 進め方 - 保証会社だけまず作る