Documentation ¶
Index ¶
- Variables
- type AdditionalField
- type CreateDomain
- type CreateMenu
- type CreateMenuItem
- type Domains
- type DomainsList
- type DomainsListQuery
- type DomainsRepository
- type GetMenu
- type GetMenuByCode
- type GetMenuItem
- type ListDomains
- type ListMenuItems
- type ListMenus
- type MenuFilter
- type MenuItemFilter
- type MenuItemPreview
- type MenuItemRepository
- type MenuItemTree
- type MenuItems
- func (mi MenuItems) Create(ctx context.Context, action CreateMenuItem) (*uuid.UUID, error)
- func (mi MenuItems) Delete(ctx context.Context, action GetMenuItem) error
- func (mi MenuItems) Get(ctx context.Context, action GetMenuItem) (*entity.MenuItem, error)
- func (mi MenuItems) GetTree(ctx context.Context, action GetMenuByCode) ([]*MenuItemTree, error)
- func (mi MenuItems) List(ctx context.Context, action ListMenuItems) ([]MenuItemPreview, error)
- func (mi MenuItems) Move(ctx context.Context, action MoveMenuItem) error
- func (mi MenuItems) Update(ctx context.Context, action UpdateMenuItem) error
- type MenuItemsListFilter
- type MenuRepository
- type Menus
- func (m Menus) Create(ctx context.Context, action CreateMenu) (*uuid.UUID, error)
- func (m Menus) Delete(ctx context.Context, action GetMenu) error
- func (m Menus) Get(ctx context.Context, action GetMenu) (*entity.Menu, error)
- func (m Menus) GetByCode(ctx context.Context, action GetMenuByCode) (*entity.Menu, error)
- func (m Menus) List(ctx context.Context, action ListMenus) (*MenusList, error)
- func (m Menus) Update(ctx context.Context, action UpdateMenu) error
- type MenusCallbacks
- type MenusList
- type MoveMenuItem
- type MoveMenuItemQuery
- type Pagination
- type UpdateMenu
- type UpdateMenuItem
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMenuAlreadyExists = errors.Conflict.New("menu with the same code already exists").T("menu.conflict") ErrMaxPosition = errors.BadRequest.New("position of menu item too large").T("menu-item.position-too-large") ErrFieldNotUpdatable = errors.BadRequest.New("field is not updatable") ErrMaxDepthExceeded = errors.BadRequest.New("the maximum depth level for menu items has been reached").T("menu-item.max-depth-exceeded") ErrMenuNotFound = errors.NotFound.New("menu not found").T("menu.not-found") ErrMenuItemNotFound = errors.NotFound.New("menu item does not exist").T("menu-item.not-found") )
Functions ¶
This section is empty.
Types ¶
type AdditionalField ¶
type CreateDomain ¶
type CreateDomain struct {
Domain string `json:"domain" validate:"required,url"`
}
type CreateMenu ¶
type CreateMenuItem ¶
type CreateMenuItem struct { MenuId uuid.UUID `json:"menuId" validate:"required,notBlank"` Name string `json:"name" validate:"required,notBlank,min=3,max=50"` DomainId *uuid.UUID `json:"domainId" validate:"omitempty,notBlank"` Url string `json:"url" validate:"omitempty,slashedSluggable"` AdditionalFields []AdditionalField `json:"additionalFields" validate:"omitempty,unique=Code,dive"` ParentMenuItemId *uuid.UUID `json:"parentMenuItemId" validate:"omitempty,notBlank"` }
type Domains ¶
type Domains struct {
// contains filtered or unexported fields
}
Domains сервис работы с доменами
func NewDomains ¶
func NewDomains(domainRepository DomainsRepository) *Domains
NewDomains конструктор
func (Domains) List ¶
func (d Domains) List(ctx context.Context, action ListDomains) (*DomainsList, error)
List получение списка доменов
type DomainsList ¶
type DomainsListQuery ¶
type DomainsListQuery struct {
Pagination
}
type DomainsRepository ¶
type GetMenuByCode ¶
type GetMenuByCode struct {
MenuCode string `json:"menuCode" validate:"required,min=3,max=50"`
}
type GetMenuItem ¶
type ListDomains ¶
type ListDomains struct {
Pagination
}
type ListMenuItems ¶
type ListMenuItems struct { Sort string `json:"sort" validate:"omitempty,oneof=id name position"` Order string `json:"order" validate:"omitempty,oneof=asc desc"` Filter MenuItemFilter `json:"filter"` }
type ListMenus ¶
type ListMenus struct { Pagination Sort string `json:"sort" validate:"omitempty,oneof=name"` Order string `json:"order" validate:"omitempty,oneof=asc desc"` }
type MenuItemFilter ¶
type MenuItemPreview ¶
type MenuItemRepository ¶
type MenuItemRepository interface { Has(ctx context.Context, menuId, menuItemId uuid.UUID) (bool, error) Create(ctx context.Context, menuItem entity.MenuItem) error Update(ctx context.Context, menuItem entity.MenuItem) error Move(ctx context.Context, move MoveMenuItemQuery) error Delete(ctx context.Context, Id uuid.UUID) error Get(ctx context.Context, Id uuid.UUID) (*entity.MenuItem, error) List(ctx context.Context, filter MenuItemsListFilter) ([]entity.MenuItem, error) Count(ctx context.Context, filter MenuItemFilter) (int64, error) GetAsTree(ctx context.Context, menuCode string) ([]*entity.MenuItem, error) GetDepthLevel(ctx context.Context, id uuid.UUID) (int, error) GetMaxDepthLevel(ctx context.Context, parentId uuid.UUID) (int, error) }
MenuItemRepository интерфейс репозитория работы с элементами меню
type MenuItemTree ¶
type MenuItems ¶
MenuItems сервис работы с элементами меню
func NewMenuItems ¶
func NewMenuItems( menuRepository MenuRepository, menuItemRepository MenuItemRepository, maxMenuItemsDepth int, callbacks callbacks.Callbacks, ) *MenuItems
NewMenuItems конструктор
func (MenuItems) Delete ¶
func (mi MenuItems) Delete(ctx context.Context, action GetMenuItem) error
Delete удаление пункта меню
func (MenuItems) GetTree ¶
func (mi MenuItems) GetTree(ctx context.Context, action GetMenuByCode) ([]*MenuItemTree, error)
GetTree получение дерева пунктов меню
func (MenuItems) List ¶
func (mi MenuItems) List(ctx context.Context, action ListMenuItems) ([]MenuItemPreview, error)
List получение списка пунктов меню
type MenuItemsListFilter ¶
type MenuItemsListFilter struct { Sort string Order string Filter MenuItemFilter }
type MenuRepository ¶
type MenuRepository interface { Has(ctx context.Context, id uuid.UUID) (bool, error) HasByCode(ctx context.Context, code string) (bool, error) Create(ctx context.Context, menu entity.Menu) error Update(ctx context.Context, menu *entity.Menu) error GetByCode(ctx context.Context, code string) (*entity.Menu, error) Get(ctx context.Context, Id uuid.UUID) (*entity.Menu, error) Delete(ctx context.Context, Id uuid.UUID) error List(ctx context.Context, filter MenuFilter) ([]entity.Menu, error) Count(ctx context.Context) (int64, error) }
MenuRepository интерфейс репозитория работы с меню
type Menus ¶
Menus сервис работы с меню
func NewMenus ¶
func NewMenus( menuRepository MenuRepository, callbacks callbacks.Callbacks, ) *Menus
NewMenus конструктор
type MenusCallbacks ¶
type MenusCallbacks struct { AfterCreate func(menu *entity.Menu) AfterUpdate func(oldMenu, newMenu *entity.Menu) }
MenusCallbacks колбэки сервиса работы с меню
type MoveMenuItem ¶
type MoveMenuItem struct { MenuId uuid.UUID `json:"menuId" validate:"required,notBlank"` MenuItemId uuid.UUID `json:"menuItemId" validate:"required,notBlank"` ParentMenuItemId *uuid.UUID `json:"parentMenuItemId" validate:"omitempty,notBlank,nefield=MenuItemId"` Position int64 `json:"position" validate:"required,min=1"` }
type MoveMenuItemQuery ¶
type Pagination ¶
type UpdateMenu ¶
type UpdateMenuItem ¶
type UpdateMenuItem struct { MenuId uuid.UUID `json:"menuId" validate:"required,notBlank"` MenuItemId uuid.UUID `json:"menuItemId" validate:"required,notBlank"` Name string `json:"name" validate:"required,notBlank,min=3,max=50"` DomainId *uuid.UUID `json:"domainId" validate:"omitempty,notBlank"` Url string `json:"url" validate:"omitempty,slashedSluggable"` AdditionalFields []AdditionalField `json:"additionalFields" validate:"omitempty,unique=Code"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.