Documentation
¶
Index ¶
- type CreateObjectSpec
- type FilterOptions
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
- type Object
- func (object Object) GetCreatedAt() time.Time
- func (object Object) GetDeletedAt() database.NullTime
- func (object Object) GetID() int64
- func (object Object) GetObjectId() string
- func (object Object) GetObjectType() string
- func (object Object) GetUpdatedAt() time.Time
- func (object Object) ToObjectSpec() *ObjectSpec
- type ObjectListParamParser
- type ObjectRepository
- type ObjectService
- func (svc ObjectService) Create(ctx context.Context, objectSpec ObjectSpec) (*ObjectSpec, error)
- func (svc ObjectService) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (svc ObjectService) GetByObjectId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)
- func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]ObjectSpec, error)
- func (svc ObjectService) Routes() []service.Route
- type ObjectSpec
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateObjectSpec ¶
type FilterOptions ¶
type FilterOptions struct {
ObjectType string
}
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteByObjectTypeAndId ¶
func (MySQLRepository) GetByObjectTypeAndId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Model, error)
type Object ¶
type Object struct {
ID int64 `mysql:"id" postgres:"id"`
ObjectType string `mysql:"objectType" postgres:"object_type"`
ObjectId string `mysql:"objectId" postgres:"object_id"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at"`
UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at"`
DeletedAt database.NullTime `mysql:"deletedAt" postgres:"deleted_at"`
}
func (Object) GetCreatedAt ¶ added in v0.8.0
func (Object) GetDeletedAt ¶ added in v0.8.0
func (Object) GetObjectId ¶ added in v0.8.0
func (Object) GetObjectType ¶ added in v0.8.0
func (Object) GetUpdatedAt ¶ added in v0.8.0
func (Object) ToObjectSpec ¶
func (object Object) ToObjectSpec() *ObjectSpec
type ObjectListParamParser ¶
type ObjectListParamParser struct{}
func (ObjectListParamParser) GetDefaultSortBy ¶
func (parser ObjectListParamParser) GetDefaultSortBy() string
func (ObjectListParamParser) GetSupportedSortBys ¶
func (parser ObjectListParamParser) GetSupportedSortBys() []string
func (ObjectListParamParser) ParseValue ¶
func (parser ObjectListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type ObjectRepository ¶
type ObjectRepository interface {
Create(ctx context.Context, object Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Model, error)
DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (ObjectRepository, error)
type ObjectService ¶
type ObjectService struct {
service.BaseService
// contains filtered or unexported fields
}
func NewService ¶
func NewService(env service.Env, repo ObjectRepository, eventSvc event.EventService, warrantSvc warrant.WarrantService) ObjectService
func (ObjectService) Create ¶
func (svc ObjectService) Create(ctx context.Context, objectSpec ObjectSpec) (*ObjectSpec, error)
func (ObjectService) DeleteByObjectTypeAndId ¶
func (ObjectService) GetByObjectId ¶
func (svc ObjectService) GetByObjectId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)
func (ObjectService) List ¶
func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]ObjectSpec, error)
func (ObjectService) Routes ¶ added in v0.8.0
func (svc ObjectService) Routes() []service.Route
type ObjectSpec ¶
type ObjectSpec struct {
// NOTE: ID is required here for internal use.
// However, we don't return it to the client.
ID int64 `json:"-"`
ObjectType string `json:"objectType" validate:"required,valid_object_type"`
ObjectId string `json:"objectId" validate:"required,valid_object_id"`
CreatedAt time.Time `json:"createdAt"`
}
func (ObjectSpec) ToObject ¶
func (spec ObjectSpec) ToObject() *Object
type PostgresRepository ¶ added in v0.4.0
type PostgresRepository struct {
database.SQLRepository
}
func NewPostgresRepository ¶ added in v0.4.0
func NewPostgresRepository(db *database.Postgres) PostgresRepository
func (PostgresRepository) DeleteByObjectTypeAndId ¶ added in v0.4.0
func (PostgresRepository) GetByObjectTypeAndId ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Model, error)
Click to show internal directories.
Click to hide internal directories.