Documentation ¶
Index ¶
- type BaseRepository
- func (b *BaseRepository) Create(value interface{}) error
- func (b *BaseRepository) DeleteByID(model interface{}, id uint) error
- func (b *BaseRepository) DeleteByIDS(model interface{}, ids []uint) (count int64, err error)
- func (b *BaseRepository) DeleteByWhere(model, where interface{}) (count int64, err error)
- func (b *BaseRepository) Find(where interface{}, out interface{}, sel string, orders ...string) error
- func (b *BaseRepository) First(where interface{}, out interface{}, other map[string]string) error
- func (b *BaseRepository) FirstByID(out interface{}, id uint) error
- func (b *BaseRepository) GetPages(model interface{}, out interface{}, pageIndex, pageSize uint, ...) error
- func (b *BaseRepository) GetTransaction() *gorm.DB
- func (b *BaseRepository) PluckList(model, where interface{}, out interface{}, fieldName string) error
- func (b *BaseRepository) Save(value interface{}) error
- type IUserRepository
- type UserRepository
- func (a *UserRepository) AddUser(user *models.User) bool
- func (a *UserRepository) CheckUser(where interface{}) bool
- func (a *UserRepository) DeleteUser(id uint) bool
- func (a *UserRepository) ExistUserByName(where interface{}) bool
- func (a *UserRepository) GetUserByID(id uint) *models.User
- func (a *UserRepository) GetUserID(sel *string, where interface{}) uint
- func (a *UserRepository) GetUserType(sel *string, where interface{}) uint
- func (a *UserRepository) GetUsers(PageNum uint, PageSize uint, total *uint64, where interface{}) *[]models.User
- func (a *UserRepository) UpdateUser(user *models.User, userOpType string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRepository ¶
type BaseRepository struct { Source datasource.IDb `inject:""` Log logger.ILogger `inject:""` }
BaseRepository 注入IDb,Logger
func (*BaseRepository) Create ¶
func (b *BaseRepository) Create(value interface{}) error
Create 创建实体
func (*BaseRepository) DeleteByID ¶
func (b *BaseRepository) DeleteByID(model interface{}, id uint) error
DeleteByID 根据id删除实体
func (*BaseRepository) DeleteByIDS ¶
func (b *BaseRepository) DeleteByIDS(model interface{}, ids []uint) (count int64, err error)
DeleteByIDS 根据多个id删除多个实体
func (*BaseRepository) DeleteByWhere ¶
func (b *BaseRepository) DeleteByWhere(model, where interface{}) (count int64, err error)
DeleteByWhere 根据条件删除实体
func (*BaseRepository) Find ¶
func (b *BaseRepository) Find(where interface{}, out interface{}, sel string, orders ...string) error
Find 根据条件返回数据
func (*BaseRepository) First ¶
func (b *BaseRepository) First(where interface{}, out interface{}, other map[string]string) error
First 根据条件获取一个实体
func (*BaseRepository) FirstByID ¶
func (b *BaseRepository) FirstByID(out interface{}, id uint) error
FirstByID 根据条件获取一个实体
func (*BaseRepository) GetPages ¶
func (b *BaseRepository) GetPages(model interface{}, out interface{}, pageIndex, pageSize uint, totalCount *uint64, where interface{}, other map[string]string) error
GetPages 分页返回数据
func (*BaseRepository) GetTransaction ¶
func (b *BaseRepository) GetTransaction() *gorm.DB
GetTransaction 获取事务
func (*BaseRepository) PluckList ¶
func (b *BaseRepository) PluckList(model, where interface{}, out interface{}, fieldName string) error
PluckList 查询 model 中的一个列作为切片
type IUserRepository ¶
type IUserRepository interface { //CheckUser 身份验证 CheckUser(where interface{}) bool //GetUserID 获取用户ID GetUserID(sel *string, where interface{}) uint //GetUserType 获取用户Type GetUserType(sel *string, where interface{}) uint //GetUsers 获取用户信息 GetUsers(PageNum uint, PageSize uint, total *uint64, where interface{}) *[]models.User //AddUser 新建用户 AddUser(user *models.User) bool //ExistUserByName 判断用户名是否已存在 ExistUserByName(where interface{}) bool //UpdateUser 更新用户 UpdateUser(user *models.User, userOpType string) bool //DeleteUser 更新用户 DeleteUser(id uint) bool //GetUserByID 获取用户 GetUserByID(id uint) *models.User }
IUserRepository User接口定义
type UserRepository ¶
type UserRepository struct { Log logger.ILogger `inject:""` Base BaseRepository `inject:"inline"` Source datasource.IDb `inject:""` }
UserRepository 注入IDb
func (*UserRepository) AddUser ¶
func (a *UserRepository) AddUser(user *models.User) bool
AddUser 新建用户
func (*UserRepository) CheckUser ¶
func (a *UserRepository) CheckUser(where interface{}) bool
CheckUser 身份验证
func (*UserRepository) DeleteUser ¶
func (a *UserRepository) DeleteUser(id uint) bool
DeleteUser 删除用户同时删除用户的角色
func (*UserRepository) ExistUserByName ¶
func (a *UserRepository) ExistUserByName(where interface{}) bool
ExistUserByName 判断用户名是否已存在
func (*UserRepository) GetUserByID ¶
func (a *UserRepository) GetUserByID(id uint) *models.User
GetUserByID 获取用户
func (*UserRepository) GetUserID ¶
func (a *UserRepository) GetUserID(sel *string, where interface{}) uint
GetUserID 获取用户ID
func (*UserRepository) GetUserType ¶
func (a *UserRepository) GetUserType(sel *string, where interface{}) uint
GetUserType 获取用户Type
func (*UserRepository) GetUsers ¶
func (a *UserRepository) GetUsers(PageNum uint, PageSize uint, total *uint64, where interface{}) *[]models.User
GetUsers 获取用户信息
func (*UserRepository) UpdateUser ¶
func (a *UserRepository) UpdateUser(user *models.User, userOpType string) bool
UpdateUser 更新用户
Click to show internal directories.
Click to hide internal directories.