response

package
v0.0.0-...-11559a6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ok                  = 200
	NotOk               = 405
	Unauthorized        = 401
	Forbidden           = 403
	InternalServerError = 500
)
View Source
const (
	OkMsg                      = "success"
	NotOkMsg                   = "failed"
	UnauthorizedMsg            = "login expired, please login again"
	InvalidParameterMsg        = "invalid parameter"
	IllegalParameterMsg        = "illegal parameter"
	LoginCheckErrorMsg         = "错误的用户名或密码"
	AssetImportErrorMsg        = "数据导入失败"
	ForbiddenMsg               = "no permission to access this resource"
	InternalServerErrorMsg     = "服务器内部错误"
	IdempotenceTokenEmptyMsg   = "idempotent token is empty"
	IdempotenceTokenInvalidMsg = "idempotent token expired"
	UserDisabledMsg            = "the account has been disabled"
	WeakPassword               = "the password is too weak"
	UserLockedMsg              = "the account has been locked"
	InvalidCaptchaMsg          = "the verification code is invalid or expired"
	InvalidSignIdMsg           = "invalid app id"
	IllegalSignIdMsg           = "illegal app id"
	InvalidSignTokenMsg        = "invalid token"
	IllegalSignTokenMsg        = "illegal token"
	InvalidSignTimestampMsg    = "invalid timestamp"
	InvalidSignScopeMsg        = "invalid scope"
)

Variables

Functions

func Result

func Result(c *gin.Context, code int, msg string, data interface{})

func SuccessWithData

func SuccessWithData(c *gin.Context, data interface{})

func SuccessWithMsg

func SuccessWithMsg(c *gin.Context, msg string)

Types

type Base

type Base struct {
	Id uint `json:"id"`
	Time
}

type Resp

type Resp struct {
	Code      int         `json:"code"`
	Data      interface{} `json:"data"`
	Msg       string      `json:"message"`
	Timestamp int64       `json:"timestamp"`
}

type Time

type Time struct {
	CreatedAt time.Time `json:"createdAt" swaggertype:"string" example:"2019-01-01 00:00:00"` // create time
	UpdatedAt time.Time `json:"updatedAt" swaggertype:"string" example:"2019-01-01 00:00:00"` // update time
}

type User

type User struct {
	Base
	Username  string    `json:"username"`
	Mobile    string    `json:"mobile"`
	Avatar    string    `json:"avatar"`
	Name      string    `json:"name"`
	Status    *uint     `json:"status"`
	DeptId    uint      `json:"deptId"`
	RoleId    uint      `json:"roleId"`
	LastLogin time.Time `json:"lastLogin"`
	Locked    uint      `json:"locked"`
}

Jump to

Keyboard shortcuts

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