model

package
v0.0.0-...-3dd6f4c Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 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 Image

type Image struct {
	gorm.Model
	ProductImage           string `gorm:"not null" json:"product_image"`
	CompressedProductImage string `json:"compressed_product_image"`
	ProductID              uint
}

type LoginInput

type LoginInput struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type Product

type Product struct {
	gorm.Model
	ProductName        string  `gorm:"size:255; not null" json:"product_name"`
	ProductDescription string  `gorm:"type:text; not null" json:"product_description"`
	ProductPrice       float64 `gorm:"not null" json:"product_price"`
	UserID             uint
	Images             []Image
}

func (*Product) Save

func (product *Product) Save() (*Product, error)

type RegisterInput

type RegisterInput struct {
	Username  string  `json:"username" binding:"required"`
	Password  string  `json:"password" binding:"required"`
	Mobile    string  `json:"mobile" binding:"required"`
	Latitude  float64 `json:"latitude" binding:"required"`
	Longitude float64 `json:"longitude" binding:"required"`
}

type User

type User struct {
	gorm.Model
	Username  string  `gorm:"size:255;not null;uniqueIndex" json:"username"`
	Password  string  `gorm:"size:255;not null;" json:"-"`
	Mobile    string  `gorm:"unique;not null" json:"mobile"`
	Latitude  float64 `gorm:"not null;check:latitude >= -90 AND latitude <= 90" json:"latitude"`
	Longitude float64 `gorm:"not null;check:longitude >= -180 AND longitude <= 180" json:"longitude"`
	Products  []Product
}

func FindUserById

func FindUserById(id uint) (User, error)

func FindUserByUsername

func FindUserByUsername(username string) (User, error)

func (*User) BeforeSave

func (user *User) BeforeSave(*gorm.DB) error

func (*User) Save

func (user *User) Save() (*User, error)

func (*User) ValidatePassword

func (user *User) ValidatePassword(password string) error

Jump to

Keyboard shortcuts

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