utils

package
v0.0.0-...-4705fdb Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	POKER = "POKER"

	LOCAL       = "LOCAL"
	DEVELOPMENT = "DEVELOPMENT"
	TESTING     = "TESTING"
	STAGING     = "STAGING"
	PRODUCTION  = "PRODUCTION"
)

Variables

This section is empty.

Functions

func EnableDevelopment

func EnableDevelopment()

func EnableProduction

func EnableProduction()

func EnableStaging

func EnableStaging()

func EnableTesting

func EnableTesting()

func GenerateToken

func GenerateToken(username, password string, secret []byte) (string, error)

func GetCommonFilterDB

func GetCommonFilterDB(db *gorm.DB, c *gin.Context) (dbRet *gorm.DB, err error)

func GetEnvironment

func GetEnvironment() string

func HandleName

func HandleName(name string) string

func IsDevelopment

func IsDevelopment() bool

func IsLocal

func IsLocal() bool

func IsProduction

func IsProduction() bool

func IsStaging

func IsStaging() bool

func IsTesting

func IsTesting() bool

func SignalHandler

func SignalHandler()

func Unix2Time

func Unix2Time(t int64) string

func UnixZero

func UnixZero() int64

获取当天 零点的unix 时间

Types

type CustomClaims

type CustomClaims struct {
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string, secret []byte) (*CustomClaims, error)

type Filter

type Filter struct {
	Field string `form:"field"`                 // 指定要从数据库检索的字段,默认情况下,将选择所有字段, 逗号隔开 "name, age"
	Order string `form:"order"`                 // 在从数据库检索记录时指定顺序, 逗号隔开 "age desc, name"
	Limit int    `form:"limit" binding:"min=0"` // 指定要检索的记录数,单页记录数
	Page  int    `form:"page" binding:"min=0"`  // 指定在开始返回记录之前要跳过的记录数, 页码
	Where string `form:"where"`                 // 过滤语句 ["age >= ? and role <> ?",20,"admin"]
}

type Result

type Result struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func NewResult

func NewResult(code int, msg string, data interface{}) *Result

func (*Result) Error

func (e *Result) Error() string

Jump to

Keyboard shortcuts

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