user

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CollectionName = "user"

Variables

View Source
var PrefixUserCacheKey = "cache:user:"

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Type    int32  `bson:"type" json:"type"`
	AppId   string `bson:"appId" json:"appId"`
	UnionId string `bson:"unionId" json:"unionId"`
}

type IUserMongoMapper

type IUserMongoMapper interface {
	Insert(ctx context.Context, data *User) (string, error)                             // 插入
	FindOne(ctx context.Context, id string) (*User, error)                              // 查找
	Update(ctx context.Context, data *User) (*mongo.UpdateResult, error)                // 修改
	UpdateById(ctx context.Context, auth *Auth, id string) (*mongo.UpdateResult, error) // 通过id修改授权信息
	Delete(ctx context.Context, id string) (int64, error)                               // 删除
	FindOneByAuth(ctx context.Context, auth *Auth) (*User, error)                       // 查找某个授权信息
	AppendAuth(ctx context.Context, id string, auth *Auth) error                        // 追加授权信息
}

func NewMongoMapper

func NewMongoMapper(config *config.Config) IUserMongoMapper

type MongoMapper

type MongoMapper struct {
	// contains filtered or unexported fields
}

func (*MongoMapper) AppendAuth

func (m *MongoMapper) AppendAuth(ctx context.Context, id string, auth *Auth) error

func (*MongoMapper) Delete

func (m *MongoMapper) Delete(ctx context.Context, id string) (int64, error)

func (*MongoMapper) FindOne

func (m *MongoMapper) FindOne(ctx context.Context, id string) (*User, error)

func (*MongoMapper) FindOneByAuth

func (m *MongoMapper) FindOneByAuth(ctx context.Context, auth *Auth) (*User, error)

func (*MongoMapper) Insert

func (m *MongoMapper) Insert(ctx context.Context, data *User) (string, error)

func (*MongoMapper) Update

func (m *MongoMapper) Update(ctx context.Context, data *User) (*mongo.UpdateResult, error)

func (*MongoMapper) UpdateById

func (m *MongoMapper) UpdateById(ctx context.Context, auth *Auth, id string) (*mongo.UpdateResult, error)

type User

type User struct {
	ID       primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	PassWord string             `bson:"passWord,omitempty" json:"passWord,omitempty"`
	Role     int32              `bson:"role,omitempty" json:"role,omitempty"`
	Auths    []*Auth            `bson:"auths,omitempty" json:"auths,omitempty"`
	UpdateAt time.Time          `bson:"updateAt,omitempty" json:"updateAt,omitempty"`
	CreateAt time.Time          `bson:"createAt,omitempty" json:"createAt,omitempty"`
}

Jump to

Keyboard shortcuts

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