From e6560d723351c44f86004e3d1871b739a45653e1 Mon Sep 17 00:00:00 2001 From: Jefferson Baldion Date: Tue, 7 May 2024 16:07:40 -0500 Subject: [PATCH] Create tables relation --- internal/entity/invest_account.go | 14 +++++++------- internal/entity/invest_code.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/entity/invest_account.go b/internal/entity/invest_account.go index fbe7709..f5b9973 100644 --- a/internal/entity/invest_account.go +++ b/internal/entity/invest_account.go @@ -8,13 +8,13 @@ import ( ) type InvestAccount struct { - ID uint `gorm:"primarykey" json:"id"` - IP string `gorm:"type:varchar(16);unique" json:"ip"` - CreatedAt time.Time ` json:"created_at"` - UpdatedAt time.Time ` json:"updated_at"` - DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"` - Code string `gorm:"type:varchar(64);index" json:"code"` - // InvestCode InvestCode `gorm:"foreignKey:Code;references:Code" json:"-"` + ID uint `gorm:"primarykey" json:"id"` + IP string `gorm:"type:varchar(16);unique" json:"ip"` + CreatedAt time.Time ` json:"created_at"` + UpdatedAt time.Time ` json:"updated_at"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"` + Code string `gorm:"type:varchar(64);index" json:"code"` + InvestCode InvestCode `gorm:"foreignKey:Code;references:Code" json:"-"` } // TableName returns the entity table name. diff --git a/internal/entity/invest_code.go b/internal/entity/invest_code.go index 91284d9..d7a9151 100644 --- a/internal/entity/invest_code.go +++ b/internal/entity/invest_code.go @@ -5,9 +5,9 @@ import ( ) type InvestCode struct { - Code string `gorm:"primarykey" json:"code"` - SocialNetwork string `gorm:"type:varchar(64)" json:"social_network"` - // InvestAccounts []InvestAccount `gorm:"foreignKey:Code;references:Code"` + Code string `gorm:"primarykey" json:"code"` + SocialNetwork string `gorm:"type:varchar(64)" json:"social_network"` + InvestAccounts []InvestAccount `gorm:"foreignKey:Code;references:Code"` } // TableName returns the entity table name.