micro

package
v1.0.73 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(logger *log.Logger) gin.HandlerFunc

func NewStore

func NewStore(name, dsn, prefix string, keyPairs ...[]byte) (store ginsession.Store, err error)

func NewStoreWithIMDB

func NewStoreWithIMDB(db imdb.Conn, prefix string, keyPairs ...[]byte) ginsession.Store

func OpenDB

func OpenDB(name, dsn string, config interface{}) (*gorm.DB, error)

func Recover

func Recover(logger *log.Logger) gin.HandlerFunc

func RegisterErrorCode

func RegisterErrorCode(codes map[int]int)

RegisterErrorCode 错误码与http状态码映射

func Trace

func Trace(callee string) gin.HandlerFunc

Types

type Controller

type Controller struct{}

func (Controller) Bind

func (c Controller) Bind(ctx *gin.Context, v interface{}) (err error)

func (Controller) ParamInt

func (c Controller) ParamInt(ctx *gin.Context, key string) (i int64, err error)

func (Controller) Response

func (c Controller) Response(ctx *gin.Context, data interface{}, err error)

type CountModel

type CountModel struct {
	CountByYear  int16 `json:"count_by_year" gorm:"index"`  // 按年统计
	CountByMonth int16 `json:"count_by_month" gorm:"index"` // 按月统计
	CountByWeek  int16 `json:"count_by_week" gorm:"index"`  // 按周统计
	CountByDay   int16 `json:"count_by_day" gorm:"index"`   // 按天统计
	CountByHour  int16 `json:"count_by_hour" gorm:"index"`  // 按时统计
}

type Dao

type Dao struct {
	// contains filtered or unexported fields
}

func NewDao

func NewDao(db func(ctx context.Context) *gorm.DB, model schema.Tabler) Dao

func (Dao) Count

func (d Dao) Count(ctx context.Context, equal Equal) (count int64, err error)

func (Dao) Create

func (d Dao) Create(ctx context.Context, equal Equal, value interface{}) (err error)

func (Dao) DB

func (d Dao) DB(ctx context.Context) *gorm.DB

func (Dao) Delete

func (d Dao) Delete(ctx context.Context, equal Equal, update Update) (err error)

func (Dao) Equal

func (d Dao) Equal(ctx context.Context, equal Equal) *gorm.DB

func (Dao) Find

func (d Dao) Find(ctx context.Context, equal Equal, out interface{}) (err error)

func (Dao) First

func (d Dao) First(ctx context.Context, equal Equal, out interface{}) (err error)

func (Dao) List

func (d Dao) List(ctx context.Context, query Query, equal Equal, out interface{}) (total int64, err error)

func (Dao) QueryDeleted

func (d Dao) QueryDeleted(ok bool) Dao

func (Dao) Update

func (d Dao) Update(ctx context.Context, equal Equal, update Update) (err error)

type Equal

type Equal map[string]interface{}

func (Equal) Where

func (e Equal) Where() map[string]interface{}

type Model

type Model struct {
	ID        uint   `json:"id" gorm:"primary_key"`
	CreatedAt int64  `json:"created_at" gorm:"index"`
	UpdatedAt int64  `json:"updated_at" gorm:"index"`
	DeletedAt int64  `json:"deleted_at" gorm:"index"`
	CreatedID string `json:"created_id" gorm:"index"`
	UpdatedID string `json:"updated_id" gorm:"index"`
	DeletedID string `json:"deleted_id" gorm:"index"`
	CreatedBy string `json:"created_by" gorm:"index"`
	UpdatedBy string `json:"updated_by" gorm:"index"`
	DeletedBy string `json:"deleted_by" gorm:"index"`
}

type Query

type Query struct {
	Page   int      `form:"page" json:"page,omitempty"`     // 当前页
	Size   int      `form:"size" json:"size,omitempty"`     // 页大小
	Sort   string   `form:"sort" json:"sort,omitempty"`     // 排序
	Cond   string   `form:"cond" json:"cond,omitempty"`     // 条件符号:and、or,用于自定义字段查询
	Omit   []string `form:"omit" json:"omit,omitempty"`     // 忽略字段
	Select []string `form:"select" json:"select,omitempty"` // 选择字段
	Where  string   `form:"where" json:"where,omitempty"`   // 自定义条件SQL
	// contains filtered or unexported fields
}

func (*Query) ByCustom

func (q *Query) ByCustom(db *gorm.DB) *gorm.DB

func (*Query) ByLimit

func (q *Query) ByLimit(db *gorm.DB) *gorm.DB

func (*Query) ByQuery

func (q *Query) ByQuery(db *gorm.DB) *gorm.DB

func (*Query) BySelect

func (q *Query) BySelect(db *gorm.DB) *gorm.DB

func (*Query) BySort

func (q *Query) BySort(db *gorm.DB) *gorm.DB

func (*Query) ByWhere

func (q *Query) ByWhere(db *gorm.DB) *gorm.DB

func (*Query) Valid

func (q *Query) Valid(ctx *gin.Context) (err error)

type Response

type Response struct {
	Errno   int         `json:"errno"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func NewResponse

func NewResponse(data interface{}, err error) (resp Response)

NewResponse 创建响应结构

type Result

type Result struct {
	Query
	Count int         `json:"count"`
	Total int64       `json:"total"`
	Data  interface{} `json:"data"`
}

type Update

type Update map[string]interface{}

func (Update) Updates

func (u Update) Updates() map[string]interface{}

type Validator

type Validator interface {
	Valid(ctx *gin.Context) (err error)
}

Jump to

Keyboard shortcuts

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