user

package
v8.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserRoleSet = wire.NewSet(wire.Struct(new(UserRoleRepo), "*"))

UserRoleSet 注入UserRole

View Source
var UserSet = wire.NewSet(wire.Struct(new(UserRepo), "*"))

UserSet 注入User

Functions

func GetUserDB

func GetUserDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetUserDB 获取用户存储

func GetUserRoleDB

func GetUserRoleDB(ctx context.Context, defDB *gorm.DB) *gorm.DB

GetUserRoleDB 获取用户角色关联存储

Types

type SchemaUser

type SchemaUser schema.User

SchemaUser 用户对象

func (SchemaUser) ToUser

func (a SchemaUser) ToUser() *User

ToUser 转换为用户实体

type SchemaUserRole

type SchemaUserRole schema.UserRole

SchemaUserRole 用户角色

func (SchemaUserRole) ToUserRole

func (a SchemaUserRole) ToUserRole() *UserRole

ToUserRole 转换为角色菜单实体

type User

type User struct {
	util.Model
	UserName string  `gorm:"size:64;uniqueIndex;default:'';not null;"` // 用户名
	RealName string  `gorm:"size:64;index;default:'';"`                // 真实姓名
	Password string  `gorm:"size:40;default:'';"`                      // 密码(sha1(md5(明文)))
	Email    *string `gorm:"size:255;"`                                // 邮箱
	Phone    *string `gorm:"size:20;"`                                 // 手机号
	Status   int     `gorm:"index;default:0;"`                         // 状态(1:启用 2:停用)
	Creator  uint64  `gorm:""`                                         // 创建者
}

User 用户实体

func (User) ToSchemaUser

func (a User) ToSchemaUser() *schema.User

ToSchemaUser 转换为用户对象

type UserRepo

type UserRepo struct {
	DB *gorm.DB
}

UserRepo 用户存储

func (*UserRepo) Create

func (a *UserRepo) Create(ctx context.Context, item schema.User) error

Create 创建数据

func (*UserRepo) Delete

func (a *UserRepo) Delete(ctx context.Context, id uint64) error

Delete 删除数据

func (*UserRepo) Get

func (a *UserRepo) Get(ctx context.Context, id uint64, opts ...schema.UserQueryOptions) (*schema.User, error)

Get 查询指定数据

func (*UserRepo) Query

Query 查询数据

func (*UserRepo) Update

func (a *UserRepo) Update(ctx context.Context, id uint64, item schema.User) error

Update 更新数据

func (*UserRepo) UpdatePassword

func (a *UserRepo) UpdatePassword(ctx context.Context, id uint64, password string) error

UpdatePassword 更新密码

func (*UserRepo) UpdateStatus

func (a *UserRepo) UpdateStatus(ctx context.Context, id uint64, status int) error

UpdateStatus 更新状态

type UserRole

type UserRole struct {
	util.Model
	UserID uint64 `gorm:"index;default:0;"` // 用户内码
	RoleID uint64 `gorm:"index;default:0;"` // 角色内码
}

UserRole 用户角色关联实体

func (UserRole) ToSchemaUserRole

func (a UserRole) ToSchemaUserRole() *schema.UserRole

ToSchemaUserRole 转换为用户角色对象

type UserRoleRepo

type UserRoleRepo struct {
	DB *gorm.DB
}

UserRoleRepo 用户角色存储

func (*UserRoleRepo) Create

func (a *UserRoleRepo) Create(ctx context.Context, item schema.UserRole) error

Create 创建数据

func (*UserRoleRepo) Delete

func (a *UserRoleRepo) Delete(ctx context.Context, id uint64) error

Delete 删除数据

func (*UserRoleRepo) DeleteByUserID

func (a *UserRoleRepo) DeleteByUserID(ctx context.Context, userID uint64) error

DeleteByUserID 根据用户ID删除数据

func (*UserRoleRepo) Get

Get 查询指定数据

func (*UserRoleRepo) Query

Query 查询数据

func (*UserRoleRepo) Update

func (a *UserRoleRepo) Update(ctx context.Context, id uint64, item schema.UserRole) error

Update 更新数据

type UserRoles

type UserRoles []*UserRole

UserRoles 用户角色关联列表

func (UserRoles) ToSchemaUserRoles

func (a UserRoles) ToSchemaUserRoles() []*schema.UserRole

ToSchemaUserRoles 转换为用户角色对象列表

type Users

type Users []*User

Users 用户实体列表

func (Users) ToSchemaUsers

func (a Users) ToSchemaUsers() []*schema.User

ToSchemaUsers 转换为用户对象列表

Jump to

Keyboard shortcuts

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