Documentation ¶
Index ¶
- Constants
- func Exists(ctx context.Context, db *gorm.DB) (bool, error)
- func FindOne(ctx context.Context, db *gorm.DB, opts QueryOptions, out interface{}) (bool, error)
- func FindPage(ctx context.Context, db *gorm.DB, pp PaginationParam, opts QueryOptions, ...) (int64, error)
- func FromIsRootUser(ctx context.Context) bool
- func FromRowLock(ctx context.Context) bool
- func FromTraceID(ctx context.Context) string
- func FromTrans(ctx context.Context) (*gorm.DB, bool)
- func FromUserID(ctx context.Context) string
- func FromUserToken(ctx context.Context) string
- func GetBodyData(c *gin.Context) []byte
- func GetDB(ctx context.Context, defDB *gorm.DB) *gorm.DB
- func GetToken(c *gin.Context) string
- func MustNewUUID() string
- func NewIsRootUser(ctx context.Context) context.Context
- func NewRowLock(ctx context.Context) context.Context
- func NewTraceID(ctx context.Context, traceID string) context.Context
- func NewTrans(ctx context.Context, db *gorm.DB) context.Context
- func NewUserCache(ctx context.Context, userCache UserCache) context.Context
- func NewUserID(ctx context.Context, userID string) context.Context
- func NewUserToken(ctx context.Context, userToken string) context.Context
- func NewXID() string
- func ParseForm(c *gin.Context, obj interface{}) error
- func ParseJSON(c *gin.Context, obj interface{}) error
- func ParseQuery(c *gin.Context, obj interface{}) error
- func RandomizedIPAddr() string
- func ResError(c *gin.Context, err error, status ...int)
- func ResJSON(c *gin.Context, status int, v interface{})
- func ResOK(c *gin.Context)
- func ResPage(c *gin.Context, v interface{}, pr *PaginationResult)
- func ResSuccess(c *gin.Context, v interface{})
- func Run(ctx context.Context, handler func(ctx context.Context) (func(), error)) error
- type Direction
- type OrderByParam
- type OrderByParams
- type PaginationParam
- type PaginationResult
- type QueryOptions
- type ResponseResult
- type Trans
- type TransFunc
- type UserCache
Constants ¶
View Source
const ( ReqBodyKey = "req-body" ResBodyKey = "res-body" TreePathDelimiter = "." )
Variables ¶
This section is empty.
Functions ¶
func FindPage ¶
func FindPage(ctx context.Context, db *gorm.DB, pp PaginationParam, opts QueryOptions, out interface{}) (int64, error)
func FromIsRootUser ¶
func FromRowLock ¶
func FromTraceID ¶
func FromUserID ¶
func FromUserToken ¶
func MustNewUUID ¶
func MustNewUUID() string
The function generates a new UUID and panics if there is an error.
func NewXID ¶
func NewXID() string
The function "NewXID" generates a new unique identifier (XID) and returns it as a string.
func ParseQuery ¶
Parse query parameter to struct
func RandomizedIPAddr ¶
func RandomizedIPAddr() string
The RandomizedIPAddr function generates a random IP address.
func ResPage ¶
func ResPage(c *gin.Context, v interface{}, pr *PaginationResult)
func ResSuccess ¶
Types ¶
type OrderByParam ¶
type OrderByParams ¶
type OrderByParams []OrderByParam
func (OrderByParams) ToSQL ¶
func (a OrderByParams) ToSQL() string
type PaginationParam ¶
type PaginationResult ¶
type PaginationResult struct { Total int64 `json:"total"` Current int `json:"current"` PageSize int `json:"pageSize"` }
func WrapPageQuery ¶
func WrapPageQuery(ctx context.Context, db *gorm.DB, pp PaginationParam, opts QueryOptions, out interface{}) (*PaginationResult, error)
type QueryOptions ¶
type QueryOptions struct { SelectFields []string OmitFields []string OrderFields OrderByParams }
type ResponseResult ¶
Click to show internal directories.
Click to hide internal directories.