entity

package
v0.0.0-...-c7bd0a4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	ID        string    `json:"id" gorm:"type:uuid;primaryKey" valid:"uuid"`
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at;autoUpdateTime" valid:"required"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;autoCreateTime" valid:"-"`
}

type Employee

type Employee struct {
	Base            `json:",inline" valid:"-"`
	Name            string            `json:"name" gorm:"column:name;not null" valid:"required"`
	Email           string            `json:"email" gorm:"column:email;not null" valid:"email"`
	Password        string            `json:"-" gorm:"column:password;not null" valid:"required"`
	Position        string            `json:"position" gorm:"column:position;not null" valid:"required"`
	Presentation    string            `json:"presentation" gorm:"column:presentation" valid:"required"`
	HireDate        time.Time         `json:"hire_date" gorm:"column:hire_date" valid:"required"`
	TerminationDate time.Time         `json:"termination_date" gorm:"column:termination_date" valid:"-"`
	IsActive        bool              `json:"is_active" gorm:"column:is_active;not null" valid:"-"`
	Skills          []*Skill          `json:"-" gorm:"many2many:employees_skills" valid:"-"`
	EmployeesSkills []*EmployeesSkill `json:"-" gorm:"foreignKey:EmployeeID" valid:"-"`
}

func NewEmployee

func NewEmployee(name, position, email, password, presentation string, hireDate time.Time) (*Employee, error)

func (*Employee) Activate

func (e *Employee) Activate(hireDate time.Time) error

func (*Employee) CompareHashAndPassword

func (e *Employee) CompareHashAndPassword(password string) error

func (*Employee) Deactivate

func (e *Employee) Deactivate(terminationDate time.Time) error

func (*Employee) HashedPassword

func (e *Employee) HashedPassword(password string) error

func (*Employee) SetEmail

func (e *Employee) SetEmail(email string) error

func (*Employee) SetHireDate

func (e *Employee) SetHireDate(hireDate time.Time) error

func (*Employee) SetName

func (e *Employee) SetName(name string) error

func (*Employee) SetPosition

func (e *Employee) SetPosition(position string) error

func (*Employee) SetPresentation

func (e *Employee) SetPresentation(presentation string) error

type EmployeesSkill

type EmployeesSkill struct {
	XP         XP        `json:"xp" gorm:"column:xp;not null" valid:"xp"`
	Note       string    `json:"note" gorm:"column:note;varchar(500)" valid:"-"`
	SkillID    string    `gorm:"column:skill_id;type:uuid;not null;unique_index:unique_employee_skill;primaryKey" valid:"uuid"`
	Skill      *Skill    `json:"-" valid:"-"`
	EmployeeID string    `gorm:"column:employee_id;type:uuid;not null;unique_index:unique_employee_skill;primaryKey" valid:"uuid"`
	Employee   *Employee `json:"-" valid:"-"`
}

func NewEmployeesSkill

func NewEmployeesSkill(employee *Employee, skill *Skill, xp XP, note string) (*EmployeesSkill, error)

func (*EmployeesSkill) SetNote

func (e *EmployeesSkill) SetNote(note string) error

func (*EmployeesSkill) SetXp

func (e *EmployeesSkill) SetXp(xp XP) error

type Skill

type Skill struct {
	Base            `json:",inline" valid:"-"`
	Name            string            `json:"name" gorm:"column:name;type:varchar(255);unique" valid:"-"`
	Employees       []*Employee       `json:"-" gorm:"many2many:employees_skils" valid:"-"`
	EmployeesSkills []*EmployeesSkill `json:"-" gorm:"foreignKey:SkillID" valid:"-"`
}

func NewSkill

func NewSkill(name string) (*Skill, error)

type XP

type XP int
const (
	JUNIOR XP = iota + 1
	FULL
	SENIOR
	SPECIALIST
)

func (XP) String

func (t XP) String() string

Jump to

Keyboard shortcuts

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