base

package
v0.10.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFieldIfExist added in v0.10.4

func SetFieldIfExist(model interface{}, fieldName string, value string)

SetFieldIfExist 设置字段值(如果字段存在且可设置) 支持字符串类型和时间类型字段的自动设置 参数说明:

  • model interface{}: 要设置字段值的模型对象
  • fieldName string: 字段名称
  • value string: 字段值(字符串格式的时间)

Types

type MysqlBaseModel

type MysqlBaseModel struct {
}

MysqlBaseModel gorm基础模型

func (*MysqlBaseModel) BeforeCreate

func (b *MysqlBaseModel) BeforeCreate(tx *gorm.DB) (err error)

func (*MysqlBaseModel) BeforeUpdate

func (b *MysqlBaseModel) BeforeUpdate(tx *gorm.DB) (err error)

func (*MysqlBaseModel) GetConfigAlias

func (b *MysqlBaseModel) GetConfigAlias(model interface{}) string

func (*MysqlBaseModel) ModelParse

func (b *MysqlBaseModel) ModelParse(modelType reflect.Type) (tableName string, fields []string, softDeleteField string, softDeleteCondition string)

ModelParse 解析模型信息(供 CRUD trait 使用) 参数说明:

  • modelType reflect.Type: 模型的反射类型

返回值:

  • tableName string: 数据表名称
  • fields []string: 字段列表
  • softDeleteField string: 软删除字段名
  • softDeleteCondition string: 软删除条件

type SqliteBaseModel

type SqliteBaseModel struct {
}

SqliteBaseModel gorm基础模型

func (*SqliteBaseModel) BeforeCreate

func (b *SqliteBaseModel) BeforeCreate(tx *gorm.DB) (err error)

func (*SqliteBaseModel) BeforeUpdate

func (b *SqliteBaseModel) BeforeUpdate(tx *gorm.DB) (err error)

func (*SqliteBaseModel) ConfigAlias

func (b *SqliteBaseModel) ConfigAlias(model interface{}) string

func (*SqliteBaseModel) ModelParse

func (b *SqliteBaseModel) ModelParse(modelType reflect.Type) (tableName string, fields []string, softDeleteField string, softDeleteCondition string)

ModelParse 解析模型信息(供 CRUD trait 使用) 参数说明:

  • modelType reflect.Type: 模型的反射类型

返回值:

  • tableName string: 数据表名称
  • fields []string: 字段列表
  • softDeleteField string: 软删除字段名
  • softDeleteCondition string: 软删除条件

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL