Documentation
¶
Index ¶
- type CreateObjectSpec
- type FilterOptions
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, object Object) (int64, error)
- func (repo MySQLRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (*Object, error)
- func (repo MySQLRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*Object, error)
- func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Object, error)
- type Object
- 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) GetRoutes() []service.Route
- func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]ObjectSpec, error)
- type ObjectSpec
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) ([]Object, error)
type Object ¶
type Object struct {
ID int64 `db:"id"`
ObjectType string `db:"objectType"`
ObjectId string `db:"objectId"`
CreatedAt time.Time `db:"createdAt"`
UpdatedAt time.Time `db:"updatedAt"`
DeletedAt database.NullTime `db:"deletedAt"`
}
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 Object) (int64, error)
GetById(ctx context.Context, id int64) (*Object, error)
GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*Object, error)
List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Object, 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
}
func NewService ¶
func NewService(env service.Env) 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) GetRoutes ¶
func (svc ObjectService) GetRoutes() []service.Route
func (ObjectService) List ¶
func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]ObjectSpec, error)
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
Click to show internal directories.
Click to hide internal directories.