user

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Code generated by genx:code@v0.4.2 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PromoteByUserID

func PromoteByUserID(ctx context.Context, id string) (any, error)

Types

type Error

type Error int

Error 用户模块错误码 +genx:code @code domain=USER

const (
	ERROR_UNDEFINED Error = iota
	// ERROR__NOT_FOUND_BY_NAME
	// @code api=StatusNotFound
	// @code hint=用户名不存在
	ERROR__NOT_FOUND_BY_NAME
	// ERROR__NOT_FOUND_BY_ID
	// @code api=StatusNotFound
	// @code hint=用ID不存在
	ERROR__NOT_FOUND_BY_ID
	// ERROR__REGISTRATION_NOT_OPEN
	// @code api=StatusForbidden
	// @code hint=注册未开放
	ERROR__REGISTRATION_NOT_OPEN
	// ERROR__USERNAME_CONFLICT
	// @code api=StatusConflict
	// @code hint=用户名已注册
	ERROR__USERNAME_CONFLICT
	// ERROR__PASSWORD_UNMATCHED
	// @code api=StatusUnauthorized
	// @code hint=登陆密码错误
	ERROR__PASSWORD_UNMATCHED
	// ERROR__FAILED_TO_REFRESH_TOKEN
	// @code api=StatusInternalServerError
	ERROR__FAILED_TO_REFRESH_TOKEN
)

func (Error) CodeHint

func (e Error) CodeHint() string

CodeHint returns the message which can be presented to users

func (Error) CodeIdentifier

func (e Error) CodeIdentifier() string

CodeIdentifier returns the unique identifier of the code

func (Error) CodeValues

func (Error) CodeValues() []any

CodeValues implements codex.CanBeCode

func (Error) Message

func (e Error) Message() string

Message presents error message

func (Error) StatusCode

func (e Error) StatusCode() int

StatusCode http status describer

type Info

type Info struct {
	ID           int64     `json:"id"`
	UserID       string    `json:"userID"`
	Username     string    `json:"username"`
	Password     string    `json:"password,omitempty"`
	Type         string    `json:"type"`
	CreatedAt    time.Time `json:"createdAt"`
	LastActiveAt time.Time `json:"lastActiveAt"`
}

func GetByUserID

func GetByUserID(_ context.Context, id string) (*Info, error)

func GetByUsername

func GetByUsername(_ context.Context, name string) (*Info, error)

func Register

func Register(_ context.Context, r *RegisterParam) (*Info, error)

type ListParam

type ListParam struct {
	UserID     string    `in:"query" name:"userID,omitempty"`
	Username   string    `in:"query" name:"username,omitempty"`
	CreatedAt  time.Time `in:"query" name:"createdAt,omitempty"`
	MemberType string    `in:"query" name:"memberType"` // NOTE: required
}

type ListResult

type ListResult struct {
	Data  []*Info `json:"data"`
	Total int     `json:"total"`
}

func ListUsers

func ListUsers(_ context.Context, r *ListParam) (*ListResult, error)

type LoginParam

type LoginParam struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResult

type LoginResult struct {
	UserID    string    `json:"userID"`
	Username  string    `json:"username"`
	Token     string    `json:"token"`
	ExpiredAt time.Time `json:"expiredAt"`
}

func LoginValidateByPassword

func LoginValidateByPassword(ctx context.Context, r *LoginParam) (*LoginResult, error)

func RefreshToken

func RefreshToken(ctx context.Context, t string) (*LoginResult, error)

type PromotionResult

type PromotionResult struct {
	UserID string `json:"userID"`
	Prev   string `json:"prev"`
	Curr   string `json:"curr"`
}

type RegisterParam

type RegisterParam struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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