model

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

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

Go to latest
Published: Jun 4, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAddress

func AddAddress(address Address) (uint64, error)

func AddBook

func AddBook(book Book) (uint64, error)

func AddCartItem

func AddCartItem(userID, bookID uint64) error

func AddOrder

func AddOrder(userID uint64, addressID uint, booksID []uint64) (uint64, error)

func AddPurchasedNum

func AddPurchasedNum(bookID uint64) (err error)

func AddUser

func AddUser(name, passwd string) (id uint64)

func CountAddresses

func CountAddresses(userID uint64) int

func CountBooks

func CountBooks(filter BooksFilter) (count uint64)

func CountOrders

func CountOrders(userID uint64) (count uint64, err error)

func CountUsers

func CountUsers(isAdmin bool) (count uint64)

func DeleteAddress

func DeleteAddress(id uint64) (err error)

func GetBookCategories

func GetBookCategories(id uint64) (categories []string)

func GetCategories

func GetCategories() (names []string)

func GetPrivilegeSet

func GetPrivilegeSet(userID uint64) (perm.PrivilegeSet, error)

func GetPrivileges

func GetPrivileges(userID uint64) ([]string, error)

func HasPrivilege

func HasPrivilege(userID uint64, privilege string) bool

func HasPrivileges

func HasPrivileges(userID uint64, privileges []string) bool

func SetPrivileges

func SetPrivileges(userID uint64, privileges []string) (err error)

func UpdateAddress

func UpdateAddress(address Address) (err error)

func UpdateBook

func UpdateBook(book Book) (err error)

func UpdateCartItem

func UpdateCartItem(userID, bookID uint64, quantity uint) (err error)

func UpdateCategories

func UpdateCategories(bookID uint64, categories []string) (err error)

func UpdateOrderStatus

func UpdateOrderStatus(id uint64, status string) (err error)

func VerifyUser

func VerifyUser(name, passwd string) (id uint64)

Types

type Address

type Address struct {
	ID        uint64
	UserID    uint64
	Consignee string
	Phone     string
	Province  string
	City      string
	County    string
	TownShip  string
	Detail    string
}

func GetAddress

func GetAddress(id uint64) (address Address, err error)

type Addresses

type Addresses []Address

func GetAddresses

func GetAddresses(userID uint64) (addresses Addresses, err error)

type Book

type Book struct {
	ID           uint64 // 数据库自增id,添加图书时不用填写
	ISBN         string
	Cover        sql.NullString
	Name, Author string
	Price        float64
	Intro        sql.NullString
	Deleted      bool
}

func GetBook

func GetBook(id uint64) (book Book, err error)

type Books

type Books = []Book

func GetBooks

func GetBooks(filter BooksFilter, offset, count uint64) (rows Books, err error)

type BooksFilter

type BooksFilter struct {
	Category   string
	Info       string
	MustExists bool
}

type CartBook

type CartBook struct {
	ID              uint64
	Name, Author    string
	Quantity        uint
	Price, Subtotal float64
}

type CartBooks

type CartBooks = []CartBook

func GetCartItems

func GetCartItems(userID uint64) (books CartBooks)

type Limit

type Limit struct {
	Offset uint64
	Count  uint64
}

type Order

type Order struct {
	ID        uint64
	UserID    uint64
	AddressID uint64
	Total     float64
	Status    string
	Items     OrderItems
	time.Time
}

func GetOrder

func GetOrder(id uint64, needItems bool) (order Order, err error)

type OrderItem

type OrderItem struct {
	Name     string
	Cover    sql.NullString
	Quantity uint
	Price    float64
	Subtotal float64
}

type OrderItems

type OrderItems = []OrderItem

func GetOrderItems

func GetOrderItems(orderID uint64) (orderItems OrderItems, err error)

type Orders

type Orders = []Order

func GetOrders

func GetOrders(userID, offset, row_count uint64) (orders Orders, err error)

type User

type User struct {
	ID           uint64
	Name         string
	CreationTime time.Time
	Privileges   []string
}

func GetUser

func GetUser(id uint64) (user User, err error)

type Users

type Users = []User

func GetUsers

func GetUsers(isAdmin bool, limit Limit) (users Users, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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