models

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID        uint64 `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Firstname string `json:"firstname" gorm:"size:255" validate:"required,min=1,max=255"`
	Surname   string `json:"surname" gorm:"size:255" validate:"required,min=1,max=255"`
}

Author represents an author entity with ID, Firstname, and Surname.

func (*Author) TableName added in v0.4.3

func (a *Author) TableName() string

TableName returns the author table name.

func (*Author) Validate

func (a *Author) Validate(v *validator.Validate) error

Validate validates the Author struct based on defined validation tags.

type Book added in v0.8.0

type Book struct {
	ID               uint         `json:"id" gorm:"primaryKey;autoIncrement;->"`
	BranchID         uint         `json:"branch_id"`
	Branch           *Branch      `json:"branch" gorm:"foreignKey:BranchID"`
	Added            time.Time    `json:"added"`
	Title            string       `json:"title" gorm:"type:varchar(255);not null" validate:"required"`
	ShortDescription string       `json:"short_description"`
	Author           []*Author    `json:"authors" gorm:"many2many:book_author;"`
	GenreID          uint         `json:"genre_id" gorm:"index"`
	Genre            *Genre       `json:"genre" gorm:"foreignKey:GenreID"`
	Price            float32      `json:"price" gorm:"default:0.00"`
	Sold             bool         `json:"sold" gorm:"default:false"`
	SoldOn           time.Time    `json:"sold_on,omitempty"`
	Removed          bool         `json:"removed" gorm:"default:false"`
	RemovedOn        time.Time    `json:"removed_on,omitempty"`
	Reserved         bool         `json:"reserved" gorm:"default:false"`
	ReservedAt       time.Time    `json:"reserved_at,omitempty"`
	ReleaseYear      int          `json:"published_date" validate:"release_year"`
	Condition        *Condition   `json:"condition" gorm:"foreignKey:ConditionID"`
	ConditionID      uint         `json:"condition_id"`
	Tags             []*Tag       `json:"tags" gorm:"many2many:book_tag;"`
	Recommendation   bool         `json:"recommendations" gorm:"foreignKey:BookID"`
	Inventory        bool         `json:"inventory" gorm:"default:false"`
	Format           *Format      `json:"format" gorm:"foreignKey:FormatID"`
	FormatID         uint         `json:"format_id" gorm:"not null"`
	Subtitle         string       `json:"subtitle" validate:"max=255"`
	Duplicate        bool         `gorm:"default:false"`
	ReservationID    uuid.UUID    `json:"reservation_id"`
	Reservation      *Reservation `json:"reservation" gorm:"foreignKey:ReservationID"`
}

Book represents a book entity.

func (Book) TableName added in v0.8.0

func (Book) TableName() string

TableName overrides the default table name for Book model.

type Branch added in v0.6.0

type Branch struct {
	ID        uint    `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name      string  `json:"name" validate:"required,max=255"`
	Steps     float32 `json:"steps" validate:"gte=0.00" gorm:"default:0.00"`
	Currency  string  `json:"currency" validate:"required,oneof=EUR USD" gorm:"default:'EUR'"`
	Ordering  string  `json:"ordering" gorm:"type:text"`
	Public    bool    `json:"public" gorm:"default:false"`
	Pricelist string  `json:"pricelist" gorm:"type:text"`
	Cart      bool    `json:"cart" gorm:"default:false"`
	Content   string  `json:"content" gorm:"type:text"`
}

Branch represents a branch entity with various attributes.

func (*Branch) TableName added in v0.6.0

func (b *Branch) TableName() string

TableName returns the branch table name.

func (*Branch) Validate added in v0.6.0

func (b *Branch) Validate(v *validator.Validate) error

Validate validates the Branch struct based on defined validation tags.

type Condition added in v0.7.0

type Condition struct {
	ID       uint   `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name     string `json:"name" gorm:"type:varchar(255);not null;unique" validate:"required,min=1,max=255"`
	BranchID uint   `json:"branch_id" gorm:"index"`
	Branch   Branch `json:"branch" gorm:"foreignKey:BranchID"`
}

Condition model represents a book's condition.

func (Condition) TableName added in v0.7.0

func (Condition) TableName() string

TableName overrides the default table name for Condition model.

func (*Condition) Validate added in v0.7.0

func (c *Condition) Validate(db *gorm.DB) bool

Validate validates the Condition model based on defined rules.

type Format added in v0.11.0

type Format struct {
	ID       uint   `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name     string `json:"name" validate:"required,min=1,max=255"`
	BranchID uint   `json:"branch_id" gorm:"index"`
	Branch   Branch `json:"branch" gorm:"foreignKey:BranchID"`
	Books    []Book `json:"-" gorm:"foreignKey:FormatID"`
}

Format represents a book format entity.

func (Format) TableName added in v0.11.0

func (Format) TableName() string

TableName overrides the default table name for Format model.

func (*Format) Validate added in v0.11.0

func (f *Format) Validate(db *gorm.DB) bool

Validate validates the Format model based on defined rules.

type Genre added in v0.9.0

type Genre struct {
	ID       uint   `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name     string `json:"name" gorm:"type:varchar(255);not null" validate:"required,min=1,max=255"`
	BranchID uint   `json:"branch_id" gorm:"index"`
	Branch   Branch `json:"branch" gorm:"foreignKey:BranchID"`
}

Genre represents a genre entity.

func (Genre) TableName added in v0.9.0

func (Genre) TableName() string

TableName overrides the default table name for Genre model.

func (*Genre) Validate added in v0.9.0

func (g *Genre) Validate(db *gorm.DB) bool

Validate validates the Genre model based on defined rules.

type Reservation added in v0.11.0

type Reservation struct {
	ID         string    `json:"id" gorm:"primaryKey"`
	BranchID   uint      `json:"branch_id" gorm:"index"`
	Branch     Branch    `json:"branch" gorm:"foreignKey:BranchID"`
	CreatedAt  time.Time `json:"created_at"`
	Notes      string    `json:"notes"`
	Books      []*Book   `json:"books" gorm:"foreignKey:ReservationID"`
	Salutation string    `json:"salutation" validate:"required,oneof=m f d"`
	Firstname  string    `json:"firstname" validate:"required,max=255"`
	Surname    string    `json:"surname" validate:"required,max=255"`
	Mail       string    `json:"mail" validate:"required,email,max=255"`
	Phone      string    `json:"phone" validate:"max=255"`
	Open       bool      `json:"open" gorm:"default:true"`
}

Reservation represents a reservation.

func (*Reservation) BeforeCreate added in v0.11.0

func (r *Reservation) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate hook for Reservation model.

func (Reservation) TableName added in v0.11.0

func (Reservation) TableName() string

TableName overrides the default table name for the Reservation model.

func (*Reservation) Validate added in v0.11.0

func (r *Reservation) Validate(db *gorm.DB) bool

Validate validates the Reservation model.

type Tabler added in v0.6.0

type Tabler interface {
	TableName() string
}

Tabler interface for table name.

type Tag added in v0.8.0

type Tag struct {
	ID   uint   `json:"id" gorm:"primaryKey;autoIncrement;->"`
	Name string `json:"name" validate:"required,max=255"`

	BranchID uint   `json:"branch_id" gorm:"index"`
	Branch   Branch `json:"branch" gorm:"foreignKey:BranchID"`

	Books []*Book `json:"books" gorm:"many2many:book_tag;"`
}

Tag represents a tag model.

func (Tag) TableName added in v0.8.0

func (Tag) TableName() string

TableName overrides the default table name.

func (*Tag) Validate added in v0.8.0

func (t *Tag) Validate(db *gorm.DB) bool

Validate validates the Tag model.

Jump to

Keyboard shortcuts

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