Documentation ¶
Index ¶
- func FmtFields(tableName string, fields ...string) []string
- func GetTimestamp(t time.Time, tt schema.TimeType) (ts int64)
- func IsRecordNotFound(err error) bool
- type BaseModel
- func (m *BaseModel) CountByCondition(data schema.Tabler, condition func(*gorm.DB) *gorm.DB) (int64, error)
- func (m *BaseModel) DeleteByCondition(data schema.Tabler, condition func(*gorm.DB) *gorm.DB) error
- func (m *BaseModel) ParseUpdateMap(data interface{}, omits, selects []string, notIgnores ...string) (map[string]interface{}, error)
- func (m *BaseModel) PluckInt64s(data schema.Tabler, column string, condition func(*gorm.DB) *gorm.DB) ([]int64, error)
- func (m *BaseModel) PluckStrings(data schema.Tabler, column string, condition func(*gorm.DB) *gorm.DB) ([]string, error)
- func (m *BaseModel) Update(data IdGetter, selects []string) error
- func (m *BaseModel) UpdateByCondition(data schema.Tabler, condition func(*gorm.DB) *gorm.DB) error
- func (m *BaseModel) UpdateWithMapByCondition(t schema.Tabler, data map[string]interface{}, ...) error
- type BaseSuite
- type ByInfo
- type ContextKey
- type IdGetter
- type PaginationQuery
- type TimeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTimestamp ¶
GetTimestamp 获取时间类型对应的当前时间戳
Types ¶
type BaseModel ¶
BaseModel 基础模型
func NewBaseModel ¶
NewBaseModel 新建基础模型
func (*BaseModel) CountByCondition ¶
func (m *BaseModel) CountByCondition(data schema.Tabler, condition func(*gorm.DB) *gorm.DB) (int64, error)
CountByCondition 通过动态条件计数数据信息
func (*BaseModel) DeleteByCondition ¶
DeleteByCondition 通过动态条件删除数据信息
func (*BaseModel) ParseUpdateMap ¶
func (m *BaseModel) ParseUpdateMap(data interface{}, omits, selects []string, notIgnores ...string) (map[string]interface{}, error)
ParseUpdateMap 解析模型数据获取对应的更新map,更新时间字段会自动跟踪,参数
data 须为模型数据结构体或其所对应指针 omits 不更新的字段列表,只在selects长度为0时生效 selects 指定更新的字段列表,长度为0时,生成的更新map取模型数据非零值并忽略主键和创建时间字段 notIgnores 不忽略的字段列表,只在selects长度为0时生效,与omits冲突时,以omits为准
func (*BaseModel) PluckInt64s ¶
func (m *BaseModel) PluckInt64s(data schema.Tabler, column string, condition func(*gorm.DB) *gorm.DB) ([]int64, error)
PluckInt64s 通过动态条件查找单个列并将结果扫描到int64切片中
func (*BaseModel) PluckStrings ¶
func (m *BaseModel) PluckStrings(data schema.Tabler, column string, condition func(*gorm.DB) *gorm.DB) ([]string, error)
PluckStrings 通过动态条件查找单个列并将结果扫描到string切片中
func (*BaseModel) UpdateByCondition ¶
UpdateByCondition 通过动态条件更新数据信息
type BaseSuite ¶
BaseSuite 基础测试套
func (*BaseSuite) TestParseUpdateMap ¶
func (s *BaseSuite) TestParseUpdateMap()
TestParseUpdateMap 测试解析更新map
type ByInfo ¶
type ByInfo struct { CreateBy int64 `json:"create_by" gorm:"column:create_by;type:bigint(20);comment:创建者"` // 创建者 UpdateBy int64 `json:"update_by" gorm:"column:update_by;type:bigint(20);comment:更新者"` // 更新者 }
ByInfo 操作者信息
func (*ByInfo) BeforeCreate ¶
BeforeCreate 创建前钩子函数
type PaginationQuery ¶
type PaginationQuery struct {
// contains filtered or unexported fields
}
PaginationQuery 分页查询
func NewPaginationQuery ¶
func NewPaginationQuery(page, pageSize int64, order string) *PaginationQuery
NewPaginationQuery 新建分页查询
func (*PaginationQuery) Add ¶
func (pq *PaginationQuery) Add(query func(*gorm.DB) *gorm.DB)
Add 添加查询条件
type TimeInfo ¶
type TimeInfo struct { CreateTime int64 `json:"create_time" gorm:"column:create_time;type:bigint(20);autoCreateTime:milli;comment:创建时间"` // 创建时间 UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20);autoUpdateTime:milli;comment:更新时间"` // 更新时间 }
TimeInfo 通用时间信息
Click to show internal directories.
Click to hide internal directories.