common

package
v0.0.0-...-3f61646 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Success        = "success"
	Failed         = "failed"
	CommaSeparator = ","
	DefaultLimit   = 10
)
View Source
const (
	WeiChat_AppId     = "wx_appid"
	WeiChat_AppSecret = "wx_appsecret"
)
View Source
const (
	LanguageEn = "en"
	LanguageZh = "zh"
)
View Source
const (
	EmailRegex = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`
	//MobileRegex = `^\+1([38][0-9]|14[57]|5[^4])\d{8}$`
	MobileRegex = `^\+[1-9]{1}[0-9]{3,14}$`
)
View Source
const (
	AppIOSDeviceType        = "ios"
	AppAndroidDeviceType    = "android"
	AppWebDeviceType        = "web"
	AppWebIosDeviceType     = "web_ios"
	AppWebAndroidDeviceType = "web_android"

	ClientPc     = "pc"
	ClientMobile = "mobile"
	ClientPad    = "pad"
	ClientMweb   = "mweb"
	ClientMinapp = "minapp"

	InternalClientJuicy     = "juicy"
	InternalClientXuangubao = "XGB"
	InternalClientSwagger   = "swagger"
	InternalClientTubiaojia = "TBJ"
	InternalClientCong      = "cong"
	InternalClientAthena    = "athena"
)
View Source
const (
	Md_USERID          = "x-userid"
	Md_CLIENTIP        = "x-clientip"
	Md_DEVICETYPE      = "x-devicetype"
	Md_OWNER           = "x-owner"
	Md_ADMIN_USER_ROLE = "x-admin-user-role"
	Md_HYSTRIX_STATUS  = "x-hystrix-status"
	Md_PLATFORM        = "x-platform"
	Md_HYSTRIX_CLOSED  = "closed"
	Md_HYSTRIX_OPEN    = "open"
	Md_APPHEADER       = "x-app-header"
	Md_Token           = "x-token"
	Md_WEBUSREID       = "x-webuserid"
	Md_APPTYPE         = "x-apptype"
	Md_INSTID          = "x-instid"
	Md_OPENID          = "x-openid"
	Md_SESSIONKEY      = "x-sessionkey"

	RequestHeaderAppOffset_DEVICETYPE = 1
)
View Source
const (
	SkipChartQueries     uint32 = 1
	SkipChartStyle       uint32 = (1 << 1)
	SkipChartSettings    uint32 = (1 << 2)
	SkipChartQueryRecord uint32 = (1 << 3)
)
View Source
const (
	TokenKey    = "tushuangshuang2501hahaha"
	SysTokenKey = "tushuangshuang20190815st"
)
View Source
const (
	Internal = "internal"

	Mobile  = "mobile"
	Email   = "email"
	Wechat  = "wechat"
	Weibo   = "weibo"
	Tencent = "tencent"
	Huawei  = "huawei"
	System  = "system"
)

app_type

View Source
const (
	InternalTokenOutTime = 7 * 24 * 3600
	UserTokenOutTime     = 10 * 365 * 3600 * 24
)
View Source
const (
	Permanent_Expiration = 1999999999
)
View Source
const SolarPlatform = "solar-platform"
View Source
const (
	StatusFrozen = "frozen"
)
View Source
const (
	UserLikeSearch = "like"
)

Variables

View Source
var (
	ContentOrderMap = map[string]string{
		"display_time_desc": "article_display_time desc",
		"display_time_asc":  "article_display_time asc",
		"updated_at_asc":    "updated_at asc",
		"updated_at_desc":   "updated_at desc",
	}
)

Functions

func CheckTextRisk

func CheckTextRisk(text string, token string) bool

func DecryptWeChatData

func DecryptWeChatData(encryptedData, iv, appId, sessionKey string) (map[string]interface{}, error)

func FilterEmoji

func FilterEmoji(content string) string

func GetRandInt

func GetRandInt(n int) int

func GetRandIntRange

func GetRandIntRange(lower int, upper int) int

func GetRolesMap

func GetRolesMap() map[string]string

func NsqChannelName

func NsqChannelName(id string, nameParam string) string

func PKCS7UnPadding

func PKCS7UnPadding(plantText []byte) []byte

func PbGetPlatform

func PbGetPlatform(ctx context.Context) string

func PbGetUser

func PbGetUser(ctx context.Context) int64

func PbMetaGet

func PbMetaGet(k string, ctx context.Context) string

func Struct2Map

func Struct2Map(obj interface{}) map[string]interface{}

func SysTokenToString

func SysTokenToString(o *Token) string

func TokenToString

func TokenToString(o *Token) string

Types

type AccessToken

type AccessToken struct {
	AccessToken string        `json:"access_token"`
	ExpiresIn   time.Duration `json:"expires_in"`
}

func GetAccessToken

func GetAccessToken() *AccessToken

type CheckRsp

type CheckRsp struct {
	Errcode int32  `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}

type QRCode

type QRCode struct {
	Scene string `json:"scene"`
	Page  string `json:"page"`
	Width int32  `json:"width"`
}

type Token

type Token struct {
	AppType    string
	UserId     int64
	OpenId     string
	SessionKey string
	Expiration int64 // FIXME: not used for now
}

func SysTokenFromString

func SysTokenFromString(content string) (*Token, error)

func TokenFromString

func TokenFromString(content string) (*Token, error)

Jump to

Keyboard shortcuts

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