dao

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Account = NewAccountDao()
View Source
var App = NewAppDao()
View Source
var Chat = NewChatDao()
View Source
var Key = NewKeyDao()
View Source
var Model = NewModelDao()
View Source
var ModelAgent = NewModelAgentDao()
View Source
var SysAdmin = NewSysAdminDao()
View Source
var User = NewUserDao()

Functions

func Aggregate

func Aggregate(ctx context.Context, database, collection string, pipeline []bson.M, result interface{}) error

func AggregateByPage

func AggregateByPage(ctx context.Context, database, collection, countField string, paging *db.Paging, countPipeline, pipeline []bson.M, result interface{}) error

Types

type AccountDao

type AccountDao struct {
	*MongoDB[entity.Account]
}

func NewAccountDao

func NewAccountDao(database ...string) *AccountDao

type AppDao

type AppDao struct {
	*MongoDB[entity.App]
}

func NewAppDao

func NewAppDao(database ...string) *AppDao

func (*AppDao) FindByAppId

func (d *AppDao) FindByAppId(ctx context.Context, appId int) (*entity.App, error)

根据appId查询应用

type ChatDao

type ChatDao struct {
	*MongoDB[entity.Chat]
}

func NewChatDao

func NewChatDao(database ...string) *ChatDao

type IMongoDB

type IMongoDB interface{}

type KeyDao

type KeyDao struct {
	*MongoDB[entity.Key]
}

func NewKeyDao

func NewKeyDao(database ...string) *KeyDao

type ModelAgentDao

type ModelAgentDao struct {
	*MongoDB[entity.ModelAgent]
}

func NewModelAgentDao

func NewModelAgentDao(database ...string) *ModelAgentDao

type ModelDao

type ModelDao struct {
	*MongoDB[entity.Model]
}

func NewModelDao

func NewModelDao(database ...string) *ModelDao

type MongoDB

type MongoDB[T IMongoDB] struct {
	*db.MongoDB
}

func NewMongoDB

func NewMongoDB[T IMongoDB](database, collection string) *MongoDB[T]

func (*MongoDB[T]) Aggregate

func (m *MongoDB[T]) Aggregate(ctx context.Context, pipeline []bson.M, result interface{}) error

func (*MongoDB[T]) AggregateByPage

func (m *MongoDB[T]) AggregateByPage(ctx context.Context, countField string, paging *db.Paging, countPipeline, pipeline []bson.M, result interface{}) error

func (*MongoDB[T]) CountDocuments

func (m *MongoDB[T]) CountDocuments(ctx context.Context, filter map[string]interface{}) (int64, error)

func (*MongoDB[T]) DeleteById

func (m *MongoDB[T]) DeleteById(ctx context.Context, id interface{}) (int64, error)

func (*MongoDB[T]) DeleteMany

func (m *MongoDB[T]) DeleteMany(ctx context.Context, filter map[string]interface{}) (int64, error)

func (*MongoDB[T]) DeleteOne

func (m *MongoDB[T]) DeleteOne(ctx context.Context, filter map[string]interface{}) (int64, error)

func (*MongoDB[T]) EstimatedDocumentCount

func (m *MongoDB[T]) EstimatedDocumentCount(ctx context.Context) (int64, error)

func (*MongoDB[T]) Find

func (m *MongoDB[T]) Find(ctx context.Context, filter map[string]interface{}, sortFields ...string) ([]*T, error)

func (*MongoDB[T]) FindById

func (m *MongoDB[T]) FindById(ctx context.Context, id interface{}) (*T, error)

func (*MongoDB[T]) FindByIds

func (m *MongoDB[T]) FindByIds(ctx context.Context, ids interface{}) ([]*T, error)

func (*MongoDB[T]) FindByPage

func (m *MongoDB[T]) FindByPage(ctx context.Context, paging *db.Paging, filter map[string]interface{}, sortFields ...string) ([]*T, error)

func (*MongoDB[T]) FindOne

func (m *MongoDB[T]) FindOne(ctx context.Context, filter map[string]interface{}, sortFields ...string) (*T, error)

func (*MongoDB[T]) FindOneAndDelete

func (m *MongoDB[T]) FindOneAndDelete(ctx context.Context, filter map[string]interface{}) (*T, error)

func (*MongoDB[T]) FindOneAndDeleteById

func (m *MongoDB[T]) FindOneAndDeleteById(ctx context.Context, id interface{}) (*T, error)

func (*MongoDB[T]) FindOneAndUpdate

func (m *MongoDB[T]) FindOneAndUpdate(ctx context.Context, filter map[string]interface{}, update interface{}, isUpsert ...bool) (*T, error)

func (*MongoDB[T]) FindOneAndUpdateById

func (m *MongoDB[T]) FindOneAndUpdateById(ctx context.Context, id interface{}, update interface{}, isUpsert ...bool) (*T, error)

func (*MongoDB[T]) Insert

func (m *MongoDB[T]) Insert(ctx context.Context, document interface{}) (string, error)

func (*MongoDB[T]) Inserts

func (m *MongoDB[T]) Inserts(ctx context.Context, documents []interface{}) ([]string, error)

func (*MongoDB[T]) UpdateById

func (m *MongoDB[T]) UpdateById(ctx context.Context, id, update interface{}, isUpsert ...bool) error

func (*MongoDB[T]) UpdateMany

func (m *MongoDB[T]) UpdateMany(ctx context.Context, filter map[string]interface{}, update interface{}, isUpsert ...bool) error

func (*MongoDB[T]) UpdateOne

func (m *MongoDB[T]) UpdateOne(ctx context.Context, filter map[string]interface{}, update interface{}, isUpsert ...bool) error

type SysAdminDao

type SysAdminDao struct {
	*MongoDB[entity.SysAdmin]
}

func NewSysAdminDao

func NewSysAdminDao(database ...string) *SysAdminDao

func (*SysAdminDao) ChangePassword

func (d *SysAdminDao) ChangePassword(ctx context.Context, uid string, password string) error

type UserDao

type UserDao struct {
	*MongoDB[entity.User]
}

func NewUserDao

func NewUserDao(database ...string) *UserDao

func (*UserDao) ChangeAccountById

func (d *UserDao) ChangeAccountById(ctx context.Context, id, account string) error

func (*UserDao) ChangePasswordByUserId

func (d *UserDao) ChangePasswordByUserId(ctx context.Context, userId int, password string) error

func (*UserDao) CreateAccount

func (d *UserDao) CreateAccount(ctx context.Context, account *do.Account) (string, error)

func (*UserDao) FindAccount

func (d *UserDao) FindAccount(ctx context.Context, account string) (*entity.Account, error)

func (*UserDao) FindAccountByUserId

func (d *UserDao) FindAccountByUserId(ctx context.Context, userId int) (*entity.Account, error)

func (*UserDao) FindAccountsByUserId

func (d *UserDao) FindAccountsByUserId(ctx context.Context, userId int) ([]*entity.Account, error)

func (*UserDao) FindUserByAccount

func (d *UserDao) FindUserByAccount(ctx context.Context, account string) (*entity.User, error)

根据账号查询用户

func (*UserDao) FindUserByUserId

func (d *UserDao) FindUserByUserId(ctx context.Context, userId int) (*entity.User, error)

根据userId查询用户

func (*UserDao) FindUserListByUserIds

func (d *UserDao) FindUserListByUserIds(ctx context.Context, userIds []int) ([]*entity.User, error)

根据userIds查询用户列表

func (*UserDao) IsAccountExist

func (d *UserDao) IsAccountExist(ctx context.Context, account string) bool

判断账号是否存在

func (*UserDao) IsEmailExist

func (d *UserDao) IsEmailExist(ctx context.Context, email string) bool

判断邮箱是否存在

func (*UserDao) IsPhoneExist

func (d *UserDao) IsPhoneExist(ctx context.Context, phone string) bool

判断手机号是否存在

Jump to

Keyboard shortcuts

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