orm

package
v0.0.71 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeFormat = "2006-01-02 15:04:05"
	TimeLocalZone     = "Asia/Shanghai"
)

Variables

This section is empty.

Functions

func PageAnyFind added in v0.0.5

func PageAnyFind[T any](db *gorm.DB, page r.PageInfo) (*r.PageAnyResp, error)

PageAnyFind 分页查找

func PageFind

func PageFind[T any](db *gorm.DB, page r.PageInfo) (data *r.PageResp[T], err error)

PageFind 分页查找

func Paginate

func Paginate(page r.PageInfo) func(db *gorm.DB) *gorm.DB

Paginate 分页器

Types

type LocalTime

type LocalTime time.Time

func (LocalTime) Format added in v0.0.3

func (t LocalTime) Format() string

Format 从配置文件获取时间格式

func (LocalTime) MarshalJSON

func (t LocalTime) MarshalJSON() ([]byte, error)

func (*LocalTime) Scan

func (t *LocalTime) Scan(v any) error

func (LocalTime) String

func (t LocalTime) String() string

func (*LocalTime) UnmarshalJSON

func (t *LocalTime) UnmarshalJSON(data []byte) (err error)

func (LocalTime) Value

func (t LocalTime) Value() (driver.Value, error)

type Model added in v0.0.3

type Model struct {
	ID        string         `json:"id" gorm:"primarykey"`
	CreatedAt LocalTime      `json:"createdAt"`
	UpdatedAt LocalTime      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

Model ID 值使用UUID, 避免分布式环境下key冲突

LocalTime

1.可以通过配置指定格式 app.timeFormat
1.1.string -> time (指定根式序列化)
1.2.time -> string (指定根式反序列化)

func (*Model) BeforeCreate added in v0.0.3

func (u *Model) BeforeCreate(tx *gorm.DB) error

Jump to

Keyboard shortcuts

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