service

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: AGPL-3.0 Imports: 18 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSeq

func GetSeq(name string, count int) []uint64

func GetSeqValue

func GetSeqValue(name string) uint64

func GetSession

func GetSession() repository.DbSession

func PlaceQuestionMark

func PlaceQuestionMark(n int) string

func RegistSeq

func RegistSeq(name string, increment uint64)

Types

type BaseService

type BaseService interface {
	GetSeq() uint64
	GetSeqs(count int) []uint64
	NewEntity(data []byte) (interface{}, error)
	//返回数组的指针
	NewEntities(data []byte) (interface{}, error)
	ParseJSON(data []byte) ([]interface{}, error)
	Get(dest interface{}, locked bool, orderby string, conds string, params ...interface{}) bool
	Find(rowsSlicePtr interface{}, md interface{}, orderby string, from int, limit int, conds string, params ...interface{}) error
	Insert(mds ...interface{}) int64
	Update(md interface{}, columns []string, conds string, params ...interface{}) int64
	Upsert(mds ...interface{}) int64
	Delete(md interface{}, conds string, params ...interface{}) int64
	Save(mds ...interface{}) int64
	Exec(clause string, params ...interface{}) sql.Result
	Query(clause string, params ...interface{}) []map[string][]byte
	Count(bean interface{}, conds string, params ...interface{}) int64
	Transaction(fc func(s repository.DbSession) (interface{}, error)) (interface{}, error)
}

func GetOrmBaseService

func GetOrmBaseService() BaseService

type OrmBaseService

type OrmBaseService struct {
	GetSeqName      func() string
	FactNewEntity   func(data []byte) (interface{}, error)
	FactNewEntities func(data []byte) (interface{}, error)
}

func (*OrmBaseService) Count

func (this *OrmBaseService) Count(bean interface{}, conds string, params ...interface{}) int64

func (*OrmBaseService) Delete

func (this *OrmBaseService) Delete(md interface{}, conds string, params ...interface{}) int64

delete model in database Delete records, bean's non-empty fields are conditions

func (*OrmBaseService) Exec

func (this *OrmBaseService) Exec(clause string, params ...interface{}) sql.Result

execute sql and get result

func (*OrmBaseService) Export

func (this *OrmBaseService) Export(condiBean interface{}) ([]byte, error)

func (*OrmBaseService) Find

func (this *OrmBaseService) Find(rowsSlicePtr interface{}, condiBean interface{}, orderby string, from int, limit int, conds string, params ...interface{}) error

Find retrieve records from table, condiBeans's non-empty fields are conditions. beans could be []Struct, []*Struct, map[int64]Struct map[int64]*Struct everyone := make([]Userinfo, 0) err := engine.Find(&everyone)

func (*OrmBaseService) Get

func (this *OrmBaseService) Get(dest interface{}, locked bool, orderby string, conds string, params ...interface{}) bool

Get retrieve one record from database, bean's non-empty fields will be as conditions

func (*OrmBaseService) GetSeq

func (this *OrmBaseService) GetSeq() uint64

func (*OrmBaseService) GetSeqs

func (this *OrmBaseService) GetSeqs(count int) []uint64

func (*OrmBaseService) Import

func (this *OrmBaseService) Import(filenames []string) error

* 导入excel格式的数据

func (*OrmBaseService) Insert

func (this *OrmBaseService) Insert(mds ...interface{}) int64

insert model data to database

func (*OrmBaseService) NewEntities

func (this *OrmBaseService) NewEntities(data []byte) (interface{}, error)

func (*OrmBaseService) NewEntity

func (this *OrmBaseService) NewEntity(data []byte) (interface{}, error)

func (*OrmBaseService) ParseJSON

func (this *OrmBaseService) ParseJSON(data []byte) ([]interface{}, error)

func (*OrmBaseService) Query

func (this *OrmBaseService) Query(clause string, params ...interface{}) []map[string][]byte

execute sql and get result

func (*OrmBaseService) Save

func (this *OrmBaseService) Save(mds ...interface{}) int64

save model data to database by state field

func (*OrmBaseService) Transaction

func (this *OrmBaseService) Transaction(fc func(s repository.DbSession) (interface{}, error)) (interface{}, error)

*

	Transaction 的 f 参数类型为 一个在事务内处理的函数
    因此可以将 f 函数作为参数传入 Transaction 函数中。
    return Transaction(func(s *BaseService) error {
        if _,error := session.Insert(User{ID:5,Version:"abc"}); error != nil{
            return error
        }
	})

func (*OrmBaseService) Update

func (this *OrmBaseService) Update(md interface{}, columns []string, conds string, params ...interface{}) int64

update model to database. cols set the columns those want to update.

func (*OrmBaseService) Upsert

func (this *OrmBaseService) Upsert(mds ...interface{}) int64

Upsert model data to database by id field

type SeqCache

type SeqCache struct {
	// contains filtered or unexported fields
}

type SequenceService

type SequenceService struct {
	OrmBaseService
}

func GetSequenceService

func GetSequenceService() *SequenceService

func (*SequenceService) CreateSeq

func (this *SequenceService) CreateSeq(name string, increment uint64, minValue uint64) int64

func (*SequenceService) GetSeqName

func (this *SequenceService) GetSeqName() string

func (*SequenceService) GetSeqValue

func (this *SequenceService) GetSeqValue(name string) uint64

func (*SequenceService) NewEntities

func (this *SequenceService) NewEntities(data []byte) (interface{}, error)

func (*SequenceService) NewEntity

func (this *SequenceService) NewEntity(data []byte) (interface{}, error)

type SessionDataService

type SessionDataService struct {
	OrmBaseService
}

func GetSessionDataService

func GetSessionDataService() *SessionDataService

func (*SessionDataService) GetSeqName

func (this *SessionDataService) GetSeqName() string

type SessionService

type SessionService struct {
	OrmBaseService
}

func GetSessionService

func GetSessionService() *SessionService

func (*SessionService) GetSeqName

func (this *SessionService) GetSeqName() string

func (*SessionService) NewEntities

func (this *SessionService) NewEntities(data []byte) (interface{}, error)

func (*SessionService) NewEntity

func (this *SessionService) NewEntity(data []byte) (interface{}, error)

Jump to

Keyboard shortcuts

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