models

package
v0.0.0-...-5e59bf0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TASK_INPROGRESS = "IN-PROGRESS"
	TASK_DONE       = "DONE"
	TASK_CANCELED   = "CANCELED"
	TASK_BROWSE     = "BROWSE"

	ACTION_REGISTER   = "REGISTER"
	ACTION_NEW_RECORD = "NEW RECORD"
)

Variables

This section is empty.

Functions

func FetchOrder

func FetchOrder(id uint) (order *Order, err *DbErr)

func GetAdmin

func GetAdmin() (user *User, err *DbErr)

func HashPassword

func HashPassword(pass string) string

func Init

func Init(externalDb *gorm.DB) error

Types

type Activity

type Activity struct {
	ID         uint   `gorm:"primaryKey" json:"id"`
	RecieverID uint   `gorm:"not null" json:"reciever_id"`
	Title      string `gorm:"not null" json:"title"`
	Action     string `gorm:"not null" json:"action"`

	Task Task `gorm:"-" json:"task,omitempty"`
}

type DbErr

type DbErr struct {
	HttpErr echo.HTTPError
	Err     error
}

func Create

func Create[T any](model *T) *DbErr

func Delete

func Delete(model any) (e *DbErr)

func DeleteById

func DeleteById(id uint, model any) (e *DbErr)

func FetchAllOrders

func FetchAllOrders() (orders *[]Order, err *DbErr)

func FindById

func FindById[T any](id uint) (model *T, e *DbErr)

func FindByIdPreload

func FindByIdPreload[T any](id uint, preload string) (model *T, e *DbErr)

func GetActivitiesByUserId

func GetActivitiesByUserId(id uint) (actitivies *[]Activity, herr *DbErr)

func GetAll

func GetAll[T any](sel string, con ...any) (models *[]T, e *DbErr)

func GetAllPreload

func GetAllPreload[T any](sel, preload string, con ...any) (models *[]T, e *DbErr)

func Login

func Login(u *User) *DbErr

func SeenActivities

func SeenActivities(id uint) *DbErr

func UpdateById

func UpdateById[T any](id uint, model *T) (e *DbErr)

func UpdateStatus

func UpdateStatus[T any](id uint, status string) (e *DbErr)

func (*DbErr) Error

func (e *DbErr) Error() string

func (*DbErr) Unwrap

func (e *DbErr) Unwrap() error

type Order

type Order struct {
	ID       uint      `gorm:"primaryKey" json:"id"`
	User     User      `json:"-"`
	UserID   uint      `gorm:"not null" json:"user_id"`
	Status   string    `gorm:"default:IN-PROGRESS" json:"status"`
	Products []Product `gorm:"many2many:order_products" json:"products,omitempty"`
}

func (Order) GetID

func (o Order) GetID() uint

func (Order) GetName

func (Order) GetName() string

func (Order) GetOwnerID

func (o Order) GetOwnerID() uint

func (Order) GetStatus

func (o Order) GetStatus() string

type Product

type Product struct {
	ID          uint    `gorm:"primaryKey" json:"id,omitempty"`
	OrderID     uint    `json:"order_id,omitempty"`
	Title       string  `gorm:"not null" json:"title,omitempty"`
	Description string  `gorm:"not null" json:"description,omitempty"`
	Price       float64 `gorm:"not null" json:"price,omitempty"`
	Orders      []Order `gorm:"many2many:order_products" json:"orders,omitempty"`
}

type Refund

type Refund struct {
	ID      uint   `gorm:"primaryKey" json:"id,omitempty"`
	OrderID uint   `gorm:"not null; unique" json:"order_id,omitempty"`
	Status  string `gorm:"default:IN-PROGRESS" json:"status,omitempty"`
	Order   Order  `json:"order,omitempty"`
}

func (Refund) GetID

func (r Refund) GetID() uint

func (Refund) GetName

func (Refund) GetName() string

func (Refund) GetOwnerID

func (r Refund) GetOwnerID() uint

func (Refund) GetStatus

func (r Refund) GetStatus() string

type Task

type Task interface {
	GetID() uint
	GetStatus() string
	GetOwnerID() uint
	GetName() string
}

func AnyToTask

func AnyToTask(model any) Task

type User

type User struct {
	ID       uint   `gorm:"primaryKey" json:"id"`
	Username string `gorm:"not null; unique" json:"username"`
	Password string `gorm:"not null" json:"password,omitempty"`
}

func GetAdminConf

func GetAdminConf() User

func (User) GetID

func (o User) GetID() uint

func (User) GetName

func (User) GetName() string

func (User) GetOwnerID

func (o User) GetOwnerID() uint

func (User) GetStatus

func (o User) GetStatus() string

Jump to

Keyboard shortcuts

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