ctxkit

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 1 Imported by: 4

Documentation

Overview

Package ctxkit 操作请求 ctx 信息

Index

Constants

View Source
const (
	// TraceIDKey 请求唯一标识,类型:string
	TraceIDKey key = iota
	// StartTimeKey 请求开始时间,类型:time.Time
	StartTimeKey
	// UserIDKey 用户 ID,未登录则为 0,类型:int64
	UserIDKey
	// ManageUserIdsKey 管辖用户 IDs,未登录则为 '0',类型:int64
	ManageUserIdsKey
	// UserNameKey 用户 名称,类型:string
	UserNameKey
	// NickNameKey 用户 昵称,类型:string
	NickNameKey
	// CompanyIDKey 公司ID,未登录则为 0,类型:int64
	CompanyIDKey
	// DepartmentIDKey 获取当前管辖部门 ID,类型:int64
	DepartmentIDKey
	// DepartmentIdsKey 获取当前部门 IDs 英文逗号隔开,类型:string
	DepartmentIdsKey
	// RolesCodesKey 获取当前权限编码 英文逗号隔开,类型:string
	RolesCodesKey
	// PartIdsKey 获取当前角色 IDs 英文逗号隔开,类型:string
	PartIdsKey
	// PartNamesKey 获取当前角色 Names 英文逗号隔开,类型:string
	PartNamesKey
	// UserIPKey 用户 IP,类型:string
	UserIPKey
	// PlatformKey 用户使用平台,ios, android, pc
	PlatformKey
	// BuildKey 客户端构建版本号
	BuildKey
	// VersionKey 客户端版本号
	VersionKey
	// AccessKey 移动端支付令牌
	AccessKey
	// DeviceKey 移动 app 设备标识,ios, android, phone, pad
	DeviceKey
	// MobiAppKey 移动 app 标识,ios, android, phone, pad
	MobiAppKey
	// UserPortKey 用户端口
	UserPortKey
	// ManageUserKey 管理后台用户名
	ManageUserKey
	// BuvidKey 非登录用户标识
	BuvidKey
	// CookieKey web 用户登录令牌
	CookieKey
	// CompanyAppKeyKey
	CompanyAppKeyKey
	// AppKeyKey 接口签名标识
	AppKeyKey
	// TsKey 时间戳
	TSKey
	// SignKey 签名
	SignKey
	// IsValidSignKeyKey 签名正确则置为 true
	IsValidSignKeyKey
)

Variables

This section is empty.

Functions

func GetAccessKey

func GetAccessKey(ctx context.Context) string

GetAccessKey 获取客户端认证令牌

func GetBuild

func GetBuild(ctx context.Context) string

GetBuild 获取客户端构建版本号

func GetBuvid

func GetBuvid(ctx context.Context) string

GetBuvid 获取用户 buvid

func GetCompanyAppKey

func GetCompanyAppKey(ctx context.Context) string

GetCompanyAppKey 获取用户平台

func GetCompanyID

func GetCompanyID(ctx context.Context) int64

GetCompanyID 获取当前公司 ID

func GetCookie

func GetCookie(ctx context.Context) string

GetCookie 获取 web cookie

func GetDepartmentID

func GetDepartmentID(ctx context.Context) int64

GetDepartmentID 获取当前管辖部门 ID

func GetDepartmentIds

func GetDepartmentIds(ctx context.Context) string

GetDepartmentIds 获取当前部门 ID 英文逗号隔开

func GetDevice

func GetDevice(ctx context.Context) string

GetDevice 获取用户设备,配合 GetPlatform 使用

func GetManageUser

func GetManageUser(ctx context.Context) string

GetManageUser 获取管理后台用户名

func GetManageUserIds added in v1.3.0

func GetManageUserIds(ctx context.Context) string

GetManageUserIds 获取当前管辖用户 IDS

func GetMobiApp

func GetMobiApp(ctx context.Context) string

GetMobiApp 获取 APP 标识

func GetNickName

func GetNickName(ctx context.Context) (nickName string)

GetNickName 获取当前登录用户 昵称

func GetPartIds

func GetPartIds(ctx context.Context) string

GetPartIds 获取当前角色 ID 英文逗号隔开

func GetPartNames added in v1.3.5

func GetPartNames(ctx context.Context) string

GetPartNames 获取当前角色 ID 英文逗号隔开

func GetPlatform

func GetPlatform(ctx context.Context) string

GetPlatform 获取用户平台

func GetRolesCodes added in v1.3.0

func GetRolesCodes(ctx context.Context) string

GetRolesCodes 获取当前权限编码 英文逗号隔开

func GetSign

func GetSign(ctx context.Context) (appkey, ts, sign string)

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID 获取用户请求标识

func GetUserID

func GetUserID(ctx context.Context) int64

GetUserID 获取当前登录用户 ID

func GetUserIP

func GetUserIP(ctx context.Context) string

GetUserIP 获取用户 IP

func GetUserName

func GetUserName(ctx context.Context) (uName string)

GetUserName 获取当前登录用户 Name

func GetUserPort

func GetUserPort(ctx context.Context) string

GetUserPort 获取用户端口

func GetVersion

func GetVersion(ctx context.Context) string

GetVersion 获取客户端版本

func IsIOSPlatform

func IsIOSPlatform(ctx context.Context) bool

IsIOSPlatform 判断是否为 IOS 平台

func IsValidSignKey

func IsValidSignKey(ctx context.Context) bool

IsValidSignKey 判断业务签名是否正确

func WithAccessKey

func WithAccessKey(ctx context.Context, accessKey string) context.Context

WithAccessKey 注入客户端认证令牌

func WithCompanyID

func WithCompanyID(ctx context.Context, companyID int64) context.Context

WithCompanyID 注入当前公司 ID

func WithDepartmentID

func WithDepartmentID(ctx context.Context, departmentID int64) context.Context

WithDepartmentID 注入当前管辖部门 ID

func WithDepartmentIds

func WithDepartmentIds(ctx context.Context, departmentID string) context.Context

WithDepartmentIds 注入当前管辖部门 ID 英文逗号隔开

func WithDevice

func WithDevice(ctx context.Context, deviceKey string) context.Context

WithDevice 注入 Device 标识

func WithManageUserIds added in v1.3.0

func WithManageUserIds(ctx context.Context, userIds string) context.Context

WithManageUserIds 注入当前管辖用户 IDS

func WithMobiApp

func WithMobiApp(ctx context.Context, mobiAppKey string) context.Context

WithMobiApp 获取 APP 标识

func WithNickName

func WithNickName(ctx context.Context, userName string) context.Context

WithNickName 注入当前登录用户 昵称

func WithPartIds

func WithPartIds(ctx context.Context, partIds string) context.Context

WithPartIds 注入当前角色 ID 英文逗号隔开

func WithPartNames added in v1.3.5

func WithPartNames(ctx context.Context, partNames string) context.Context

WithPartNames 注入当前角色 ID 英文逗号隔开

func WithPlatform

func WithPlatform(ctx context.Context, platform string) context.Context

func WithRolesCodes added in v1.3.0

func WithRolesCodes(ctx context.Context, rolesCodes string) context.Context

WithRolesCodes 注入当前权限编码 英文逗号隔开

func WithSignKey

func WithSignKey(ctx context.Context, signKey string) context.Context

WithAccessKey 注入签名认证令牌

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) context.Context

WithTraceID 注入 trace_id

func WithUserID

func WithUserID(ctx context.Context, userID int64) context.Context

WithUserID 注入当前登录用户 ID

func WithUserIP

func WithUserIP(ctx context.Context, userIP string) context.Context

func WithUserName

func WithUserName(ctx context.Context, userName string) context.Context

WithUserName 注入当前登录用户 Name

func WithVersion

func WithVersion(ctx context.Context, version string) context.Context

Types

This section is empty.

Jump to

Keyboard shortcuts

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