entities

package
v0.0.0-...-d4bccd0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	gorm.Model
	UserID uint   `gorm:"not null" json:"user_id" form:"user_id"`
	Street string `gorm:"type:varchar(100);not null" json:"street" form:"street"`
	City   string `gorm:"type:varchar(100);not null" json:"city" form:"city"`
	State  string `gorm:"type:varchar(100);not null" json:"state" form:"state"`
	Zip    string `gorm:"type:varchar(5);not null" json:"zip" form:"zip"`
	User   User   `gorm:"foreignkey:UserID" json:"user" form:"user"`
}

type Book

type Book struct {
	gorm.Model
	Title        string   `gorm:"type:varchar(100);not null" json:"title" form:"title"`
	Isbn         string   `gorm:"type:varchar(100);unique;not null" json:"isbn" form:"isbn"`
	Author       string   `gorm:"type:varchar(60);not null" json:"author" form:"author"`
	Publisher    string   `gorm:"type:varchar(60);not null" json:"publisher" form:"publisher"`
	PublishDate  string   `gorm:"type:date;not null" json:"publish_date" form:"publish_date"`
	Description  string   `gorm:"type:text" json:"description" form:"description"`
	Cover        string   `gorm:"type:varchar(255)" json:"cover" form:"cover"`
	OwnerID      uint     `gorm:"not null" json:"owner_id" form:"owner_id"`
	CategorySlug string   `gorm:"type:varchar(100)" json:"category_slug" form:"category_slug"`
	Owner        User     `gorm:"foreignkey:OwnerID" json:"owner" form:"owner"`
	Category     Category `gorm:"foreignkey:CategorySlug;references:slug;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"category" form:"category"`
}

type Category

type Category struct {
	gorm.Model
	Slug string `gorm:"type:varchar(100);unique;not null" json:"slug" form:"slug"`
	Name string `gorm:"type:varchar(100);not null"`
}

type Rent

type Rent struct {
	gorm.Model
	UserID    uint      `gorm:"not null" json:"user_id" form:"user_id"`
	BookID    uint      `gorm:"not null" json:"book_id" form:"book_id"`
	AddressID uint      `gorm:"not null" json:"address_id" form:"address_id"`
	Status    string    `gorm:"type:enum('receive','return');default:'receive'" json:"status" form:"status"`
	ReturnAt  time.Time `gorm:"type:datetime(3);not null" json:"return_at" form:"return_at"`
	User      User      `gorm:"foreignkey:UserID" json:"user" form:"user"`
	Book      Book      `gorm:"foreignkey:BookID" json:"book" form:"book"`
	Address   Address   `gorm:"foreignkey:AddressID" json:"address" form:"address"`
}

type User

type User struct {
	gorm.Model
	Admin    bool   `gorm:"type:boolean;default:false" json:"admin" form:"admin"`
	Name     string `gorm:"type:varchar(100);not null" json:"name" form:"name"`
	Email    string `gorm:"type:varchar(100);unique;not null" json:"email" form:"email"`
	Password string `gorm:"type:varchar(255);not null" json:"password" form:"password"`

} //@name User

Jump to

Keyboard shortcuts

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