common

package
v0.0.0-...-caf75cb Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessCode = "100000"
	ErrorCode   = "100001"
	NoPermCode  = "100002"
)
View Source
const (
	SuccessMsg = "操作成功"
	ErrorMsg   = "系统异常"
	NoPermMsg  = "没有权限"
)
View Source
const UserTokenForIdPrefix = "user_id_"
View Source
const UserTokenForUniqueCodePrefix = "user_uniqueCode_"
View Source
const UserTokenPrefix = "user_token_"

Variables

This section is empty.

Functions

func GetCache

func GetCache() *cache.Cache

func GetConfig

func GetConfig(section, key string) string

func GetGormDB

func GetGormDB() *gorm.DB

func GetSectionConfig

func GetSectionConfig(section string) map[string]string

func GetUserDataByToken

func GetUserDataByToken(token string) (data interface{})

* 根据token获取用户信息 @param string token

func GetUserIdByToken

func GetUserIdByToken(token string) (id uint)

* 根据token获取用户id @param string token

func GetUserUniqueCodeByToken

func GetUserUniqueCodeByToken(token string) (uniqueCode string)

* 根据token获取用户UniqueCode @param string token

func OssUpload

func OssUpload(objectKey string, reader io.Reader) (string, error)

func SetUserToken

func SetUserToken(id uint, uniqueCode string, data interface{}) string

* 设置用户token @param id uint 用户id @param uniqueCode string 用户唯一码 @param data interface 用户信息

func WhereBuild

func WhereBuild(where map[string]interface{}) (whereSQL string, vals []interface{})

Types

type NullType

type NullType byte
const (

	// IsNull the same as `is null`
	IsNull NullType
	// IsNotNull the same as `is not null`
	IsNotNull
)

type Output

type Output struct {
	Code   string      `json:"code"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
	Custom interface{} `json:"custom"`
	Token  string      `json:"token"`
}

func (*Output) ErrorOutput

func (output *Output) ErrorOutput(msg string) *Output

func (*Output) SuccessOutput

func (output *Output) SuccessOutput(data interface{}, msg string) *Output

Jump to

Keyboard shortcuts

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