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
|
||||||
|
}
|
||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
type Base struct {
|
type Base struct {
|
||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
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 {
|
type UpdateHistory struct {
|
||||||
ID uint `gorm:"primaryKey" json:"-"`
|
ID uint `gorm:"primaryKey" json:"id,omitempty"`
|
||||||
ModelID uint `json:"-"`
|
ModelID uint `json:"model_id"`
|
||||||
ModelType string `json:"-"`
|
ModelType string `json:"model_type"`
|
||||||
Timestamp time.Time `json:"-"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
UpdatedBy uint `gorm:"index" json:"-"`
|
UpdatedBy uint `gorm:"index" json:"updated_by"`
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user