models

package
v0.0.0-...-ab91d5a Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCommodity

func CreateCommodity(commodity *Commodity) error

CreateCommodity 创建新商品

func CreateUser

func CreateUser(user *User) error

CreateUser 创建公司普通员工账号

func DeleteCommodity

func DeleteCommodity(commodityID string) error

DeleteCommodity 删除商品

func DeleteCustormerOrder

func DeleteCustormerOrder(orderID string) error

DeleteCustormerOrder 删除客户订单

func DeletePurchaseOrder

func DeletePurchaseOrder(orderID string) error

DeletePurchaseOrder 删除采购订单

func DeleteUser

func DeleteUser(userID string) error

DeleteUser 删除公司普通员工账号

func DisableUserRole

func DisableUserRole(userID string, role RoleType) error

DisableUserRole 更新角色用户权限

func EnableUserRole

func EnableUserRole(userID string, role RoleType) error

EnableUserRole 更新角色用户权限

func GetUserRole

func GetUserRole(userID string) ([]string, error)

GetUserRole 获取用户角色权限

func HaveCommodity

func HaveCommodity(id string) bool

HaveCommodity 查询是否有此商品

func HaveTel

func HaveTel(tel string) bool

HaveTel 查询是否有此账号

func HaveUser

func HaveUser(userID string) bool

HaveUser 查询是否有此用户

func Init

func Init(info *DBInfo)

Init 初始化

func QueryYearFinance

func QueryYearFinance(year int) (profit []float32, turnover []float32, orderQuantity []int, err error)

QueryYearFinance 查询年利润,营业额

func UpdateCommodity

func UpdateCommodity(commodityID string, commodity *Commodity) error

UpdateCommodity 更新商品信息

func UpdatePassword

func UpdatePassword(userID string, newPassword string) error

UpdatePassword 更新密码

func UpdateUser

func UpdateUser(userID string, newName, newTel, newPassword, newPosition string) error

UpdateUser 更新用户信息

Types

type Commodity

type Commodity struct {
	ID            string `gorm:"primary_key"`
	Name          string
	Colour        string
	Size          string
	Brand         string
	Number        uint
	PresaleNumber uint
	SalesVolume   uint
	Price         float32
	PurchasePrice float32
}

Commodity 商品表

func GetCommodities

func GetCommodities() (commodities []Commodity, err error)

GetCommodities 获取所有商品信息

func GetCommoditiesWithPurchasePrice

func GetCommoditiesWithPurchasePrice() (commodities []Commodity, err error)

GetCommoditiesWithPurchasePrice 获取所有商品信息(包含进价)

func GetCommodity

func GetCommodity(id string) *Commodity

GetCommodity 获取商品信息

type CustormerGoods

type CustormerGoods struct {
	CustormerOrderID uint
	GoodsID          string
	Number           uint
}

CustormerGoods 客户订单详细商品表

type CustormerOrder

type CustormerOrder struct {
	gorm.Model
	Operator        string `gorm:"size:255"`
	Name            string
	Tel             string
	DeliveryAddress string
	DeliveryTime    string
	Amount          float32
	Deposit         float32
	Remarks         string
	State           string `gorm:"default:'未完成'"`
	Freight         float32
}

CustormerOrder 客户订单表

type CustormerOrderInfo

type CustormerOrderInfo struct {
	CustormerOrder
	Goods []Commodity
}

CustormerOrderInfo 与客户端通信的订单信息

func ConfirmCustormerOrder

func ConfirmCustormerOrder(orderID string, freight float32) (*CustormerOrderInfo, error)

ConfirmCustormerOrder 确认订单

func CreateCustormerOrder

func CreateCustormerOrder(order *CustormerOrder, goods []CustormerGoods) (*CustormerOrderInfo, error)

CreateCustormerOrder 创建客户订单

func ListCustormerOrders

func ListCustormerOrders() (orders []CustormerOrderInfo, err error)

ListCustormerOrders 获取所有客户订单

type DBInfo

type DBInfo struct {
	Name     string `json:"name"`
	Password string `json:"password"`
	DBname   string `json:"DBname"`
	Addr     string `json:"addr"`
}

DBInfo 数据库连接信息

type PurchaseGoods

type PurchaseGoods struct {
	PurchaseOrderID uint
	GoodsID         string
	Number          uint
}

PurchaseGoods 采购订单详细产品表

type PurchaseOrder

type PurchaseOrder struct {
	gorm.Model
	Operator string `gorm:"size:255"`
	Remarks  string
	Amount   float32
	Freight  float32
	State    string `gorm:"default:'未完成'"`
}

PurchaseOrder 采购订单表

type PurchaseOrderInfo

type PurchaseOrderInfo struct {
	PurchaseOrder
	Goods []Commodity
}

PurchaseOrderInfo 订单信息

func ConfirmPurchaseOrder

func ConfirmPurchaseOrder(orderID string, freight float32) (*PurchaseOrderInfo, error)

ConfirmPurchaseOrder 确认订单

func CreatePurchaseOrder

func CreatePurchaseOrder(order *PurchaseOrder, goods []PurchaseGoods) (*PurchaseOrderInfo, error)

CreatePurchaseOrder 创建采购订单

func ListPurchaseOrders

func ListPurchaseOrders() (orders []PurchaseOrderInfo, err error)

ListPurchaseOrders 所有订单

type Role

type Role struct {
	UserID string `gorm:"primary_key"`
	Admin  bool
	CM     bool
	PM     bool
}

Role 用户角色权限

type RoleType

type RoleType int

RoleType 角色权限枚举

const (
	// Admin 管理员
	Admin RoleType = iota
	// CM 保留管理权限
	CM
	// PM 保留管理权限
	PM
)

type User

type User struct {
	UserID   string `gorm:"primary_key"`
	Name     string `gorm:"size:255;not null"`
	Tel      string `gorm:"not null;unique_index"`
	Password string `gorm:"not null"`
	Position string `gorm:"not null"`
}

User 用户信息

func GetUser

func GetUser(userID string) *User

GetUser 获取用户信息

func ListUsers

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

ListUsers 所有用户

func VerifyUser

func VerifyUser(tel string, password string) (*User, error)

VerifyUser 验证用户账号密码

Jump to

Keyboard shortcuts

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