common

package
v0.0.0-...-2a2bf8c Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixUserID = "u"
	PrefixRoleID = "r"
)
View Source
const (
	SUCCESS_CODE          = 20000      //成功的状态码
	FAIL_CODE             = 30000      //失败的状态码
	MD5_PREFIX            = "jkfldfsf" //MD5加密前缀字符串
	TOKEN_KEY             = "X-Token"  //页面token键名
	USER_ID_Key           = "X-USERID" //页面用户ID键名
	USER_UUID_Key         = "X-UUID"   //页面UUID键名
	SUPER_ADMIN_ID uint64 = 956986     // 超级管理员账号ID

)

Variables

View Source
var Enforcer *casbin.Enforcer

Functions

func CsbinAddRoleForUser

func CsbinAddRoleForUser(userid uint64) (err error)

用户角色处理

func CsbinCheckPermission

func CsbinCheckPermission(userID, url, methodtype string) (bool, error)

检查用户是否有权限

func CsbinDeleteRole

func CsbinDeleteRole(roleids []uint64)

删除角色

func CsbinSetRolePermission

func CsbinSetRolePermission(roleid uint64)

设置角色权限

func GetPageIndex

func GetPageIndex(c *gin.Context) uint64

获取页码

func GetPageKey

func GetPageKey(c *gin.Context) string

获取搜索关键词信息

func GetPageLimit

func GetPageLimit(c *gin.Context) uint64

获取每页记录数

func GetPageSort

func GetPageSort(c *gin.Context) string

获取排序信息

func GetQueryToStr

func GetQueryToStr(c *gin.Context, key string, defaultValues ...string) string

GetQueryToStr

func GetQueryToStrE

func GetQueryToStrE(c *gin.Context, key string) (string, error)

GetQueryToStrE

func GetQueryToUint

func GetQueryToUint(c *gin.Context, key string, defaultValues ...uint) uint

QueryToUint

func GetQueryToUint64

func GetQueryToUint64(c *gin.Context, key string, defaultValues ...uint64) uint64

QueryToUint

func GetQueryToUint64E

func GetQueryToUint64E(c *gin.Context, key string) (uint64, error)

QueryToUintE

func GetQueryToUintE

func GetQueryToUintE(c *gin.Context, key string) (uint, error)

QueryToUintE

func InitCsbinEnforcer

func InitCsbinEnforcer() (err error)

角色-URL导入

func ResErrCli

func ResErrCli(c *gin.Context, err error)

响应错误-用户端故障

func ResErrSrv

func ResErrSrv(c *gin.Context, err error)

响应错误-服务端故障

func ResFail

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

响应失败

func ResFailCode

func ResFailCode(c *gin.Context, msg string, code int)

响应失败

func ResJSON

func ResJSON(c *gin.Context, status int, v interface{})

响应JSON数据

func ResSuccess

func ResSuccess(c *gin.Context, v interface{})

响应成功

func ResSuccessMsg

func ResSuccessMsg(c *gin.Context)

响应成功

func ResSuccessPage

func ResSuccessPage(c *gin.Context, total uint64, list interface{})

响应成功-分页数据

func UploadFiles

func UploadFiles(c *gin.Context)

/ 上传接口

Types

type ResponseModel

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

type ResponseModelBase

type ResponseModelBase struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ResponsePage

type ResponsePage struct {
	Code    int              `json:"code"`
	Message string           `json:"message"`
	Data    ResponsePageData `json:"data"`
}

type ResponsePageData

type ResponsePageData struct {
	Total uint64      `json:"total"`
	Items interface{} `json:"items"`
}

Jump to

Keyboard shortcuts

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