service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const USER_LOGIN_TPL = "user:login:%d"

用户登录标识

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationClaims

type AuthorizationClaims struct {
	jwt.StandardClaims
	Id uint
}

type Model

type Model interface {
	Get(req, resp interface{}) error
	Count(req, resp interface{}) error
	Select(req, resp interface{}) error
	Insert(req, resp interface{}) error
	Update(req, resp interface{}) error
}

type Service

type Service struct {
	Mdl Model
}

func NewService

func NewService(mdl Model) *Service

func (*Service) Get

func (s *Service) Get(req, data any) *contexts.RESPONSE

func (*Service) Insert

func (s *Service) Insert(req any) *contexts.RESPONSE

func (*Service) List

func (s *Service) List(req, data any) *contexts.RESPONSEWITHCOUNT

func (*Service) Remove

func (s *Service) Remove(req any) *contexts.RESPONSE

func (*Service) Update

func (s *Service) Update(req any) *contexts.RESPONSE

type UserService

type UserService struct {
	*Service
	Mdl *model.UserModel
}

func NewUserService

func NewUserService() *UserService

func (*UserService) CreateAuthorization

func (us *UserService) CreateAuthorization(id uint) (s string, e error)

生成授权令牌

func (*UserService) DelLogin

func (us *UserService) DelLogin(id uint)

删除登录标识(账号被禁用或者被删除后删除登录标识让用户被动下线)

func (*UserService) GetLogin

func (us *UserService) GetLogin(id uint) string

获取登录标识

func (*UserService) Insert

func (us *UserService) Insert(req any) *contexts.RESPONSE

写入用户信息

func (*UserService) Login

登录操作

func (*UserService) ParseAuthorization

func (us *UserService) ParseAuthorization(s string) (*AuthorizationClaims, *contexts.State)

解析授权令牌

func (*UserService) SetLogin

func (us *UserService) SetLogin(id uint, expireTime int64)

设置登录标识(用户登录后设置)

func (*UserService) Update

func (us *UserService) Update(req any) *contexts.RESPONSE

更新用户信息

Jump to

Keyboard shortcuts

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