gorm_service

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormService

type GormService struct {
	Engine         *gorm.DB
	DataSourceName string
	LogWrite       io.Writer
	// contains filtered or unexported fields
}

func NewGormService

func NewGormService(userName string, password string, host string, port int,
	dbName string, logWriter io.Writer, logLevel uint8) *GormService

func (*GormService) DBClose

func (gs *GormService) DBClose()

func (*GormService) DBCreate

func (gs *GormService) DBCreate(value interface{}) error

DBCreate *****************************************************

  • @Description: 插入数据
  • @receiver self
  • @param value
  • @return error *****************************************************

func (*GormService) DBDelete

func (gs *GormService) DBDelete(value interface{}, conds ...interface{}) error

DBDelete *****************************************************

  • @Description: 删除数据
  • @receiver self
  • @param value
  • @param conds
  • @return error *****************************************************

func (*GormService) DBGet

func (gs *GormService) DBGet(dest interface{}, conds ...interface{}) error

DBGet *****************************************************

  • @Description: 根据主键检索 DBGet(&user, 10) // SELECT * FROM users WHERE id = 10; DBGet(&users, []int{1,2,3}) // SELECT * FROM users WHERE id IN (1,2,3);
  • @receiver self
  • @param dest
  • @param conds
  • @return error *****************************************************

func (*GormService) DBHas

func (gs *GormService) DBHas(dest interface{}, query interface{}, args ...interface{}) bool

DBHas *****************************************************

  • @Description: 是否存在符合条件的数据
  • @receiver self
  • @param dest
  • @param query
  • @param args
  • @return bool *****************************************************

func (*GormService) DBInit

func (gs *GormService) DBInit(entities ...interface{}) (err error)

func (*GormService) DBList

func (gs *GormService) DBList(dest interface{}, conds ...interface{}) error

DBList *****************************************************

  • @Description: 获取满足条件的列表
  • @receiver self
  • @param dest
  • @param conds
  • @return error *****************************************************

func (*GormService) DBListOrder

func (gs *GormService) DBListOrder(dest interface{}, order string, conds ...interface{}) error

DBListOrder *****************************************************

  • @Description: 获取满足条件的列表,并按排序条件排序
  • @receiver self
  • @param dest
  • @param order xxx desc, xxx
  • @param conds
  • @return error *****************************************************

func (*GormService) DBSave

func (gs *GormService) DBSave(value interface{}) error

DBSave *****************************************************

  • @Description: 根据主键更新所有数据,跳过零值判断,如果主键为空,执行插入
  • @receiver self
  • @param value
  • @return error *****************************************************

func (*GormService) SetLogLevel added in v0.0.11

func (gs *GormService) SetLogLevel(logLevel uint8)

SetLogLevel DBInit之前调用生效

Jump to

Keyboard shortcuts

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