Documentation ¶
Index ¶
- func BuildCountSQL(sql string) string
- func GormDB() *gorm.DB
- func RegisterGormDB(dbConfig *DbConfig, isDebug bool)
- type BaseRepository
- func (d *BaseRepository) Delete(result fdentity.IdInterface) error
- func (d *BaseRepository) DeleteAll(result fdentity.IdInterface, ids []string) error
- func (d *BaseRepository) Engine() *gorm.DB
- func (d *BaseRepository) GetOne(result fdentity.IdInterface) error
- func (d *BaseRepository) InjectGormDB(db *gorm.DB)
- func (d *BaseRepository) QueryWithPaging(model interface{}, out interface{}, paging *fdmodel.Paging, ...) error
- func (d *BaseRepository) RawQuery(paging *fdmodel.Paging, buildSQL func() (sql string, conditions []interface{}), ...) error
- func (d *BaseRepository) Save(result fdentity.IdInterface) error
- func (d *BaseRepository) Update(result fdentity.IdInterface, m map[string]interface{}) error
- type DaoEngine
- type DbConfig
- type GormDaoEngine
- type GormExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCountSQL ¶
Types ¶
type BaseRepository ¶
type BaseRepository struct {
// contains filtered or unexported fields
}
*
- 数据库操作基础类(注意db是否为空,service层会自动调用InjectGormDB注入db)
func GetBaseRepository ¶
func GetBaseRepository() *BaseRepository
func (*BaseRepository) Delete ¶
func (d *BaseRepository) Delete(result fdentity.IdInterface) error
*
- 删除对象
func (*BaseRepository) DeleteAll ¶
func (d *BaseRepository) DeleteAll(result fdentity.IdInterface, ids []string) error
*
- 删除对象
func (*BaseRepository) Engine ¶
func (d *BaseRepository) Engine() *gorm.DB
func (*BaseRepository) GetOne ¶
func (d *BaseRepository) GetOne(result fdentity.IdInterface) error
*
- 根据ID获取数据
func (*BaseRepository) InjectGormDB ¶
func (d *BaseRepository) InjectGormDB(db *gorm.DB)
func (*BaseRepository) QueryWithPaging ¶
func (d *BaseRepository) QueryWithPaging(model interface{}, out interface{}, paging *fdmodel.Paging, interceptor func(db *gorm.DB) *gorm.DB) error
*
- 查询分页列表
func (*BaseRepository) Save ¶
func (d *BaseRepository) Save(result fdentity.IdInterface) error
*
- 保存对象到数据库
func (*BaseRepository) Update ¶
func (d *BaseRepository) Update(result fdentity.IdInterface, m map[string]interface{}) error
*
- 修改对象
type DbConfig ¶
type DbConfig struct { Host string `yaml:"host"` Port string `yaml:"port"` User string `yaml:"user"` Pass string `yaml:"pass"` Name string `yaml:"name"` Type string `yaml:"type"` MaxOpenConnections int `yaml:"max_open_conns"` MaxIdleConnections int `yaml:"max_idle_conns"` }
*
- 数据库配置
type GormDaoEngine ¶
type GormDaoEngine struct { }
func (*GormDaoEngine) ExecuteDaoStatement ¶
func (e *GormDaoEngine) ExecuteDaoStatement(target interface{}, inTransaction bool, fun func() error) error
*
- 数据库操作方法(target为dao层)
type GormExecutor ¶
Click to show internal directories.
Click to hide internal directories.