user

package
v0.0.0-...-86e0aa6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateUserRequest

type CreateUserRequest struct {
	UserName string            `json:"username" gorm:"column:username" comment:"用户名, 用户名不允许重复的"`
	PassWord string            `json:"password" gorm:"column:password" comment:"不能保持用户的明文密码,hash算法"`
	Label    map[string]string `json:"label" gorm:"column:label;serializer:json"`
	Role     Roles             `json:"role" gorm:"column:role;comment:用户角色,0表示普通用户,1表示审核用户,2表示管理员"`
}

func NewCreateUserRequest

func NewCreateUserRequest() *CreateUserRequest

暂时可无

func (*CreateUserRequest) HashPassword

func (req *CreateUserRequest) HashPassword()

密码hash加密

type DeleteUserRequest

type DeleteUserRequest struct {
	Id       int64  `json:"id" gorm:"column:id"`
	Username string `json:"username" gorm:"column:username;comment:用户名, 用户名不允许重复的"`
}

func NewDeleteUserRequest

func NewDeleteUserRequest() *DeleteUserRequest

创建DeleteUserRequest结构体 此处给api调用时使用的

type EditUserRequest

type EditUserRequest struct {
	Username string `json:"username" gorm:"column:username;comment:用户名, 用户名不允许重复的"`
	PassWord string `json:"password" gorm:"column:password;comment:不能保持用户的明文密码,hash算法"`
}

func NewEditUserRequest

func NewEditUserRequest() *EditUserRequest

创建EditUserRequest结构体 此处给api调用时使用的

type QueryUserRequest

type QueryUserRequest struct {
	QueryByID int64 `json:"id"` //当queryby等于0时,传进去的就是id,1时就是nanme
	// QueryBy       QueryUserBy //当queryby等于0时,传进去的就是id,1时就是nanme
	QueryByName string `json:"username" gorm:"column:username;comment:用户名, 用户名不允许重复的"`
}

func NewQueryUserRequest

func NewQueryUserRequest() *QueryUserRequest

创建QueryUserRequest结构体

type Roles

type Roles int
const (
	// 创建者, 负责博客创作
	ROLE_CREATE Roles = iota
	// 审核员
	ROLE_AUDITOR
	// 系统管理员
	ROLE_ADMIN
)

type Service

type Service interface {
	CreateUser(context.Context, *CreateUserRequest) (*Users, error)
	QueryUser(context.Context, *QueryUserRequest) (*Users, error)
	EditUser(context.Context, *EditUserRequest) (*Users, error)
	DeleteUser(context.Context, *DeleteUserRequest) error
}

type Users

type Users struct {
	*common.Meta
	Username string `json:"username" gorm:"column:username;comment:用户名, 用户名不允许重复的"`
	Password string `json:"password" gorm:"column:password;comment:不能保持用户的明文密码,hash算法"`
	Role     Roles  `json:"role" gorm:"column:role;comment:用户角色,0表示普通用户,1表示审核用户,2表示管理员"`
}

func NewUsers

func NewUsers(req *CreateUserRequest) *Users

创建用户,需要创建对象

func (*Users) String

func (u *Users) String() string

func (*Users) TableName

func (*Users) TableName() string

返回表名

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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