Documentation
¶
Index ¶
- type DefaultModel
- type GraphQLField
- type Model
- func (m *Model) Begin()
- func (m *Model) Commit() (err error)
- func (m *Model) Count(model interface{}) (total int64, err error)
- func (m *Model) Create(value interface{}) (err error)
- func (m *Model) Delete(value interface{}, ids []int64) (err error)
- func (m *Model) Find(dest interface{}) error
- func (m *Model) First(dest interface{}) error
- func (m *Model) FuzzyQuery(keyword string, field string) Repository
- func (m *Model) GetDB() *gorm.DB
- func (m *Model) IDArrayQuery(ids interface{}, idFieldName ...string) Repository
- func (m *Model) IDQuery(id interface{}, idFieldName ...string) Repository
- func (m *Model) LeftJoin(query string, args ...interface{}) Repository
- func (m *Model) Order(value interface{}) Repository
- func (m *Model) Pagination(offset, limit int) Repository
- func (m *Model) Preload(query string, args ...interface{}) Repository
- func (m *Model) Raw(sql string, result interface{}, value ...interface{}) (err error)
- func (m *Model) ReSetDB()
- func (m *Model) Rollback()
- func (m *Model) Save(value interface{}) (err error)
- func (m *Model) Select(fields []string, omitFields ...string) Repository
- func (m *Model) SelectWithPrefix(fields []string, prefix string, omitFields ...string) Repository
- func (m *Model) SetDB(db *gorm.DB)
- func (m *Model) Sort(sorts []*Sort) Repository
- func (m *Model) Table(name string, args ...interface{}) Repository
- func (m *Model) Take(dest interface{}) error
- func (m *Model) Unscoped() Repository
- func (m *Model) Updates(value interface{}) (err error)
- func (m *Model) Where(query interface{}, args ...interface{}) Repository
- type Repository
- type Search
- type Service
- func (s Service) GetByID(r Repository, id uint, columns []string) error
- func (s Service) GetConnection(r Repository, searchParam *SearchParam, data interface{}, ...) (total int64, err error)
- func (s Service) GetInputFields(ctx context.Context) []string
- func (s Service) GetPageInfo(searchParam *SearchParam) (int, int)
- func (s Service) GetValidIDs(r Repository, tableName string, ids []uint) []uint
- func (s Service) OldGetConnection(ctx context.Context, r Repository, searchParam *SearchParam, data interface{}, ...) (total int64, err error)deprecated
- func (s Service) RecordNotExist(r Repository, id interface{}, uid ...uint) bool
- func (s Service) ToInt64(ids []uint) []int64
- func (s Service) ToUintIDs(ids []int64) []uint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultModel ¶
type DefaultModel struct {
Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt sql.NullTime `gorm:"index"`
}
DefaultModel ..
type GraphQLField ¶
GraphQLField ..
func ForGraphQLField ¶
func ForGraphQLField(queryFields []string, prefix string) GraphQLField
ForGraphQLField get fields from queryFields
func NewGraphQLField ¶
func NewGraphQLField(ctx context.Context, prefix string) GraphQLField
NewGraphQLField get graphql field from context
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model ..
func (*Model) FuzzyQuery ¶
func (m *Model) FuzzyQuery(keyword string, field string) Repository
FuzzyQuery 增加模糊查询
func (*Model) IDArrayQuery ¶
func (m *Model) IDArrayQuery(ids interface{}, idFieldName ...string) Repository
IDArrayQuery ids查询
func (*Model) IDQuery ¶
func (m *Model) IDQuery(id interface{}, idFieldName ...string) Repository
IDQuery id查询
func (*Model) LeftJoin ¶
func (m *Model) LeftJoin(query string, args ...interface{}) Repository
LeftJoin 左连接
func (*Model) Preload ¶
func (m *Model) Preload(query string, args ...interface{}) Repository
Preload 预加载
func (*Model) Select ¶
func (m *Model) Select(fields []string, omitFields ...string) Repository
Select 选择字段
func (*Model) SelectWithPrefix ¶
func (m *Model) SelectWithPrefix(fields []string, prefix string, omitFields ...string) Repository
SelectWithPrefix 选择字段带上特定前缀
func (*Model) Where ¶
func (m *Model) Where(query interface{}, args ...interface{}) Repository
Where where查询
type Repository ¶
type Repository interface {
SetDB(db *gorm.DB)
ReSetDB()
GetDB() *gorm.DB
Table(name string, args ...interface{}) Repository
SelectWithPrefix(fields []string, prefix string, omitFields ...string) Repository
Select(fields []string, omitFields ...string) Repository
LeftJoin(query string, args ...interface{}) Repository
FuzzyQuery(keyword string, field string) Repository
IDQuery(id interface{}, idFieldName ...string) Repository
IDArrayQuery(ids interface{}, idFieldName ...string) Repository
Where(query interface{}, args ...interface{}) Repository
Pagination(offset, limit int) Repository
Sort(sorts []*Sort) Repository
Order(value interface{}) Repository
Preload(query string, args ...interface{}) Repository
First(dest interface{}) error
Take(dest interface{}) error
Find(dest interface{}) error
Count(model interface{}) (total int64, err error)
Create(value interface{}) error
Updates(value interface{}) error
Delete(value interface{}, ids []int64) error
Begin()
Rollback()
Commit() error
}
Repository 。。
type Search ¶
type Search struct {
Ctx context.Context
SearchParam *SearchParam
Scheme string
SearchService *elastic.SearchService
BoolQuery *elastic.BoolQuery
FilterQueries []elastic.Query
IgnoreQueries []elastic.Query
}
Search ..
func (*Search) GetAggResults ¶
func (s *Search) GetAggResults(aggsParams []*es.AggsParam, result *elastic.SearchResult) []*model.AggResult
GetAggResults ..
type Service ¶
type Service struct {
}
Service base service
func (Service) GetByID ¶
func (s Service) GetByID(r Repository, id uint, columns []string) error
GetByID Get model by id
func (Service) GetConnection ¶
func (s Service) GetConnection(r Repository, searchParam *SearchParam, data interface{}, replaceFunc func(field GraphQLField) error, omitFields ...string) (total int64, err error)
GetConnection get list data and total count
func (Service) GetInputFields ¶
GetInputFields from context
func (Service) GetPageInfo ¶
GetPageInfo ...
func (Service) GetValidIDs ¶
func (s Service) GetValidIDs(r Repository, tableName string, ids []uint) []uint
GetValidIDs ..
func (Service) OldGetConnection
deprecated
func (s Service) OldGetConnection(ctx context.Context, r Repository, searchParam *SearchParam, data interface{}, replaceFunc func(field GraphQLField) error, omitFields ...string) (total int64, err error)
Deprecated: query params should get from searchParam not context
func (Service) RecordNotExist ¶
func (s Service) RecordNotExist(r Repository, id interface{}, uid ...uint) bool
RecordNotExist ..
Click to show internal directories.
Click to hide internal directories.