utils

package
v0.0.0-...-c780586 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TokenClaimEXP 有效期标识
	TokenClaimEXP = "exp"
	// TokenClaimOpenID 用户OpenID标识
	TokenClaimOpenID = "openID"
	// TermOfValidity 有效期7天
	TermOfValidity = 24 * 7
)

Functions

func CheckJwtToken

func CheckJwtToken(tokenString string) bool

CheckJwtToken 检查token是否有效

func CheckJwtTokenExpected

func CheckJwtTokenExpected(tokenString string) error

CheckJwtTokenExpected 检查token是否过期

func DateFormat

func DateFormat(time time.Time) string

日期格式化:2006-01-02

func Error

func Error(r *ghttp.Request)

func GenJwtToken

func GenJwtToken(claims jwt.MapClaims) (string, error)

GenJwtToken 生成token

func GenOpenIDToken

func GenOpenIDToken(openID string) (string, error)

GenOpenIDToken 根据OPenID生成token

func GenSecretToken

func GenSecretToken(secret string) (string, error)

GenSecretToken 根据secret生成token

func GenderCode

func GenderCode() string

func GetOpenIDFromToken

func GetOpenIDFromToken(tokenString string) (string, error)

GetOpenIDFromToken 从token中拿到openid

func GetUUID

func GetUUID() string

GetUUID 获取uuid

func Md5

func Md5(str string) string

Md5 md5加密

func ParseJwtToken

func ParseJwtToken(tokenString string) (*jwt.Token, error)

ParseJwtToken 解析token

func Success

func Success(r *ghttp.Request, data interface{})

func TimeFormat

func TimeFormat(time time.Time) string

日期格式化:2006-01-02 15:04:05

Types

type AdminResponse

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

后台的Response,为了兼容

type AutoInc

type AutoInc struct {
	// contains filtered or unexported fields
}
var Id *AutoInc

func (*AutoInc) Close

func (ai *AutoInc) Close()

Close 关闭生成器

func (*AutoInc) Next

func (ai *AutoInc) Next() int

Next 获取一个id

type GetAccessTokenResponse

type GetAccessTokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type KeyWordData

type KeyWordData struct {
	Value string `json:"value"`
	Color string `json:"color,omitempty"`
}

type Miniprogram

type Miniprogram struct {
	AppID    string `json:"appid"`
	Pagepath string `json:"pagepath"`
}

type Response

type Response struct {
	Code int
	Data interface{}
	Msg  string
}

Response 封装请求返回体

func ErrorResponse

func ErrorResponse(msg string) *Response

ErrorReponse 错误返回体

func SuccessResponse

func SuccessResponse(msg string) *Response

SuccessReponse 成功返回体

func SuccessWithData

func SuccessWithData(msg string, data interface{}) *Response

successWithData 成功返回体

type SendTemplateResponse

type SendTemplateResponse struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
	MsgID   string `json:"msgid"`
}

func SendTemplate

func SendTemplate(msg *TemplateMsg) (*SendTemplateResponse, error)

SendTemplate 发送模板消息

type TemplateData

type TemplateData struct {
	First    KeyWordData `json:"first,omitempty"`
	Keyword1 KeyWordData `json:"keyword1,omitempty"`
	Keyword2 KeyWordData `json:"keyword2,omitempty"`
	Keyword3 KeyWordData `json:"keyword3,omitempty"`
	Keyword4 KeyWordData `json:"keyword4,omitempty"`
	Keyword5 KeyWordData `json:"keyword5,omitempty"`
}

type TemplateMsg

type TemplateMsg struct {
	Touser      string        `json:"touser"`      //接收者的OpenID
	TemplateID  string        `json:"template_id"` //模板消息ID
	FormID      string        `json:"form_id"`
	URL         string        `json:"url"`         //点击后跳转链接
	Miniprogram Miniprogram   `json:"miniprogram"` //点击跳转小程序
	Data        *TemplateData `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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