entity

package
v0.0.0-...-418145e Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExportStatus_Error    = "error"
	ExportStatus_Running  = "running"
	ExportStatus_Finished = "finished"
)

Variables

View Source
var PaginationDefaultPage = 1
View Source
var PaginationDefaultSize = 10

Functions

func ApplyEntityOption

func ApplyEntityOption(e mongodbr.IEntity, opts ...mongodbr.EntityOption)

func EntityWithCreatorUserId

func EntityWithCreatorUserId(userId string) mongodbr.EntityOption

Types

type BatchRequestPayload

type BatchRequestPayload struct {
	Ids []primitive.ObjectID `form:"ids" json:"ids"`
}

type EntityExport

type EntityExport struct {
	ExportOptions

	Id           string     `json:"id"`
	Status       string     `json:"status"`
	StartTime    time.Time  `json:"startTime"`
	EndTime      *time.Time `json:"endTime"`
	FileName     string     `json:"fileName"`
	DownloadPath string     `json:"-"`
	Limit        int        `json:"-"`
}

type EntityExportService

type EntityExportService[T mongodbr.IEntity] struct {
	// contains filtered or unexported fields
}

func (*EntityExportService[T]) ExportToCSV

func (s *EntityExportService[T]) ExportToCSV(options ExportOptions) (exportId string, err error)

func (*EntityExportService[T]) GetExport

func (s *EntityExportService[T]) GetExport(exportId string) (*EntityExport, error)

func (*EntityExportService[T]) GetRepository

func (s *EntityExportService[T]) GetRepository() mongodbr.IRepository

type EntityService

type EntityService[T mongodbr.IEntity] struct {
	// contains filtered or unexported fields
}

func (*EntityService[T]) Count

func (s *EntityService[T]) Count(filter interface{}) (count int64, err error)

func (*EntityService[T]) Create

func (s *EntityService[T]) Create(item interface{}) (*T, error)

func (*EntityService[T]) Delete

func (s *EntityService[T]) Delete(id primitive.ObjectID) error

func (*EntityService[T]) DeleteMany

func (s *EntityService[T]) DeleteMany(filter interface{}) (*mongo.DeleteResult, error)

func (*EntityService[T]) DeleteManyByIdList

func (service *EntityService[T]) DeleteManyByIdList(idList []primitive.ObjectID) (*mongo.DeleteResult, error)

func (*EntityService[T]) FindAll

func (s *EntityService[T]) FindAll() (list []T, err error)

func (*EntityService[T]) FindById

func (s *EntityService[T]) FindById(id primitive.ObjectID) (*T, error)

func (*EntityService[T]) FindList

func (s *EntityService[T]) FindList(filter interface{}, opts ...mongodbr.FindOption) (list []T, err error)

func (*EntityService[T]) FindOne

func (s *EntityService[T]) FindOne(filter interface{}) (*T, error)

func (*EntityService[T]) GetRepository

func (s *EntityService[T]) GetRepository() mongodbr.IRepository

func (*EntityService[T]) UpdateFields

func (s *EntityService[T]) UpdateFields(id primitive.ObjectID, update map[string]interface{}) error

update fields value

type EntityWithTenant

type EntityWithTenant struct {
	TenantId string `json:"tenantId" bson:"tenantId"`
}

func (*EntityWithTenant) GetTenantId

func (p *EntityWithTenant) GetTenantId() string

func (*EntityWithTenant) SetTenantId

func (t *EntityWithTenant) SetTenantId(tenantId string)

type EntityWithUser

type EntityWithUser struct {
	mongodbr.AuditedEntity `bson:",inline"`
}

func (*EntityWithUser) GetCreatorId

func (p *EntityWithUser) GetCreatorId() string

func (*EntityWithUser) SetUserCreator

func (p *EntityWithUser) SetUserCreator(userId string)

type ExportOptions

type ExportOptions struct {
	Type   string      `json:"type"`
	Target string      `json:"target"`
	Filter interface{} `json:"filter"`
	Async  bool        `json:"async"`

	GetFieldNameFunc  func(entity interface{}, name string) string `json:"-"`
	Skip              int                                          `json:"skip"`
	FieldNameList     []string                                     `json:"fieldNameList"`
	FieldNameTitleMap map[string]string                            `json:"fieldNameTitleMap"`
}

type IEntityExportService

type IEntityExportService[TEntity mongodbr.IEntity] interface {
	GetRepository() mongodbr.IRepository

	ExportToCSV(options ExportOptions) (exportId string, err error)
	GetExport(exportId string) (*EntityExport, error)
}

func NewEntityExportService

func NewEntityExportService[T mongodbr.IEntity](repository mongodbr.IRepository) IEntityExportService[T]

type IEntityService

type IEntityService[T mongodbr.IEntity] interface {
	GetRepository() mongodbr.IRepository

	FindAll() ([]T, error)
	FindList(filter interface{}, opts ...mongodbr.FindOption) (list []T, err error)
	Count(filter interface{}) (count int64, err error)
	FindById(id primitive.ObjectID) (*T, error)
	FindOne(filter interface{}) (*T, error)

	Create(interface{}) (*T, error)
	Delete(primitive.ObjectID) error
	DeleteMany(interface{}) (*mongo.DeleteResult, error)
	DeleteManyByIdList(idList []primitive.ObjectID) (*mongo.DeleteResult, error)
	UpdateFields(id primitive.ObjectID, update map[string]interface{}) error
}

func NewEntityService

func NewEntityService[T mongodbr.IEntity](repository mongodbr.IRepository) IEntityService[T]

type IEntityWithTenant

type IEntityWithTenant interface {
	SetTenantId(tenantId string)
	GetTenantId() string
}

func CheckEntityIsIEntityWithTenant

func CheckEntityIsIEntityWithTenant(entityValue interface{}) IEntityWithTenant

type IEntityWithUser

type IEntityWithUser interface {
	SetUserCreator(userId string)
	GetCreatorId() string
}

func CheckEntityIsIEntityWithUser

func CheckEntityIsIEntityWithUser(entityValue interface{}) IEntityWithUser

type Pagination

type Pagination struct {
	Page int `form:"page" url:"page"`
	Size int `form:"size" url:"size"`
}

func (*Pagination) IsDefault

func (p *Pagination) IsDefault() (ok bool)

func (*Pagination) IsZero

func (p *Pagination) IsZero() (ok bool)

type Sort

type Sort struct {
	Key       string `json:"key"`
	Direction string `json:"d"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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