store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CartAdd

func CartAdd(id uint16, product Product, count int) error

func CartDel

func CartDel(id uint16, product ...Product) error

func GetRandom

func GetRandom() ([]bson.M, error)

func InitDB

func InitDB() *mongo.Database

func SearchItself

func SearchItself()

Types

type Address

type Address struct {
	Name     string `json:"name"`
	Addr     string `json:"addr"`
	Phone    string `json:"phone"`
	Postal   string `json:"postal"`
	Province string `json:"province"`
}

type Cart

type Cart struct {
	Owner    uint16    `bson:"owner"`
	Item     []item    `bson:"item,omitempty"`
	CreateAt time.Time `bson:"create_at,omitempty"`
	UpdateAt time.Time `bson:"update_at,omitempty"`
}

type Mgo

type Mgo struct {
	// contains filtered or unexported fields
}
var Client Mgo

func (*Mgo) Close

func (m *Mgo) Close()

func (*Mgo) Init

func (m *Mgo) Init()

type Order

type Order struct {
	OrderNo      string    `json:"OrderNo" bson:"OrderNo"`
	Seller       string    `json:"seller" bson:"seller,omitempty"`
	Buyer        string    `json:"buyer" bson:"buyer"`
	Payment      int32     `json:"payment" bson:"payment" `
	PaymentType  int       `json:"payment_type" bson:"payment_type,omitempty" `
	ShippingTo   Address   `json:"shipping_to" bson:"shipping_to,omitempty"`
	Item         []Product `json:"item" bson:"item,omitempty"`
	CreateTime   time.Time `json:"create_time" bson:"create_time"`
	IsClose      bool      `json:"is_close"`
	EndTime      time.Time `json:"end_time"`
	SendTime     time.Time `json:"send_time"`
	sync.RWMutex `bson:"-"`
}

OrderNo 订单号 Seller 卖家 Buyer 卖家 Payment 价格 PaymentType 支付方式 ShippingTo 邮寄地址 IsClose 订单是否已关闭 CreateAt 订单创建时间

func (*Order) Create

func (o *Order) Create() error

订单创建

func (*Order) Delete

func (o *Order) Delete() error

订单删除

func (*Order) Update

func (o *Order) Update(filed string, value interface{}) error

订单修改

type Product

type Product struct {
	ProductId    uint16    `json:"product_id" bson:"_id"`                    //商品id
	Name         string    `json:"name" bson:"name,omitempty"`               //商品名
	ImageUri     string    `json:"image_uri" bson:"image_uri,omitempty"`     //商品图片url
	Description  string    `json:"description" bson:"description,omitempty"` //商品介绍
	Information  Type      `json:"info" bson:"info,omitempty"`               //品牌
	Price        int       `json:"price" bson:"price,omitempty"`             //价格
	Off          int       `json:"off" bson:"off,omitempty"`                 //折扣
	Owner        string    `json:"owner" bson:"owner,omitempty"`             //拥有者
	CreateAt     time.Time `json:"create_at" bson:"create_at,omitempty"`     //创建时间
	Shelves      bool      `json:"shelves" bson:"shelves,omitempty"`         //是否上架
	IsDelete     bool      `json:"is_delete" bson:"is_delete,omitempty"`     //是否已删除
	sync.RWMutex `json:"_" bson:"_"`
}
func Search(key string, pageNumber int, PerPage int) ([]Product, error)

func (*Product) Add

func (p *Product) Add() error

func (*Product) Delete

func (p *Product) Delete() error

func (*Product) Get

func (p *Product) Get() error

func (*Product) Set

func (p *Product) Set(filed string, value interface{}) error

func (*Product) Update

func (p *Product) Update() error

type Shop

type Shop struct {
	Name         string    `json:"name" bson:"name"`
	Owner        string    `json:"owner" bson:"owner,omitempty"`
	Description  string    `json:"description" bson:"description,omitempty"`
	IsClose      bool      `json:"is_close" bson:"is_close,omitempty"`
	CreateAt     time.Time `json:"create_at" bson:"create_at,omitempty"`
	CloseAt      time.Time `json:"close_at" bson:"close_at,omitempty"`
	sync.RWMutex `bson:"-"`
	IsDelete     bool `json:"is_delete" bson:"is_delete,omitempty"`
}

func (*Shop) Create

func (s *Shop) Create() error

创建一家店铺的存储方法

func (*Shop) Delete

func (s *Shop) Delete() error

删除一家店铺

func (*Shop) Set

func (s *Shop) Set(filed string, value interface{}) error

修改店铺信息

type Type

type Type struct {
	Category string `json:"category"` //产品分类
	Brand    string `json:"brand"`    //产品品牌
}

type UserInformation

type UserInformation struct {
	Id           uint16    `json:"id,omitempty" bson:"id,omitempty"`
	Username     string    `json:"username" validate:"min=1,max=32" bson:"username,omitempty"`
	Password     string    `json:"password,omitempty" validate:"min=1,max=32" bson:"password,omitempty"`
	Email        string    `json:"email,omitempty"  bson:"email,omitempty"`
	Role         int       `json:"role,omitempty" bson:"role,omitempty"`
	Gander       int       `json:"gander,omitempty" bson:"gander,omitempty"`
	Addresses    []Address `json:"addresses,omitempty" bson:"addresses,omitempty"`
	sync.RWMutex `bson:"-"`
}

func (*UserInformation) Create

func (u *UserInformation) Create() error

创建用户

func (*UserInformation) Delete

func (u *UserInformation) Delete() error

删除一位用户

func (*UserInformation) GetUser

func (u *UserInformation) GetUser() (*UserInformation, error)

获取用户信息

func (*UserInformation) Set

func (u *UserInformation) Set(filed string, value interface{}) error

修改用户信息

Jump to

Keyboard shortcuts

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