entities

package
v0.0.0-...-d3a2b01 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 5 Imported by: 0

README

Чистые структуры, не зависящие от внешних библиотек. Желательно, чтобы их методы вызывались только в бизнес-логике, а во внешних слоях вызывались только методы сервисов (бизнес-логики). Нежелательно отдавать объекты моделей наружу, вместо них можно использовать т.н. data transfer objects (могут быть свои для каждого слоя).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRequest

type AuthRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Context

type Context struct {
	ID      int    `db:"id"`
	RegDate string `db:"registration_date"`
	Text    string `db:"text"`
}

func (*Context) Contains

func (c *Context) Contains(other *Context) bool

func (*Context) ContainsUnit

func (c *Context) ContainsUnit(unit *Unit) bool

func (*Context) GetRegDate

func (c *Context) GetRegDate() (time.Time, error)

func (*Context) IsDuplicate

func (c *Context) IsDuplicate(other *Context) bool

func (*Context) IsValid

func (c *Context) IsValid() error

func (*Context) SetRegDate

func (c *Context) SetRegDate(t time.Time)

type Model

type Model struct {
	ID   int    `db:"id"`
	Name string `db:"name"`
}

func (*Model) AddElement

func (m *Model) AddElement(element *ModelElement) *Model

func (*Model) Contains

func (m *Model) Contains(other *Model) bool

func (*Model) ContainsElement

func (m *Model) ContainsElement(element *ModelElement) bool

func (*Model) GetNuclearElem

func (m *Model) GetNuclearElem() (*Model, error)

func (*Model) IsDuplicate

func (m *Model) IsDuplicate(other *Model) bool

func (*Model) IsValid

func (m *Model) IsValid() error

func (*Model) IsValidName

func (m *Model) IsValidName() error

type ModelElement

type ModelElement struct {
	ID   int    `db:"id"`
	Name string `db:"name"`
}

func (*ModelElement) IsValid

func (e *ModelElement) IsValid() error

type Properties

type Properties []Property

func (Properties) Contains

func (p Properties) Contains(other *Property) bool

func (Properties) RemoveDuplicates

func (p Properties) RemoveDuplicates() Properties

type Property

type Property struct {
	ID   int    `db:"id"`
	Name string `db:"property"`
}

func (*Property) Contains

func (p *Property) Contains(other *Property) bool

func (*Property) IsDuplicate

func (p *Property) IsDuplicate(other *Property) bool

func (*Property) IsValid

func (p *Property) IsValid() error

type Unit

type Unit struct {
	ID      int    `db:"id"`
	ModelID int    `db:"model_id"`
	RegDate string `db:"registration_date"`
	Text    string `db:"text"`
}

func (Unit) GetNuclearElem

func (u Unit) GetNuclearElem() (*Unit, error)

func (Unit) GetRegDate

func (u Unit) GetRegDate() (time.Time, error)

func (Unit) IsValid

func (u Unit) IsValid() error

func (Unit) SetModel

func (u Unit) SetModel(model *Model) error

func (Unit) SetRegDate

func (u Unit) SetRegDate(t time.Time)

type UnitsMap

type UnitsMap map[string][]Unit

type User

type User struct {
	ID       int    `db:"id"`
	Name     string `db:"name"`
	Password string `db:"password"`
	Role     string `db:"role"`
	RegDate  string `db:"registration_date"`
}

func NewUser

func NewUser(request *AuthRequest) *User

func (*User) GetHash

func (u *User) GetHash() (uint64, error)

func (*User) GetRegDate

func (u *User) GetRegDate() (time.Time, error)

func (*User) IsValid

func (u *User) IsValid() error

func (*User) SetRegDate

func (u *User) SetRegDate(t time.Time)

Jump to

Keyboard shortcuts

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