category

package
v0.0.0-...-b2483d2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUUID

func IsUUID(id string) bool

func NewUUID

func NewUUID() string

Types

type AdminDetailDto

type AdminDetailDto struct {
	*Entity
}

type AdminListDto

type AdminListDto struct {
	UUID      string                  `json:"uuid" bson:"_id,omitempty"`
	MainUUIDs []string                `json:"mainUUIDs" bson:"main_uuids"`
	Images    []Image                 `json:"images" bson:"images"`
	Meta      map[Locale]*MetaListDto `json:"meta" bson:"meta"`
	IsActive  bool                    `json:"isActive" bson:"is_active"`
	IsDeleted bool                    `json:"isDeleted" bson:"is_deleted"`
	UpdatedAt time.Time               `json:"updatedAt" bson:"updated_at"`
}

type Alert

type Alert struct {
	UUID         string                     `json:"uuid" bson:"uuid" validate:"required,uuid4"`
	Translations map[Locale]BaseTranslation `json:"translations" bson:"translations"`
	Type         string                     `json:"type" bson:"type"` // info, warning, error
}

type AlertDto

type AlertDto struct {
	UUID         string                     `json:"uuid"`
	CategoryMeta map[Locale]*MetaMiniDto    `json:"categoryMeta"`
	Translations map[Locale]BaseTranslation `json:"translations"`
	Type         string                     `json:"type"`
}

type BaseTranslation

type BaseTranslation struct {
	Name        string `json:"name" bson:"name" validate:"required,max=255,min=3"`
	Description string `json:"description" bson:"description" validate:"required,max=255,min=3"`
}

type CreatedEvent

type CreatedEvent struct {
	AdminUUID string  `json:"admin_uuid"`
	Entity    *Entity `json:"entity"`
}

type DeletedEvent

type DeletedEvent struct {
	AdminUUID  string `json:"admin_uuid"`
	EntityUUID string `json:"entity_uuid"`
}

type DetailDto

type DetailDto struct {
	UUID      string           `json:"uuid" bson:"_id,omitempty"`
	MainUUIDs []string         `json:"mainUUIDs" bson:"main_uuids"`
	Images    []Image          `json:"images" bson:"images"`
	Meta      map[Locale]*Meta `json:"meta" bson:"meta"`
	CreatedAt time.Time        `json:"createdAt" bson:"created_at"`
}

type DisabledEvent

type DisabledEvent struct {
	AdminUUID  string `json:"admin_uuid"`
	EntityUUID string `json:"entity_uuid"`
}

type EnabledEvent

type EnabledEvent struct {
	AdminUUID  string `json:"admin_uuid"`
	EntityUUID string `json:"entity_uuid"`
}

type Entity

type Entity struct {
	UUID        string           `json:"uuid" bson:"_id,omitempty"`
	MainUUID    string           `json:"mainUUID" bson:"main_uuid,omitempty"  validate:"omitempty,object_id"`
	MainUUIDs   []string         `json:"mainUUIDs" bson:"main_uuids"  validate:"omitempty,dive,object_id"`
	Images      []Image          `json:"images" bson:"images"  validate:"min=1,max=30,dive,required"`
	Meta        map[Locale]*Meta `json:"meta" bson:"meta" validate:"required,dive"`
	InputGroups []InputGroup     `json:"inputGroups" bson:"input_groups" validate:"required,dive"`
	Inputs      []Input          `json:"inputs" bson:"inputs" validate:"required,dive"`
	Rules       []Rule           `json:"rules" bson:"rules" validate:"required,dive"`
	Alerts      []Alert          `json:"alerts" bson:"alerts" validate:"required,dive"`
	Validators  []string         `json:"validators" bson:"validators" validate:"required,min=1"`
	Order       int              `json:"order" bson:"order" validate:"required,min=0,max=100"`
	IsActive    bool             `json:"isActive" bson:"is_active" validate:"required,boolean"`
	IsDeleted   bool             `json:"isDeleted" bson:"is_deleted" validate:"required,boolean"`
	CreatedAt   time.Time        `json:"createdAt" bson:"created_at" validate:"required"`
	UpdatedAt   time.Time        `json:"updatedAt" bson:"updated_at" validate:"required"`
}

func (*Entity) BeforeCreate

func (e *Entity) BeforeCreate()

func (*Entity) BeforeUpdate

func (e *Entity) BeforeUpdate()

func (Entity) GetInput

func (e Entity) GetInput(uuid string) (Input, bool)

func (*Entity) HasValidator

func (e *Entity) HasValidator(name string) bool

func (*Entity) IsMain

func (e *Entity) IsMain() bool

func (*Entity) ToAdminDetail

func (e *Entity) ToAdminDetail() *AdminDetailDto

func (*Entity) ToAdminList

func (e *Entity) ToAdminList() *AdminListDto

func (*Entity) ToAlert

func (e *Entity) ToAlert() []*AlertDto

func (*Entity) ToDetail

func (e *Entity) ToDetail() *DetailDto

func (*Entity) ToInputGroup

func (e *Entity) ToInputGroup() []*InputGroupDto

func (*Entity) ToList

func (e *Entity) ToList() *ListDto

func (*Entity) ToMetaList

func (m *Entity) ToMetaList() map[Locale]*MetaListDto

func (*Entity) ToMetaMini

func (m *Entity) ToMetaMini() map[Locale]*MetaMiniDto

func (*Entity) ToRule

func (e *Entity) ToRule() []*RuleDto

type Errors

type Errors interface {
	InvalidInputType(t string) *i18np.Error
	InvalidInputUUID(uuid string) *i18np.Error
	InvalidInputGroupUUID(uuid string) *i18np.Error
	Failed(action string) *i18np.Error
	NotFound() *i18np.Error
	MinOneTranslationRequired(field string) *i18np.Error
	InvalidMetaLength(len int) *i18np.Error
	InvalidImagesLength(len int) *i18np.Error
	InvalidUUID(uuid string) *i18np.Error
	InvalidCategoryInputType(t string, value interface{}) *i18np.Error
	ParentUUIDIsNotEmpty() *i18np.Error
	ParentUUIDIsNotCorrect() *i18np.Error
	CategoryUUIDsIsNotCorrect() *i18np.Error
	FeatureIsNotCorrect() *i18np.Error
}

type EventConfig

type EventConfig struct {
	Topics    config.Topics
	Publisher events.Publisher
}

type Events

type Events interface {
	Created(event CreatedEvent)
	Updated(event UpdatedEvent)
	Enabled(event EnabledEvent)
	Disabled(event DisabledEvent)
	Deleted(event DeletedEvent)
	UpdateOrder(event OrderUpdatedEvent)
	ListingValidationSuccess(event ListingValidationSuccessEvent)
	ListingValidationFailed(event ListingValidationFailedEvent)
}

func NewEvents

func NewEvents(cnf EventConfig) Events

type Factory

type Factory struct {
	Errors Errors
}

func NewFactory

func NewFactory() Factory

func (Factory) IsZero

func (f Factory) IsZero() bool

func (Factory) New

func (f Factory) New(cnf NewConfig) *Entity

func (Factory) Validate

func (f Factory) Validate(entity *Entity) *i18np.Error

type I18nDetail

type I18nDetail struct {
	Locale string
	Slug   string
}

type Image

type Image struct {
	Url   string `json:"url" bson:"url" validate:"required,url"`
	Order int16  `json:"order" bson:"order" validate:"required,min=0,max=20"`
}

type Input

type Input struct {
	UUID         string                       `json:"uuid" bson:"uuid" validate:"required,uuid4"`
	GroupUUID    string                       `json:"groupUUID" bson:"group_uuid"`
	Type         InputType                    `json:"type" bson:"type"  validate:"required"`
	Translations map[Locale]*InputTranslation `json:"translations" bson:"translations" validate:"required,dive"`
	IsRequired   *bool                        `json:"isRequired" bson:"is_required"  validate:"required,boolean"`
	IsMultiple   *bool                        `json:"isMultiple" bson:"is_multiple"  validate:"required,boolean"`
	IsUnique     *bool                        `json:"isUnique" bson:"is_unique"  validate:"required,boolean"`
	IsPayed      *bool                        `json:"isPayed" bson:"is_payed"  validate:"required,boolean"`
	Extra        []InputExtra                 `json:"extra" bson:"extra"  validate:"required,dive"`
	Options      []string                     `json:"options" bson:"options"  validate:"required,min=0"`
}

func (Input) GetExtra

func (i Input) GetExtra(name string) (string, bool)

func (Input) HasOption

func (i Input) HasOption(option string) bool

type InputExtra

type InputExtra struct {
	Name  string `json:"name" bson:"name" validate:"required,max=255,min=1"`
	Value string `json:"value" bson:"value" validate:"required,max=255,min=1"`
}

type InputGroup

type InputGroup struct {
	UUID         string                     `json:"uuid" bson:"uuid" validate:"required,uuid4"`
	Icon         string                     `json:"icon" bson:"icon" validate:"required,max=255,min=3"`
	Translations map[Locale]BaseTranslation `json:"translations" bson:"translations" validate:"required,dive"`
}

type InputGroupDto

type InputGroupDto struct {
	UUID         string                     `json:"uuid" bson:"uuid" validate:"required,uuid4"`
	Icon         string                     `json:"icon" bson:"icon" validate:"required,max=255,min=3"`
	Translations map[Locale]BaseTranslation `json:"translations" bson:"translations" validate:"required,dive"`
	Inputs       []Input                    `json:"inputs" bson:"inputs" validate:"required,dive"`
}

type InputTranslation

type InputTranslation struct {
	Name        string `json:"name" bson:"name" validate:"required,max=255,min=3"`
	Placeholder string `json:"placeholder" bson:"placeholder" validate:"required,max=255,min=3"`
	Help        string `json:"help" bson:"help" validate:"required,max=255,min=3"`
}

type InputType

type InputType string
const (
	InputTypeText     InputType = "text"
	InputTypeTextarea InputType = "textarea"
	InputTypeNumber   InputType = "number"
	InputTypeSelect   InputType = "select"
	InputTypeRadio    InputType = "radio"
	InputTypeCheckbox InputType = "checkbox"
	InputTypeDate     InputType = "date"
	InputTypeTime     InputType = "time"
	InputTypeDatetime InputType = "datetime"
	InputTypeFile     InputType = "file"
	InputTypeImage    InputType = "image"
	InputTypePDF      InputType = "pdf"
	InputTypeRange    InputType = "range"
	InputTypeColor    InputType = "color"
	InputTypeURL      InputType = "url"
	InputTypeEmail    InputType = "email"
	InputTypeTel      InputType = "tel"
	InputTypeLocation InputType = "location"
	InputTypePrice    InputType = "price"
	InputTypeRating   InputType = "rating"
)

func (InputType) In

func (t InputType) In(types ...InputType) bool

func (InputType) String

func (t InputType) String() string

type ListDto

type ListDto struct {
	UUID      string                  `json:"uuid" bson:"_id,omitempty"`
	MainUUIDs []string                `json:"mainUUIDs" bson:"main_uuids"`
	Images    []Image                 `json:"images" bson:"images"`
	Meta      map[Locale]*MetaListDto `json:"meta" bson:"meta"`
}

type ListingValidationFailedEvent

type ListingValidationFailedEvent struct {
	ListingUUID  string                     `json:"listingUUID"`
	BusinessUUID string                     `json:"business_uuid"`
	BusinessName string                     `json:"business_name"`
	Listing      *listing.Entity            `json:"entity"`
	Errors       []*listing.ValidationError `json:"errors"`
	User         UserDetailEvent            `json:"user"`
}

type ListingValidationSuccessEvent

type ListingValidationSuccessEvent struct {
	ListingUUID  string          `json:"listingUUID"`
	BusinessUUID string          `json:"business_uuid"`
	BusinessName string          `json:"business_name"`
	Listing      *listing.Entity `json:"entity"`
	User         UserDetailEvent `json:"user"`
}

type Locale

type Locale string
const (
	LocaleEN Locale = "en"
	LocaleTR Locale = "tr"
)

func (Locale) String

func (l Locale) String() string

type Meta

type Meta struct {
	Name        string `json:"name" bson:"name" validate:"required,max=255,min=3"`
	Description string `json:"description" bson:"description" validate:"required,max=255,min=5"`
	Title       string `json:"title" bson:"title" validate:"required,max=100,min=5"`
	Slug        string `json:"slug" bson:"slug"`
	Seo         Seo    `json:"seo" bson:"seo"  validate:"required"`
}

func (*Meta) ToList

func (m *Meta) ToList() *MetaListDto

func (*Meta) ToMini

func (m *Meta) ToMini() *MetaMiniDto

type MetaListDto

type MetaListDto struct {
	Name        string `json:"name" bson:"name"`
	Description string `json:"description" bson:"description"`
	Title       string `json:"title" bson:"title"`
	Slug        string `json:"slug" bson:"slug"`
}

type MetaMiniDto

type MetaMiniDto struct {
	Name string `json:"name" bson:"name"`
	Slug string `json:"slug" bson:"slug"`
}

type NewConfig

type NewConfig struct {
	MainUUID    string
	MainUUIDs   []string
	Images      []Image
	Meta        map[Locale]*Meta
	InputGroups []InputGroup
	Inputs      []Input
	Rules       []Rule
	Alerts      []Alert
	Validators  []string
	Order       int
}

type OrderUpdatedEvent

type OrderUpdatedEvent struct {
	AdminUUID  string `json:"admin_uuid"`
	EntityUUID string `json:"entity_uuid"`
	Order      int16  `json:"order"`
}

type Repository

type Repository interface {
	Create(ctx context.Context, entity *Entity) (*Entity, *i18np.Error)
	Update(ctx context.Context, entity *Entity) *i18np.Error
	Delete(ctx context.Context, categoryUUID string) *i18np.Error
	Disable(ctx context.Context, categoryUUID string) *i18np.Error
	Enable(ctx context.Context, categoryUUID string) *i18np.Error
	FindChild(ctx context.Context, categoryUUID string) ([]*Entity, *i18np.Error)
	Find(ctx context.Context, categoryUUID string) (*Entity, *i18np.Error)
	FindAll(ctx context.Context, categoryUUIDs []string) ([]*Entity, *i18np.Error)
	AdminFindAll(ctx context.Context, onlyMains bool) ([]*Entity, *i18np.Error)
	AdminFindChild(ctx context.Context, categoryUUID string) ([]*Entity, *i18np.Error)
	UpdateOrder(ctx context.Context, categoryUUID string, order int16) *i18np.Error
	FindBySlug(ctx context.Context, i18n I18nDetail) (*Entity, *i18np.Error)
	FindFieldsByUUIDs(ctx context.Context, categoryUUIDs []string) ([]*Entity, *i18np.Error)
	FindByUUIDs(ctx context.Context, categoryUUIDs []string) ([]*Entity, *i18np.Error)
}

func NewRepo

func NewRepo(collection *mongo.Collection, factory Factory) Repository

type Rule

type Rule struct {
	UUID         string                     `json:"uuid" bson:"uuid" validate:"required,uuid4"`
	Translations map[Locale]BaseTranslation `json:"translations" bson:"translations" validate:"required,dive"`
}

type RuleDto

type RuleDto struct {
	UUID         string                     `json:"uuid"`
	CategoryMeta map[Locale]*MetaMiniDto    `json:"categoryMeta"`
	Translations map[Locale]BaseTranslation `json:"translations"`
}

type Seo

type Seo struct {
	Title       string     `json:"title" bson:"title" validate:"required,max=100,min=5"`
	Description string     `json:"description" bson:"description" validate:"required,max=255,min=5"`
	Keywords    string     `json:"keywords" bson:"keywords" validate:"required,max=255,min=5"`
	Canonical   string     `json:"canonical" bson:"canonical" validate:"omitempty,url"`
	Extra       []SeoExtra `json:"extra" bson:"extra" validate:"required"`
}

type SeoAttribute

type SeoAttribute struct {
	Name  string `json:"name" bson:"name" validate:"required,max=255,min=3"`
	Value string `json:"value" bson:"value" validate:"required,max=255,min=3"`
}

type SeoExtra

type SeoExtra struct {
	Name       string         `json:"name" bson:"name" validate:"required,max=255,min=3"`
	Content    string         `json:"content" bson:"content" validate:"required,max=255,min=3"`
	Attributes []SeoAttribute `json:"attributes" bson:"attributes" validate:"required"`
}

type UpdatedEvent

type UpdatedEvent struct {
	AdminUUID string  `json:"admin_uuid"`
	Entity    *Entity `json:"entity"`
}

type UserDetailEvent

type UserDetailEvent struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

type Validator

type Validator interface {
	Validate(input Input, value interface{}) *i18np.Error
	GetName() string
	GetType() InputType
}

type ValidatorFunc

type ValidatorFunc func(input Input, value interface{}) *i18np.Error

type Validators

type Validators map[InputType]Validator

func NewValidators

func NewValidators(errors Errors, config config.App) Validators

func (Validators) GetValidator

func (v Validators) GetValidator(t InputType) (Validator, bool)

Jump to

Keyboard shortcuts

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