entity

package
v0.0.0-...-8cce31a Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 5 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        uuid.UUID `json:"id" gorm:"type:char(36);primary_key"`
	CreatedAt time.Time `json:"created_at" gorm:"not null"`
}

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(scope *gorm.Scope) error

type Photo

type Photo struct {
	Base
	AuthorID uuid.UUID `json:"author_id" gorm:"type:char(36);not null"`
	Author   User      `json:"-" gorm:"foreignkey:AuthorID"`
	FileName string    `json:"-"`
	Url      string    `json:"url" gorm:"-"`
}

func (*Photo) PopulateUrl

func (p *Photo) PopulateUrl(host string)

type Point

type Point struct {
	Base
	AuthorID  uuid.UUID `json:"author_id" gorm:"type:char(36);not null"`
	Author    User      `json:"-" gorm:"foreignkey:AuthorID"`
	Latitude  float32   `json:"latitude" gorm:"not null"`
	Longitude float32   `json:"longitude" gorm:"not null"`
	PhotoID   uuid.UUID `json:"photo_id" gorm:"char(36)"`
	Photo     Photo     `json:"photo" gorm:"foreignkey:PhotoID"`

	AverageTaste float32 `json:"average_taste" gorm:"-"`
	UserRating   *Rating `json:"user_rating" gorm:"-"`
}

type Rating

type Rating struct {
	Base
	AuthorID uuid.UUID `json:"author_id" gorm:"type:char(36);not null"`
	Author   User      `json:"-" gorm:"foreignkey:AuthorID"`
	PointID  uuid.UUID `json:"point_id" gorm:"type:char(36);not null"`
	Point    Point     `json:"-" gorm:"foreignkey:PointID"`

	Taste uint32 `json:"taste"`
}

type User

type User struct {
	Base
	Username string `json:"username" gorm:"type:varchar(191);unique_index;not null"`
	Email    string `json:"email" gorm:"type:varchar(191);unique_index;not null"`
	Password string `json:"-" gorm:"not null"`
	Active   bool   `json:"active" gorm:"not null"`
}

Jump to

Keyboard shortcuts

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