new file: main_dc/yalarba/api_es/internal/models/account.go

modified:   main_dc/yalarba/api_es/internal/models/base.go
	modified:   main_dc/yalarba/api_es/internal/models/update_history.go
fix update history, add json
set Base without polymorphicValue
create Account object but not finish
This commit is contained in:
2026-01-22 15:43:03 +05:00
parent 276e94c460
commit 4c5a7af5f5
3 changed files with 25 additions and 11 deletions
@@ -0,0 +1,14 @@
package models
import (
"gorm.io/gorm"
)
type Account struct {
Base Base `gorm:"embedded"`
FirstName string
LastName string
Email string
Password string
IsAdmin bool
}
@@ -7,8 +7,8 @@ import (
type Base struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
UpdateHistories []UpdateHistory `gorm:"polymorphic:Model;polymorphicValue:base" json:"-"` // полностью скрываем
UpdateHistories []UpdateHistory `gorm:"polymorphic:Model" json:"-"` // убран polymorphicValue
}
@@ -5,9 +5,9 @@ import (
)
type UpdateHistory struct {
ID uint `gorm:"primaryKey" json:"-"`
ModelID uint `json:"-"`
ModelType string `json:"-"`
Timestamp time.Time `json:"-"`
UpdatedBy uint `gorm:"index" json:"-"`
ID uint `gorm:"primaryKey" json:"id,omitempty"`
ModelID uint `json:"model_id"`
ModelType string `json:"model_type"`
Timestamp time.Time `json:"timestamp"`
UpdatedBy uint `gorm:"index" json:"updated_by"`
}