Documentation ¶
Index ¶
- Constants
- Variables
- func AddCodesToGift(ctx context.Context, appId, giftId string, giftCodes []string) (err error)
- func Allow(ctx context.Context, appId string, keys []string) (err error)
- func BanUsers(ctx context.Context, appId string, userIds []string, banTo time.Time, ...) (err error)
- func BindAcctIdToUser(ctx context.Context, appId, userId string, acctIds []string, ...) (_ []string, err error)
- func Block(ctx context.Context, appId string, keys []string, banTo time.Time, ...) (err error)
- func CancelOrder(ctx context.Context, appId, orderId, reason string) (err error)
- func CheckNonce(ctx context.Context, appId, nonce string) (err error)
- func CreateGift(ctx context.Context, appId string, gift *Gift, codes []string) (err error)
- func CreateOrder(ctx context.Context, appId string, data *v1pb.PurchaseData) (err error)
- func DecId(id string) (appKey uint32, tag uint8, err error)
- func DelCodesFromGift(ctx context.Context, appId string, codes []string) (err error)
- func FulfillOrder(ctx context.Context, appId, orderId string) (err error)
- func GetAcctIdByDetail(ctx context.Context, appId string, keyVals map[string]string) (acctIds []string, err error)
- func GetOrder(ctx context.Context, appId, orderId string) (_ *v1pb.PurchaseData, err error)
- func IdBelongToAppId(appId string, ids ...string) bool
- func LoginUser(ctx context.Context, app *App, clientIp, deviceId string, acctIds []string, ...) (_ *User, _ *Sess, err error)
- func LogoutUser(ctx context.Context, userIds ...string) (err error)
- func PayOrder(ctx context.Context, appId, orderId, transactionId, receipt string) (err error)
- func RevokeGift(ctx context.Context, appId, giftId string) (err error)
- func SetRoleMetadata(ctx context.Context, appId, roleId string, md map[string]string) (err error)
- func SetUserMetadata(ctx context.Context, appId, userId string, md map[string]string) (err error)
- func SignInRole(ctx context.Context, appId, roleId string) (err error)
- func UnbanUsers(ctx context.Context, appId string, userIds []string) (err error)
- func UnbindAcctIdFromUser(ctx context.Context, appId, userId string, acctIds []string) (_ []string, err error)
- func UpdateAcctDetail(ctx context.Context, appId, acctId, detail string) (err error)
- func UpdateGift(ctx context.Context, appId string, gift *Gift) (err error)
- func WatchApps(ch chan<- []*App) func()
- type Admin
- type App
- type BlockData
- type Gift
- func GetAllGifts(ctx context.Context, appId string) (gifts []*Gift, err error)
- func GetGiftByCode(ctx context.Context, appId, code string) (_ *Gift, err error)
- func GetGiftById(ctx context.Context, appId, giftId string) (_ *Gift, err error)
- func RedeemGiftCode(ctx context.Context, appId, code string) (_ *Gift, err error)
- func VerifyGiftCode(ctx context.Context, appId, code string) (_ *Gift, err error)
- type GiftCode
- type Permission
- type Role
- func AlterRoleIndex(ctx context.Context, appId, roleId string, index uint32) (_ *Role, err error)
- func CreateRole(ctx context.Context, appId, userId string, index uint32) (_ *Role, err error)
- func GetRole(ctx context.Context, appId, roleId string) (_ *Role, err error)
- func GetRoles(ctx context.Context, appId string, roleIds []string) (_ []*Role, err error)
- func GetRolesByUserId(ctx context.Context, appId string, userIds []string) (_ []*Role, err error)
- func ListRoles(ctx context.Context, appId, userId string) (_ []*Role, err error)
- type Sess
- type SessData
- type User
- func GetUser(ctx context.Context, appId, userId string) (_ *User, err error)
- func GetUsers(ctx context.Context, appId string, userIds []string) (_ []*User, err error)
- func GetUsersByAcctId(ctx context.Context, appId string, acctIds ...string) (_ []*User, err error)
- func GetUsersWithFields(ctx context.Context, appId string, userIds, fields []string) (_ []*User, err error)
Constants ¶
View Source
const ( UserIdTag uint8 = 0x1 RoleIdTag uint8 = 0x2 )
Variables ¶
View Source
var ( // Unauthenticated ErrInvalidToken = newUnauthenticatedError("invalid token") // NotFound ErrUserNotFound = newNotFoundError("user not found") ErrRoleNotFound = newNotFoundError("role not found") ErrAcctIdNotFound = newNotFoundError("acct id not found") // AlreadyExists ErrAcctAlreadyExists = newAlreadyExistsError("acct already exists") // InvalidArgument ErrInvalidNonce = newInvalidArgumentError("invalid nonce") ErrInvalidAppId = newInvalidArgumentError("invalid app id") ErrInvalidAcctId = newInvalidArgumentError("invalid acct id") // Internal ErrMalformedSessData = newInternalError("malformed session data") ErrDatabaseUnavailable = newUnavailableError("database unavailable") )
Functions ¶
func AddCodesToGift ¶
func BindAcctIdToUser ¶
func CancelOrder ¶
设置订单已取消
func CreateGift ¶
func CreateOrder ¶
创建订单
func DelCodesFromGift ¶
func GetAcctIdByDetail ¶
func IdBelongToAppId ¶
func SetRoleMetadata ¶
func SetUserMetadata ¶
func UnbindAcctIdFromUser ¶
func UpdateAcctDetail ¶
Types ¶
type Admin ¶
type Admin struct { Id string `bson:"_id"` Name string `bson:"name"` Description string `bson:"description"` Secret string `bson:"secret,omitempty"` Permissions []*Permission `bson:"permissions,omitempty"` }
func FindAdminById ¶
func (*Admin) IsPermitted ¶
type App ¶
type App struct { // 应用ID Id string `bson:"_id"` // 数值形式的应用ID Key uint32 `bson:"key"` // 应用签名密钥,授权访问 Secret string `bson:"secret,omitempty"` // 应用指纹,特异化应用数据,增加安全性 Fingerprint string `bson:"fingerprint,omitempty"` // 允许的服务 Permissions []*Permission `bson:"permissions,omitempty"` // contains filtered or unexported fields }
func FindAppById ¶
func (*App) IsPermitted ¶
type BlockData ¶
type Gift ¶
type Gift struct { // ID Id string `bson:"_id,omitempty"` // 更新时间 UpdateAt time.Time `bson:"update_at,omitempty"` // 过期时间 ExpireAt time.Time `bson:"expire_at,omitempty"` // 有效载荷 Payload []byte `bson:"payload,omitempty"` }
func GetGiftByCode ¶
func RedeemGiftCode ¶
type GiftCode ¶
type Permission ¶
type Role ¶
type Role struct { Id string `bson:"_id"` // 角色序号,主要有一下几个用途 // 1. 创建用户发生重试时保证只有唯一一个角色被成功创建 // 2. 用来确定该用户的角色分类,比如分区分服 Index uint32 `bson:"index,omitempty"` // 所属用户ID UserId string `bson:"user_id,omitempty"` // 创建时间 CreateAt time.Time `bson:"create_at,omitempty"` // 上次登录时间 SignInAt time.Time `bson:"sign_in_at,omitempty"` // 元数据 Metadata map[string]string `bson:"metadata,omitempty"` }
func AlterRoleIndex ¶
func CreateRole ¶
func GetRolesByUserId ¶
type Sess ¶
type User ¶
type User struct { Id string `bson:"_id"` // 用户账号列表,其中任意一个匹配都可以认定为该用户 // 常见的用例为: // 1. 游客账号/正式账号 // 2. 平台账号/第三方账号 AcctIds []string `bson:"acct_ids,omitempty"` // 创建时间 CreateAt time.Time `bson:"create_at,omitempty"` // 创建时IP CreateIp string `bson:"create_ip,omitempty"` // 上次登录时间 LoginAt time.Time `bson:"login_at,omitempty"` // 上次登录时IP LoginIp string `bson:"login_ip,omitempty"` // 封号时间 BanAt time.Time `bson:"ban_at,omitempty"` // 封号时间 BanTo time.Time `bson:"ban_to,omitempty"` // 封号原因 BanFor string `bson:"ban_for,omitempty"` // 元数据 Metadata map[string]string `bson:"metadata,omitempty"` }
func GetUsersByAcctId ¶
Click to show internal directories.
Click to hide internal directories.