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:
@@ -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
|
||||
}
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
UpdateHistories []UpdateHistory `gorm:"polymorphic:Model;polymorphicValue:base" json:"-"` // полностью скрываем
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
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" 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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user