global

package
v0.0.0-...-b411c9a Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GsE              *gin.Engine
	GsAppPath        string
	Config           *config.Config
	Db               *gorm.DB
	SuperAdmin       string
	EventDispatcher  event.DispatcherEvent
	Limiter          *rate.Limiter
	Logger           *zap.SugaredLogger
	ValidatorManager *ginValidator.CustomValidatorManager
)

Functions

func CaptchaServe

func CaptchaServe(w http.ResponseWriter, r *http.Request, id, ext, lang string, download bool, width, height int) error

CaptchaServe 验证码

func GetError

func GetError(errs error, r interface{}) string

GetError 获取错误信息

func GetEventDispatcher

func GetEventDispatcher(c *gin.Context) *event.DispatcherEvent

func GormTans

func GormTans(err error) error

func IsSlice

func IsSlice(v interface{}) bool

func IsSuperAdmin

func IsSuperAdmin(roles []string, role string) bool

IsSuperAdmin 即将废弃,请勿使用

func Pages

func Pages(page int, pageSize int, total int, rows interface{}) map[string]interface{}

Pages 通用分页

func SlicesHasStr

func SlicesHasStr(s interface{}, str string) bool

Types

type Del

type Del struct {
	Ids []uint `json:"id"`
}

type GsModel

type GsModel struct {
	ID        uint           `gorm:"primarykey;autoIncrement" json:"id"` // 主键ID
	CreatedAt *LocalTime     `json:"created_at" gorm:"type:datetime(3)"` // 创建时间
	UpdatedAt *LocalTime     `json:"updated_at" gorm:"type:datetime(3)"` // 更新时间
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`                     // 删除时间
}

type List

type List struct {
	Page     int                    `json:"page" form:"page"`
	PageSize int                    `json:"pageSize" form:"pageSize"`
	Where    map[string]interface{} `json:"where" form:"where"`
}

type LocalTime

type LocalTime time.Time

func (*LocalTime) MarshalJSON

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

func (*LocalTime) Scan

func (t *LocalTime) Scan(v interface{}) error

Scan @ignore waring

func (LocalTime) Value

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

type Response

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

func (Response) Failed

func (r Response) Failed(c *gin.Context, err string)

Failed Deprecated

func (Response) Success

func (r Response) Success(c *gin.Context, msg string, data interface{})

Success disabled

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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