Documentation ¶
Index ¶
- type ArticleRepository
- func (a *ArticleRepository) AddArticle(article *models.Article) bool
- func (a *ArticleRepository) GetArticle(where interface{}) *models.Article
- func (a *ArticleRepository) GetArticles(PageNum int, PageSize int, total *uint64, where interface{}) []*models.Article
- func (a *ArticleRepository) GetTables(PageNum, PageSize int, where interface{}) []*models.Article
- type BaseRepository
- func (b *BaseRepository) Create(value interface{}) error
- func (b *BaseRepository) DeleteByID(model interface{}, id int) error
- func (b *BaseRepository) DeleteByIDS(model interface{}, ids []int) (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{}, selects ...string) error
- func (b *BaseRepository) FirstByID(out interface{}, id int) error
- func (b *BaseRepository) GetPages(model interface{}, out interface{}, pageIndex, pageSize int, ...) 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 IArticleRepository
- type IRoleRepository
- type IUserRepository
- type RoleRepository
- type UserRepository
- func (a *UserRepository) AddUser(user *models.User) bool
- func (a *UserRepository) CheckUser(where interface{}) bool
- func (a *UserRepository) DeleteUser(id int) bool
- func (a *UserRepository) ExistUserByName(where interface{}) bool
- func (a *UserRepository) GetUserAvatar(sel *string, where interface{}) *string
- func (a *UserRepository) GetUserByID(id int) *models.User
- func (a *UserRepository) GetUserID(sel *string, where interface{}) int
- func (a *UserRepository) GetUsers(PageNum int, PageSize int, total *uint64, where interface{}) []*models.User
- func (a *UserRepository) UpdateUser(user *models.User, role *models.Role) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArticleRepository ¶
type ArticleRepository struct { Log logger.ILogger `inject:""` Base BaseRepository `inject:"inline"` }
ArticleRepository 注入IDb
func (*ArticleRepository) AddArticle ¶
func (a *ArticleRepository) AddArticle(article *models.Article) bool
AddArticle 新增Article
func (*ArticleRepository) GetArticle ¶
func (a *ArticleRepository) GetArticle(where interface{}) *models.Article
GetArticle 根据id获取Article
func (*ArticleRepository) GetArticles ¶
func (a *ArticleRepository) GetArticles(PageNum int, PageSize int, total *uint64, where interface{}) []*models.Article
GetArticles 获取文章
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 int) error
DeleteByID 根据id删除实体
func (*BaseRepository) DeleteByIDS ¶
func (b *BaseRepository) DeleteByIDS(model interface{}, ids []int) (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{}, selects ...string) error
First 根据条件获取一个实体
func (*BaseRepository) FirstByID ¶
func (b *BaseRepository) FirstByID(out interface{}, id int) error
FirstByID 根据条件获取一个实体
func (*BaseRepository) GetPages ¶
func (b *BaseRepository) GetPages(model interface{}, out interface{}, pageIndex, pageSize int, totalCount *uint64, where interface{}, orders ...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 IArticleRepository ¶
type IArticleRepository interface { //GetTables 分页返回Articles GetTables(PageNum, PageSize int, where interface{}) []*models.Article //GetArticle 根据id获取Article GetArticle(where interface{}) *models.Article //AddArticle 新增Article AddArticle(article *models.Article) bool //GetArticles 获取文章 GetArticles(PageNum int, PageSize int, total *uint64, where interface{}) []*models.Article }
IArticleRepository Article接口定义
type IRoleRepository ¶
type IRoleRepository interface { //GetUserRoles 分页返回Articles获取用户身份信息 GetUserRoles(where interface{}) []*models.Role //GetRoles 获取用户角色 GetRoles(sel *string, where interface{}) []string //AddRole 添加用户角色 AddRole(role *models.Role) bool //GetRole 获取角色 GetRole(where interface{}) *models.Role }
IRoleRepository Role接口定义
type IUserRepository ¶
type IUserRepository interface { //CheckUser 身份验证 CheckUser(where interface{}) bool //GetUserAvatar 获取用户头像 GetUserAvatar(sel *string, where interface{}) *string //GetUserID 获取用户ID GetUserID(sel *string, where interface{}) int //GetUsers 获取用户信息 GetUsers(PageNum int, PageSize int, total *uint64, where interface{}) []*models.User //AddUser 新建用户 AddUser(user *models.User) bool //ExistUserByName 判断用户名是否已存在 ExistUserByName(where interface{}) bool //UpdateUser 更新用户 UpdateUser(user *models.User, role *models.Role) bool //DeleteUser 更新用户 DeleteUser(id int) bool //GetUserByID 获取用户 GetUserByID(id int) *models.User }
IUserRepository User接口定义
type RoleRepository ¶
type RoleRepository struct { Log logger.ILogger `inject:""` Base BaseRepository `inject:"inline"` }
RoleRepository 注入IDb
func (*RoleRepository) AddRole ¶
func (a *RoleRepository) AddRole(role *models.Role) bool
AddRole 添加用户角色
func (*RoleRepository) GetRole ¶
func (a *RoleRepository) GetRole(where interface{}) *models.Role
GetRole 获取角色
func (*RoleRepository) GetRoles ¶
func (a *RoleRepository) GetRoles(sel *string, where interface{}) []string
GetRoles 获取用户角色
func (*RoleRepository) GetUserRoles ¶
func (a *RoleRepository) GetUserRoles(where interface{}) []*models.Role
GetUserRoles 获取用户身份信息
type UserRepository ¶
type UserRepository struct { Log logger.ILogger `inject:""` Base BaseRepository `inject:"inline"` }
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 int) bool
DeleteUser 删除用户同时删除用户的角色
func (*UserRepository) ExistUserByName ¶
func (a *UserRepository) ExistUserByName(where interface{}) bool
ExistUserByName 判断用户名是否已存在
func (*UserRepository) GetUserAvatar ¶
func (a *UserRepository) GetUserAvatar(sel *string, where interface{}) *string
GetUserAvatar 获取用户头像
func (*UserRepository) GetUserByID ¶
func (a *UserRepository) GetUserByID(id int) *models.User
GetUserByID 获取用户
func (*UserRepository) GetUserID ¶
func (a *UserRepository) GetUserID(sel *string, where interface{}) int
GetUserID 获取用户ID
func (*UserRepository) GetUsers ¶
func (a *UserRepository) GetUsers(PageNum int, PageSize int, total *uint64, where interface{}) []*models.User
GetUsers 获取用户信息
func (*UserRepository) UpdateUser ¶
UpdateUser 更新用户