From 4c5a7af5f5f94f95f5b01b058931636533decb35 Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Thu, 22 Jan 2026 15:43:03 +0500 Subject: [PATCH] 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 --- main_dc/yalarba/api_es/internal/models/account.go | 14 ++++++++++++++ main_dc/yalarba/api_es/internal/models/base.go | 10 +++++----- .../api_es/internal/models/update_history.go | 12 ++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 main_dc/yalarba/api_es/internal/models/account.go diff --git a/main_dc/yalarba/api_es/internal/models/account.go b/main_dc/yalarba/api_es/internal/models/account.go new file mode 100644 index 0000000..235bc49 --- /dev/null +++ b/main_dc/yalarba/api_es/internal/models/account.go @@ -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 +} \ No newline at end of file diff --git a/main_dc/yalarba/api_es/internal/models/base.go b/main_dc/yalarba/api_es/internal/models/base.go index cb22250..ec30d15 100644 --- a/main_dc/yalarba/api_es/internal/models/base.go +++ b/main_dc/yalarba/api_es/internal/models/base.go @@ -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 } diff --git a/main_dc/yalarba/api_es/internal/models/update_history.go b/main_dc/yalarba/api_es/internal/models/update_history.go index e70c1d7..800084f 100644 --- a/main_dc/yalarba/api_es/internal/models/update_history.go +++ b/main_dc/yalarba/api_es/internal/models/update_history.go @@ -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:"-"` -} \ No newline at end of file + 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"` +}