Documentation
¶
Index ¶
- Constants
- func GetPKs(obj any, pkName string) ([]any, error)
- func GetValidationRules(model Model, filter func(field *Field) bool) rules
- func RawType(elem reflect.Type) reflect.Type
- type Association
- type AssociationType
- type Field
- type FieldFiller
- type FieldType
- type Fields
- type FillFunc
- type FloatProperties
- type Focusable
- type Model
- func (m Model) ElementToMap(modelElement any, filter func(field Field) bool) (model map[string]any, err error)
- func (m Model) ElementsSlice(modelElementsMaps []map[string]any) (any, error)
- func (m Model) NewElement(fieldsMap map[string]any, filter func(field *Field) bool) (modelElement any, err error)
- func (m Model) Type() reflect.Type
- func (m Model) UpdateElement(dst any, src any, filter func(field *Field) bool) error
- type ModelsRegistry
Constants ¶
View Source
const ( CreateView view = iota + 1 UpdateView ListView )
Variables ¶
This section is empty.
Functions ¶
func GetValidationRules ¶
Types ¶
type Association ¶
type Association struct { Type AssociationType // Type Тип ассоциации, может быть belongsTo, hasOne, hasMany, manyToMany (как в gorm) Model *Model // Model Модель, к которой происходит ассоциация Many2Many string // Many2Many Название промежуточной таблицы для отношения many2many ForeignKey string // ForeignKey Внешний ключ ассоциации References string // References Референс внешнего ключа JoinForeignKey string // JoinForeignKey Внешний ключ в промежуточной таблице JoinReferences string // JoinReferences Референс в промежуточной таблице JoinSort string // JoinSort сортировка ассоциации (только для типа many2many) // contains filtered or unexported fields }
Ассоциация модели
type AssociationType ¶
type AssociationType int
const ( None AssociationType = iota BelongsTo HasOne HasMany ManyToMany )
type Field ¶
type Field struct { Title string // Title Название поля (как оно будет отображаться) Column string // Column Название колонки в таблице (в базе) Code string // Code код поля Sortable bool // Sortable Участвует в сортировке или нет (в списке элементов) Filterable bool // Filterable Участвует в фильтрации или нет (в списке элементов) Position int // Position Порядок отображения в списке и карточке Block string // Block Блок, в котором располагается поле IsUnique bool // IsUnique Уникальность IsMedia bool // IsMedia поле является ассоциацией к медиа IsTime bool // IsTime поле является датой/временем Hidden []view // Hidden описывает, где поле не отображается Disabled []view // Disabled описывает, где поле не доступно для редактирования View form.FieldType // View тип отображения ViewExtra map[string]any // ViewExtra доп параметры отображения Multiple bool // Multiple множественное Model *Model // Model Описание модели поля *FloatProperties // FloatProperties настройки для типа float Association *Association // Association Описание ассоциации // contains filtered or unexported fields }
func (*Field) Scan ¶
func (f *Field) Scan(structField reflect.StructField)
Scan заполнение поля значениями на основе структуры поля
type FieldFiller ¶
type FloatProperties ¶
type Model ¶
type Model struct { TableName string `json:"tableName"` // Название таблицы Code string `json:"code"` // Код модели Title string `json:"name"` // Название модели для отображения PrimaryKey *Field `json:"primaryKey"` // Первичный ключ Fields Fields `json:"fields"` // Поля модели, кроме первичного ключа // contains filtered or unexported fields }
func (Model) ElementToMap ¶
func (m Model) ElementToMap(modelElement any, filter func(field Field) bool) (model map[string]any, err error)
ElementToMap преобразование элемента модели в карту
func (Model) ElementsSlice ¶
Model.ElementsSlice получение среза элементов
type ModelsRegistry ¶
type ModelsRegistry struct {
// contains filtered or unexported fields
}
func NewModelsRegistry ¶
func NewModelsRegistry(supportMedia bool) *ModelsRegistry
NewModelsRegistry конструктор
func (ModelsRegistry) GetModel ¶
func (r ModelsRegistry) GetModel(code string) *Model
GetModel получение модели по коду
func (ModelsRegistry) ListModels ¶
func (r ModelsRegistry) ListModels() []*Model
ListModels получение всех зарегистрированных моделей
func (*ModelsRegistry) NewModel ¶
func (r *ModelsRegistry) NewModel(t reflect.Type)
ModelsRegistry.NewModel сканирование модели
func (*ModelsRegistry) Register ¶
func (r *ModelsRegistry) Register(items ...any)
Register регистрация моделей
Click to show internal directories.
Click to hide internal directories.