utils

package
v0.0.0-...-6a5318f Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const FailedCode = "failed"

FailedCode 请求失败

View Source
const FailedMsg = "操作失败"

FailedMsg 失败提示信息

View Source
const SuccessCode = "success"

SuccessCode 请求成功

View Source
const SuccessMsg = "操作成功"

SuccessMsg 成功提示信息

Variables

View Source
var DefaultPageLimit = 20

DefaultPageLimit 默认每页数量

View Source
var FilterUser = func(ctx *context.Context) {
	_, ok := ctx.Input.Session("uid").(int)
	if !ok && ctx.Request.RequestURI != "/login" {
		ctx.Redirect(302, "/login")
	}
}
View Source
var GlobalGroupMenus = make(map[string]interface{})

GlobalGroupMenus 全局权限组菜单

View Source
var GlobalSessions *session.Manager

GlobalSessions 全局session

Functions

func Decode

func Decode(data []byte, to interface{}) error

Decode 用gob进行数据解码

func DelCache

func DelCache(key string) error

DelCache 删除缓存信息

func Encode

func Encode(data interface{}) ([]byte, error)

Encode 用gob进行数据编码

func GetCache

func GetCache(key string, to interface{}) error

GetCache 获得缓存信息

func InitCache

func InitCache()

InitCache 根据conf初始化cache

func JSONreflectStruct

func JSONreflectStruct(jsonData map[string]interface{}, obj interface{}) (err error)

JSONreflectStruct json数据反射为结构体

func LogOut

func LogOut(level, v interface{})

LogOut 输出日志 @Title LogOut @Param body body models.AccountAccountTag true "body for AccountAccountTag content"

func PasswordMD5

func PasswordMD5(passwd, salt string) string

@Title 生成密码 @Description create AccountAccount @Param body body models.AccountAccount true "body for AccountAccount content" @Success 201 {int} models.AccountAccount @Failure 403 body is empty

func SetCache

func SetCache(key string, value interface{}, timeout int) error

SetCache 设置缓存

func StringsJoin

func StringsJoin(strs ...string) string

StringsJoin 字符串拼接

func ToInt64

func ToInt64(v interface{}) (re int64, err error)

ToInt64 类型转换,获得int64

func ToSlice

func ToSlice(arr interface{}) []interface{}

ToSlice 转换为数组

func ToString

func ToString(v interface{}) (re string)

ToString 类型转换,获得string

Types

type AccessResult

type AccessResult struct {
	Create bool
	Update bool
	Read   bool
	Unlink bool
}

AccessResult 表访问权限

type LangType

type LangType struct {
	Lang, Name string
}

LangType 语言

type Paginator

type Paginator struct {
	CurrentPage     int64 `json:"currentPage"`     //当前页
	NextPage        int64 `json:"nextPage"`        //下一页
	PrePage         int64 `json:"prePage"`         //上一页
	PageSize        int64 `json:"pageSize"`        //每页数量
	CurrentPageSize int64 `json:"currentPageSize"` //当前页数量
	TotalPage       int64 `json:"totalPage"`       //总页数
	TotalCount      int64 `json:"totalCount"`      //总数量
	FirstPage       bool  `json:"firstPage"`       //为第一页
	LastPage        bool  `json:"lastPage"`        //为最后一页
	// PageList        []int64 `json:"pageList"`        //显示的页
	Max int64
}

func GenPaginator

func GenPaginator(limit, offset, count int64) Paginator

Jump to

Keyboard shortcuts

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