Documentation ¶
Index ¶
- func ParseTagValue(templateURN string, fieldID uint, dataType, tagValue string, options []string) (interface{}, error)
- type DuplicateError
- type DuplicateTemplateError
- type Field
- type NotFoundError
- type Service
- func (s *Service) CreateTag(ctx context.Context, tag *Tag) error
- func (s *Service) DeleteTag(ctx context.Context, assetID, templateURN string) error
- func (s *Service) FindTagByAssetIDAndTemplateURN(ctx context.Context, assetID, templateURN string) (Tag, error)
- func (s *Service) GetTagsByAssetID(ctx context.Context, assetID string) ([]Tag, error)
- func (s *Service) UpdateTag(ctx context.Context, tag *Tag) error
- func (s *Service) Validate(tag *Tag) error
- type Tag
- type TagRepository
- type TagTemplateRepository
- type TagValue
- type Template
- type TemplateNotFoundError
- type TemplateService
- func (s *TemplateService) CreateTemplate(ctx context.Context, template *Template) error
- func (s *TemplateService) DeleteTemplate(ctx context.Context, urn string) error
- func (s *TemplateService) GetTemplate(ctx context.Context, urn string) (Template, error)
- func (s *TemplateService) GetTemplates(ctx context.Context, templateURN string) ([]Template, error)
- func (s *TemplateService) UpdateTemplate(ctx context.Context, templateURN string, template *Template) error
- func (s *TemplateService) Validate(template Template) error
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DuplicateError ¶
func (DuplicateError) Error ¶
func (e DuplicateError) Error() string
type DuplicateTemplateError ¶
type DuplicateTemplateError struct {
URN string
}
func (DuplicateTemplateError) Error ¶
func (e DuplicateTemplateError) Error() string
type Field ¶
type Field struct { ID uint `json:"id"` URN string `json:"urn" validate:"required"` DisplayName string `json:"display_name" validate:"required"` Description string `json:"description" validate:"required"` DataType string `json:"data_type" validate:"oneof=string double boolean enumerated datetime"` Options []string `json:"options"` Required bool `json:"required"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Field is a field for a single template
type NotFoundError ¶
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a type that manages business process
func NewService ¶
func NewService(repository TagRepository, templateService *TemplateService) *Service
NewService initializes service tag
func (*Service) FindTagByAssetIDAndTemplateURN ¶
func (s *Service) FindTagByAssetIDAndTemplateURN(ctx context.Context, assetID, templateURN string) (Tag, error)
FindByAssetAndTemplate handles business process to get tags by its asset id and template id
func (*Service) GetTagsByAssetID ¶
GetTagsByAssetID handles business process to get tags by its asset id
type Tag ¶
type Tag struct { AssetID string `json:"asset_id" validate:"required"` TemplateURN string `json:"template_urn" validate:"required"` TagValues []TagValue `json:"tag_values" validate:"required,min=1,dive"` TemplateDisplayName string `json:"template_display_name"` TemplateDescription string `json:"template_description"` }
Tag is the tag to be managed
type TagRepository ¶
type TagRepository interface { Create(ctx context.Context, tag *Tag) error Read(ctx context.Context, filter Tag) ([]Tag, error) Update(ctx context.Context, tag *Tag) error Delete(ctx context.Context, filter Tag) error }
TagRepository is a contract to communicate with the primary store
type TagTemplateRepository ¶
type TagTemplateRepository interface { Create(ctx context.Context, template *Template) error Read(ctx context.Context, templateURN string) ([]Template, error) ReadAll(ctx context.Context) ([]Template, error) Update(ctx context.Context, templateURN string, template *Template) error Delete(ctx context.Context, templateURN string) error }
TagTemplateRepository is a contract to communicate with the primary store
type TagValue ¶
type TagValue struct { FieldID uint `json:"field_id" validate:"required"` FieldValue interface{} `json:"field_value" validate:"required"` FieldURN string `json:"field_urn"` FieldDisplayName string `json:"field_display_name"` FieldDescription string `json:"field_description"` FieldDataType string `json:"field_data_type"` FieldOptions []string `json:"field_options"` FieldRequired bool `json:"field_required"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
TagValue is one of the value for a tag
type Template ¶
type Template struct { URN string `json:"urn" validate:"required"` DisplayName string `json:"display_name" validate:"required"` Description string `json:"description" validate:"required"` Fields []Field `json:"fields" validate:"required,min=1,dive"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Template is a template of a tag for a resource
type TemplateNotFoundError ¶
type TemplateNotFoundError struct {
URN string
}
func (TemplateNotFoundError) Error ¶
func (e TemplateNotFoundError) Error() string
type TemplateService ¶
type TemplateService struct {
// contains filtered or unexported fields
}
Service is a type of service that manages business process
func NewTemplateService ¶
func NewTemplateService(r TagTemplateRepository) *TemplateService
NewTemplateService initializes service template service
func (*TemplateService) CreateTemplate ¶
func (s *TemplateService) CreateTemplate(ctx context.Context, template *Template) error
Create handles create business operation for template
func (*TemplateService) DeleteTemplate ¶
func (s *TemplateService) DeleteTemplate(ctx context.Context, urn string) error
DeleteTemplate handles request to delete template by urn
func (*TemplateService) GetTemplate ¶
GetTemplate handles request to get template by urn
func (*TemplateService) GetTemplates ¶
GetTemplates handles read business operation for template
func (*TemplateService) UpdateTemplate ¶
func (s *TemplateService) UpdateTemplate(ctx context.Context, templateURN string, template *Template) error
UpdateTemplate handles update business operation for template
func (*TemplateService) Validate ¶
func (s *TemplateService) Validate(template Template) error
Validate validates domain template based on the business rule
type ValidationError ¶
type ValidationError struct {
Err error
}
func (ValidationError) Error ¶
func (e ValidationError) Error() string