diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9c738e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea/ +.vscode/ + +.DS_Store diff --git a/shared/research.go b/shared/research.go index b933484..9aa85d3 100644 --- a/shared/research.go +++ b/shared/research.go @@ -217,7 +217,7 @@ type Forex struct { High float64 Close float64 Date int64 - Type string `gorm:"-" json:"type"` + Type string `gorm:"-" json:"type"` } type ForexAsset struct { @@ -361,9 +361,8 @@ type WatchList struct { } type HistoricTvlAll struct { - Timestamp uint64 `gorm:"uniqueIndex:idx_historic_name"` Name string `gorm:"uniqueIndex:idx_historic_name"` - Type string + Timestamp uint64 `gorm:"uniqueIndex:idx_historic_name"` TotalUsdLiquidity float64 } diff --git a/shared/toscale.go b/shared/toscale.go index 348c4a3..a144ccb 100644 --- a/shared/toscale.go +++ b/shared/toscale.go @@ -1,29 +1,31 @@ package shared +import "database/sql" + type User struct { - ID uint64 `gorm:"primaryKey"` - Name string - Email string - Role string - Avatar string - Password string - CreatedAt uint64 `gorm:"column:createdAt"` - Referal uint64 - Lang string - EmailConfirmed bool `gorm:"column:emailConfirm"` - TwoFaSecret string `gorm:"column:twoFaSecret"` - ContainerId string `gorm:"column:containerId"` - TaskId string `gorm:"column:taskId"` - TwoFaEnabled bool `gorm:"column:twoFaEnabled"` - LastOnline uint64 `gorm:"column:lastOnline"` - Verified bool `gorm:"column:verified"` - NewsLang string `gorm:"column:newsLang"` - AssetId uint64 `gorm:"column:assetId"` - AvaliableMarketplace bool `gorm:"column:avaliableMarketplace"` - AvaliablePortfolio bool `gorm:"column:avaliablePortfolio"` - AvaliableTerminal bool `gorm:"column:avaliableTerminal"` - AvaliableLending bool `gorm:"column:avaliableLending"` - AvaliableAssist bool `gorm:"column:avaliableAssist"` + ID uint64 `gorm:"primaryKey"` + Name string + Email string + Role string `gorm:"default:user"` + Avatar string + Password string + CreatedAt uint64 `gorm:"column:createdAt"` + Referral sql.Null[uint64] + Lang string + EmailConfirmed bool `gorm:"column:emailConfirm"` + TwoFaSecret string `gorm:"column:twoFaSecret"` + ContainerId sql.NullString `gorm:"column:containerId"` + TaskId sql.NullString `gorm:"column:taskId"` + TwoFaEnabled bool `gorm:"column:twoFaEnabled"` + LastOnline uint64 `gorm:"column:lastOnline"` + Verified bool `gorm:"column:verified"` + NewsLang string `gorm:"column:newslang"` + AssetId sql.Null[uint64] `gorm:"column:assetId"` + AvaliableMarketplace bool `gorm:"column:avaliableMarketplace"` + AvaliablePortfolio bool `gorm:"column:avaliablePortfolio"` + AvaliableTerminal bool `gorm:"column:avaliableTerminal"` + AvaliableLending bool `gorm:"column:avaliableLending"` + AvaliableAssist bool `gorm:"column:avaliableAssist"` } func (User) TableName() string { @@ -105,4 +107,4 @@ type ApiKey struct { TokensUsedMonth uint64 `gorm:"default:0"` TotalTokensMonth uint64 `gorm:"default:10000"` ExpirityDate uint64 -} \ No newline at end of file +} diff --git a/shared/trade.go b/shared/trade.go index e54a651..b7b7e07 100644 --- a/shared/trade.go +++ b/shared/trade.go @@ -1,26 +1,5 @@ package shared -import ( - "errors" - - "gorm.io/gorm" -) - -func (ticker *OrganizedTickers) BeforeCreate(tx *gorm.DB) (err error) { - var existingTicker OrganizedTickers - result := tx.Where("symbol = ? AND exchange = ?", ticker.Symbol, ticker.Exchange).First(&existingTicker) - - if result.Error == nil || result.RowsAffected > 0 { - ticker.ID = existingTicker.ID - } else if errors.Is(result.Error, gorm.ErrRecordNotFound) { - return tx.Raw("SELECT nextval('organized_tickers_id_seq')").Scan(&ticker.ID).Error - } else { - return result.Error - } - - return nil -} - type OrganizedTickers struct { ID uint64 `json:"id" gorm:"primaryKey"` Exchange string `json:"-" gorm:"uniqueIndex:idx_uniq_ticker"` @@ -147,4 +126,4 @@ type DexOrganizedTickers struct { BaseVolume float64 `json:"baseVolume"` QuoteVolume float64 `json:"quoteVolume"` CreatedAt uint64 `json:"createdAt" gorm:"autoCreateTime:milli"` -} \ No newline at end of file +}