mo2utils

package
v0.0.0-...-bef4ad1 Latest Latest
Warning

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

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

Documentation

Index

Examples

Constants

View Source
const UserInfoKey = "User"

UserInfoKey name of param whitch stores userinfo in gin.Context

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, item string) bool

Contains test slice contain string

func DeleteAccountIndex

func DeleteAccountIndex(id string)

func DeleteBlogIndex

func DeleteBlogIndex(id string)

func DeleteProjectIndex

func DeleteProjectIndex(id string)

func GenerateJwtCode

func GenerateJwtCode(info dto.LoginUserInfo) string

GenerateJwtCode generate jwt token with claim in type JwtClaims for info dto.LoginUserInfo jwtToken string

func GenerateJwtToken

func GenerateJwtToken(info string, expireAt time.Time) string

GenerateJwtToken generate jwt token with claim in type JwtClaims for info string jwtToken string

func GenerateVerifyJwtToken

func GenerateVerifyJwtToken(info string) string

GenerateVerifyJwtToken generate jwt token with claim in type JwtClaims for info string jwtToken string

func GetKey

func GetKey() (key []byte, err error)

GetKey from redis or create new key

func GetUserInfo

func GetUserInfo(ctx *gin.Context) (uinfo dto.LoginUserInfo, ext bool)

GetUserInfo get user info from gin context

func IndexAccount

func IndexAccount(account *model.Account)

func IndexAccounts

func IndexAccounts(accounts []model.Account)

func IndexBlog

func IndexBlog(blog *model.Blog)

IndexBlog index the blog

func IndexBlogs

func IndexBlogs(blog []model.Blog)

IndexBlogs index multiple blogs

func IndexProject

func IndexProject(project *model.Project)

func IsEnvRelease

func IsEnvRelease() (release bool)

IsEnvRelease check if GIN_MODE is release

func IsInRole

func IsInRole(ctx *gin.Context, role model.Erole) (result bool)

IsInRole check if user is in role

func ParseJwt

func ParseJwt(tokenString string) (userInfo dto.LoginUserInfo, err error)

ParseJwt for JwtLoginClaims if token is valid, return nil

func ParsePagination

func ParsePagination(ctx *gin.Context) (page int64, pagesize int64, err error)

ParsePagination get pagination info from ctx

func ProcessAllFiles

func ProcessAllFiles(srcPath string, uploadRootPath string, processHandler func(parameter ...string))

ProcessAllFiles use handler function to process each file recursively under srcPath

Example
ProcessAllFiles("./", "/dist", func(parameter ...string) {
	println(parameter[0], "\n", parameter[2])
	//for _,v :=range parameter{
	//	println(v)
	//}
})
Output:

func QueryAccountPrefix

func QueryAccountPrefix(term string) search.DocumentMatchCollection

func QueryBlog

func QueryBlog(search string, page int, pagesize int) search.DocumentMatchCollection

func QueryBlogPrefix

func QueryBlogPrefix(term string) search.DocumentMatchCollection

func QueryProject

func QueryProject(search string, page int, pagesize int) search.DocumentMatchCollection

func QueryUser

func QueryUser(search string, page int, pagesize int) search.DocumentMatchCollection

func UploadCDN

func UploadCDN()

UploadCDN upload frontend files to cdn

Types

type JwtInfoClaims

type JwtInfoClaims struct {
	Info string `json:"info"`
	jwt.StandardClaims
}

JwtInfoClaims claim with extra string info

type JwtLoginClaims

type JwtLoginClaims struct {
	UserInfo dto.LoginUserInfo `json:"user_info"`
	jwt.StandardClaims
}

JwtLoginClaims mo2 jwt claims

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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