domain

package
v0.0.0-...-37d2846 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChildrenName = "children"
	ParentName   = "parent"
)

Variables

View Source
var (
	// ErrRegistrationNotFound will throw if the searched person registration cannot be found
	ErrRegistrationNotFound = errors.New("person registration not found")
	// ErrInvalidSelfRelation will throw if the attempted relationship is with oneself.
	ErrInvalidSelfRelation = errors.New("cannot create a relationship with oneself")
	// ErrDuplicateRelation will throw if the attempted relationship already exists.
	ErrDuplicateRelation = errors.New("relationship already exists")
	// ErrRelationNotFound will throw if the searched relationship cannot be found.
	ErrRelationNotFound = errors.New("relationship not found")
	// ErrIncestuousRelation will throw if the attempted relationship is incestuous.
	ErrIncestuousRelation = errors.New("cannot create incestuous relationship")
)
View Source
var FamilyConnection = map[string]int64{
	"self":         0,
	"parent":       1,
	"children":     1,
	"sibling":      2,
	"grandparent":  2,
	"grandchild":   2,
	"aunt_uncle":   3,
	"niece_nephew": 3,
	"cousin":       4,
}

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	ErrorMessage string `json:"error"`
}

type Family

type Family struct {
	ID               int64      `json:"id" xml:"id"`
	Name             string     `json:"name" xml:"name"`
	Relationship     string     `json:"relationship" xml:"relationship"`
	FamilyConnection int64      `json:"family_connection" xml:"family_connection"`
	Relationships    []Relation `json:"relationships" xml:"relationships>relation"`
}

type Member

type Member struct {
	XMLName xml.Name `json:"-" xml:"family"`
	ID      int64    `json:"id" xml:"id"`
	Name    string   `json:"name" xml:"name"`
	Members []Family `json:"members" xml:"members>member"`
}

type Person

type Person struct {
	ID        int64      `json:"id"`
	Name      string     `json:"name"`
	Email     string     `json:"email"`
	BirthDate *time.Time `json:"birth_date"`
	CreatedAt time.Time  `json:"created_at"`
}

type PersonRepository

type PersonRepository interface {
	GetByID(id int64) (Person, error)
	CreatePerson(person PersonRequest) error
	GetAllPerson() ([]Person, error)
}

type PersonRequest

type PersonRequest struct {
	Name      string `json:"name" binding:"required,min=3"`
	Email     string `json:"email" binding:"required,email"`
	BirthDate string `json:"birth_date"`
}

type PersonUseCase

type PersonUseCase interface {
	GetByID(id int64) (Person, error)
	CreatePerson(person PersonRequest) error
	GetAllPerson() ([]Person, error)
}

type Relation

type Relation struct {
	ID           int64  `json:"id" xml:"id"`
	Name         string `json:"name" xml:"name"`
	Relationship string `json:"relationship" xml:"relationship"`
}

type Relationship

type Relationship struct {
	ParentId   int64 `json:"parent"`
	ChildrenId int64 `json:"children"`
}

type RelationshipRepository

type RelationshipRepository interface {
	GetRelationshipByID(personId int64) (*Member, error)
	CreateRelationship(personId int64, relationship Relationship) error
	DeleteRelationship(personId int64) error
}

type RelationshipUseCase

type RelationshipUseCase interface {
	GetRelationshipByID(personId int64) (*Member, error)
	CreateRelationship(personId int64, person Relationship) error
	DeleteRelationship(personId int64) error
}

Jump to

Keyboard shortcuts

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