fdrepository

package
v0.0.0-...-3ce3758 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCountSQL

func BuildCountSQL(sql string) string

func GormDB

func GormDB() *gorm.DB

*

  • 获取gorm数据库引擎

func RegisterGormDB

func RegisterGormDB(dbConfig *DbConfig, isDebug bool)

*

  • 初始化数据库配置

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) RawQuery

func (d *BaseRepository) RawQuery(paging *fdmodel.Paging, buildSQL func() (sql string, conditions []interface{}), mappingRow func(rows *sql.Rows) error) 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 DaoEngine

type DaoEngine interface {
	ExecuteDaoStatement(d interface{}, inTransaction bool, fun func() error) 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

type GormExecutor interface {
	InjectGormDB(db *gorm.DB)
}

Jump to

Keyboard shortcuts

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