models

package
v0.0.0-...-ed5149a Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ORDER_STATUS_PROCESSING = "processing"
	ORDER_STATUS_COMPLETED  = "completed"
	ORDER_STATUS_CANCELED   = "canceled"
)
View Source
const (
	REFUND_STATUS_APPENDING = "appending"
	REFUND_STATUS_APPROVED  = "approved"
	REFUND_STATUS_CANCELED  = "canceled"

	REFUND_ERROR_BADORDER = "Order is not completed"
)

Variables

This section is empty.

Functions

func CreateOrder

func CreateOrder(userId uint, description string) (id uint, err error)

func CreateRefund

func CreateRefund(orderId uint) (id uint, err error)

func DeleteOrder

func DeleteOrder(id uint) int64

func DeleteRefund

func DeleteRefund(id uint) int64

func InitDB

func InitDB() (err error)

func LoginUser

func LoginUser(username, password, email string) (uint, error)

func Migrate

func Migrate() error

func RegisterUser

func RegisterUser(username, password, email string) error

func UpdateOrder

func UpdateOrder(id uint, description, status string) int64

func UpdateRefund

func UpdateRefund(id uint, status string) int64

func UpdateUser

func UpdateUser(id uint, username, password, email string) int64

Types

type Order

type Order struct {
	ID          uint   `gorm:"primaryKey" json:"id"`
	UserID      uint   `json:"user_id"`
	Status      string `gorm:"not null;default:processing" json:"status"`
	Description string `gorm:"not null" json:"description"`

	User User `json:"-"`
}

func GetAllOrders

func GetAllOrders() (orders []Order, err error)

func GetOrderById

func GetOrderById(id uint) (order Order, err error)

type Refund

type Refund struct {
	ID      uint   `gorm:"primaryKey" json:"id"`
	OrderID uint   `gorm:"not null;unique" json:"order_id"`
	Status  string `gorm:"not null;default:appending" json:"status"`

	Order Order `json:"-"`
}

func GetAllRefunds

func GetAllRefunds() (Refunds []Refund, err error)

func GetRefundById

func GetRefundById(id uint) (Refund Refund, err error)

type User

type User struct {
	ID       uint   `gorm:"primaryKey" json:"id"`
	Password string `gorm:"not null" json:"pass"`
	Username string `gorm:"unique;not null" json:"user"`
	Email    string `gorm:"unique;not null" json:"email"`
}

func GetAllUsers

func GetAllUsers() (users []User, err error)

func GetUserById

func GetUserById(id uint) (user *User, err error)

Jump to

Keyboard shortcuts

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