node

package
v0.0.0-...-20be885 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FieldsAll = []string{
		"id",
		"hierarchy",
		"name",
		"email_address",
	}

	FieldsAllExceptId = []string{
		"hierarchy",
		"name",
		"email_address",
	}

	FieldsHierarchy = []string{
		"hierarchy",
	}

	FieldsPatchable = []string{
		"hierarchy",
		"name",
		"email_address",
	}
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	ConfigService      *config.Service
	LocalErrorService  *localerror.Service
	NodeService        *Service
	DesignationService *designation.Service
	MembershipService  *membership.Service
}

func NewController

func NewController(
	cfg *config.Service,
	les *localerror.Service,
	svc *Service,
	ds *designation.Service,
	ms *membership.Service,
) *Controller

func (*Controller) Delete

func (c *Controller) Delete(w http.ResponseWriter, r *http.Request)

Delete Nodes : HTTP endpoint to delete nodes @Tags Nodes @Description Delete a node @Produce json @Param id path string true "Node ID" @Success 200 {object} DeleteResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id} [DELETE]

func (*Controller) Get

func (c *Controller) Get(w http.ResponseWriter, r *http.Request)

Get Nodes : HTTP endpoint to get a node @Tags Nodes @Description Get a node @Produce json @Param id path string true "Node ID" @Success 200 {object} GetResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id} [GET]

func (*Controller) GetChildren

func (c *Controller) GetChildren(w http.ResponseWriter, r *http.Request)

Get Children of Nodes : HTTP endpoint to get the children of a node @Tags Nodes @Description Get children of a node @Produce json @Param id path string true "Node ID" @Success 200 {object} GetChildrenResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id}/children [GET]

func (*Controller) GetLineage

func (c *Controller) GetLineage(w http.ResponseWriter, r *http.Request)

Get Lineage of Nodes : HTTP endpoint to get the lineage of a node @Tags Nodes @Description Get lineage of a node @Produce json @Param id path string true "Node ID" @Success 200 {object} GetLineageResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id}/lineage [GET]

func (*Controller) GetLineageSiblings

func (c *Controller) GetLineageSiblings(w http.ResponseWriter, r *http.Request)

Get Lineage Siblings of Nodes : HTTP endpoint to get the siblings and ancestral siblings of a node @Tags Nodes @Description Get siblings and ancestral siblings of a node @Produce json @Param id path string true "Node ID" @Success 200 {object} GetLineagelSiblingsResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id}/lineage-siblings [GET]

func (*Controller) GetMembers

func (c *Controller) GetMembers(w http.ResponseWriter, r *http.Request)

Get Members within Nodes : HTTP endpoint to get the current members within a node @Tags Nodes @Description Get current members within a node @Produce json @Param id path string true "Node ID" @Success 200 {object} GetMembersResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id}/members [GET]

func (*Controller) GetOfficers

func (c *Controller) GetOfficers(w http.ResponseWriter, r *http.Request)

Get Officers within Nodes : HTTP endpoint to get the officers within a node @Tags Nodes @Description Get officers within a node @Produce json @Param id path string true "Node ID" @Success 200 {object} GetOfficersResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id}/officers [GET]

func (*Controller) Patch

func (c *Controller) Patch(w http.ResponseWriter, r *http.Request)

Patch Nodes : HTTP endpoint to patch a node @Tags Nodes @Description Patch a node @Accept json @Produce json @Param id path string true "Node ID" @Param data body PatchRequestDto true "Node Patch Request" @Success 200 {object} PatchResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes/{id} [PATCH]

func (*Controller) Post

func (c *Controller) Post(w http.ResponseWriter, r *http.Request)

Post Nodes : HTTP endpoint to post new nodes @Tags Nodes @Description Post a new node @Accept json @Produce json @Param data body PostRequestDto true "Node Request" @Success 200 {object} PostResponseDto "Success Response" @Failure 400 "BadRequest" @Failure 500 "InternalServerError" @Router /nodes [POST]

type DeleteResponseDto

type DeleteResponseDto = dtorespwithoutdata.Class

type Entity

type Entity struct {
	Id           string `json:"id"`
	Hierarchy    string `json:"hierarchy"`
	Name         string `json:"name"`
	EmailAddress string `json:"email_address"`
}

func (Entity) GetId

func (e Entity) GetId() string

func (Entity) SetId

func (e Entity) SetId(id string)

type GetChildrenResponseDto

type GetChildrenResponseDto = dtorespwithdata.Class[[]Entity]

type GetLineageResponseDto

type GetLineageResponseDto = dtorespwithdata.Class[tree.Node[Entity]]

type GetLineagelSiblingsResponseDto

type GetLineagelSiblingsResponseDto = dtorespwithdata.Class[tree.Node[Entity]]

type GetMembersResponseDto

type GetMembersResponseDto = dtorespwithdata.Class[[]membership.ViewEntity]

type GetOfficersResponseDto

type GetOfficersResponseDto = dtorespwithdata.Class[[]designation.Entity]

type GetResponseDto

type GetResponseDto = dtorespwithdata.Class[Entity]

type PatchRequestDto

type PatchRequestDto struct {
	Fields map[string]interface{} `json:"fields"`
}

type PatchResponseDto

type PatchResponseDto = dtorespwithoutdata.Class

type PostRequestDto

type PostRequestDto struct {
	Id           string `json:"id"`
	Hierarchy    string `json:"hierarchy"`
	Name         string `json:"name"`
	EmailAddress string `json:"email_address"`
}

type PostResponseDto

type PostResponseDto = dtorespwithdata.Class[Entity]

type Query

type Query interface {
	SelectById(fields []string, id string) *gorm.DB
	SelectChildrenByHierarchy(fields []string, hierarchy string) *gorm.DB
	SelectLineageByHierarchy(fields []string, hierarchy string) (*gorm.DB, error)
	SelectLineageSiblingsByHierarchy(fields []string, hierarchy string) (*gorm.DB, error)
	SelectChildrenById(fields []string, id string) *gorm.DB
}

func NewQuery

func NewQuery(db *gorm.DB, tableName string) Query

type QueryImpl

type QueryImpl struct {
	Db        *gorm.DB
	TableName string
}

func (*QueryImpl) SelectById

func (q *QueryImpl) SelectById(fields []string, id string) *gorm.DB

func (*QueryImpl) SelectChildrenByHierarchy

func (q *QueryImpl) SelectChildrenByHierarchy(fields []string, hierarchy string) *gorm.DB

func (*QueryImpl) SelectChildrenById

func (q *QueryImpl) SelectChildrenById(fields []string, id string) *gorm.DB

func (*QueryImpl) SelectLineageByHierarchy

func (q *QueryImpl) SelectLineageByHierarchy(fields []string, hierarchy string) (*gorm.DB, error)

func (*QueryImpl) SelectLineageSiblingsByHierarchy

func (q *QueryImpl) SelectLineageSiblingsByHierarchy(
	fields []string,
	hierarchy string,
) (*gorm.DB, error)

type Repository

type Repository interface {
	Create(req *Entity) (*Entity, error)
	UpdateById(fields map[string]interface{}, id string) error
	FindById(id string) (*Entity, error)
	DeleteById(id string) error
	FindChildrenByHierarchy(hierarchy string) ([]Entity, error)
	FindLineageByHierarchy(hierarchy string) ([]Entity, error)
	FindLineageSiblingsByHierarchy(hierarchy string) ([]Entity, error)
	FindChildrenById(id string) ([]Entity, error)
	FindLineageById(hierarchy string) ([]Entity, error)
	FindLineageSiblingsById(hierarchy string) ([]Entity, error)
}

func NewRepository

func NewRepository(cfg *config.Service) Repository

type RepositoryImpl

type RepositoryImpl struct {
	ConfigService *config.Service
	TableName     string
	Query         Query
}

func (*RepositoryImpl) Create

func (r *RepositoryImpl) Create(req *Entity) (*Entity, error)

func (*RepositoryImpl) DeleteById

func (r *RepositoryImpl) DeleteById(id string) error

func (*RepositoryImpl) FindById

func (r *RepositoryImpl) FindById(id string) (*Entity, error)

func (*RepositoryImpl) FindChildrenByHierarchy

func (r *RepositoryImpl) FindChildrenByHierarchy(hierarchy string) ([]Entity, error)

func (*RepositoryImpl) FindChildrenById

func (r *RepositoryImpl) FindChildrenById(id string) ([]Entity, error)

func (*RepositoryImpl) FindLineageByHierarchy

func (r *RepositoryImpl) FindLineageByHierarchy(hierarchy string) ([]Entity, error)

func (*RepositoryImpl) FindLineageById

func (r *RepositoryImpl) FindLineageById(id string) ([]Entity, error)

func (*RepositoryImpl) FindLineageSiblingsByHierarchy

func (r *RepositoryImpl) FindLineageSiblingsByHierarchy(
	hierarchy string,
) ([]Entity, error)

func (*RepositoryImpl) FindLineageSiblingsById

func (r *RepositoryImpl) FindLineageSiblingsById(id string) ([]Entity, error)

func (*RepositoryImpl) UpdateById

func (r *RepositoryImpl) UpdateById(fields map[string]interface{}, id string) error

type Service

type Service struct {
	ConfigService  *config.Service
	NodeRepository Repository
}

func NewService

func NewService(
	cfg *config.Service,
	r Repository,
) *Service

func (*Service) Create

func (s *Service) Create(req PostRequestDto) (*Entity, error)

func (*Service) DeleteById

func (s *Service) DeleteById(id string) error

func (*Service) RetrieveById

func (s *Service) RetrieveById(id string) (*Entity, error)

func (*Service) RetrieveChildrenById

func (s *Service) RetrieveChildrenById(id string) ([]Entity, error)

func (*Service) RetrieveLineageById

func (s *Service) RetrieveLineageById(id string) (*tree.Node[Entity], error)

func (*Service) RetrieveLineageSiblingsById

func (s *Service) RetrieveLineageSiblingsById(id string) (*tree.Node[Entity], error)

func (*Service) UpdateById

func (s *Service) UpdateById(fields map[string]interface{}, id string) error

Jump to

Keyboard shortcuts

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