models

package
v0.0.0-...-1bcd10a Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectTimeOut   = time.Second * 30
	ReadWriteTimeOut = time.Second * 30

	UrlJsCode2Session string = "https://api.weixin.qq.com/sns/jscode2session"
)

Variables

View Source
var (
	WechatAppId     string
	WechatSecret    string
	WechatGrantType string
)
View Source
var AESSecretKey = beego.AppConfig.String("AESSecretKey")

Get global config

Functions

func GetWuid

func GetWuid() uint64

func JsCode2Session

func JsCode2Session(jsCode string) (string, string, error)

Types

type Address

type Address struct {
	AddressId    uint64 `json:"addressId" gorm:"column:addressId; primary_key; not null;"`
	Contact      string `json:"contact" gorm:"column:contact; type:varchar(32); not null;"`
	Telephone    string `json:"telephone" gorm:"column:telephone; type:varchar(15); not null;"`
	IsDefault    bool   `json:"isDefault" gorm:"column:isDefault; default:false; not null;"`
	Country      string `json:"country" gorm:"column:country; not null;"`
	ProvinceCity string `json:"city" gorm:"column:city; not null;"`
	Details      string `json:"details" gorm:"column:details; not null;"`
	Status       string `json:"status" gorm:"column:status; type:varchar(10); default:'active'; not null;"`
	UserId       uint64 `json:"userId" gorm:"column:userId; not null;"`
	BaseModel
}

func (*Address) CreateAddress

func (addr *Address) CreateAddress(dto *AddressDTO) error

func (*Address) DeleteAddressByAddressId

func (addr *Address) DeleteAddressByAddressId(userId uint64, addressId uint64) error

func (*Address) QueryAddressByAddressId

func (addr *Address) QueryAddressByAddressId(userId uint64, addressId uint64) (*Address, error)

func (*Address) QueryAddresses

func (addr *Address) QueryAddresses(userId uint64) ([]Address, error)

func (*Address) SetDefaultAddress

func (addr *Address) SetDefaultAddress(userId uint64, addressId uint64) error

func (*Address) UpdateAddress

func (addr *Address) UpdateAddress(dto *AddressDTO) error

type AddressDTO

type AddressDTO struct {
	AddressId    uint64 `json:"addressId"`
	Contact      string `json:"contact"`
	Telephone    string `json:"telephone"`
	IsDefault    bool   `json:"isDefault"`
	Country      string `json:"country"`
	ProvinceCity string `json:"provinceCity"`
	Details      string `json:"details"`
	UserId       uint64 `json:"userId"`
}
type Advert struct {
	AdvertId   uint64 `json:"advertId" gorm:"column:advertId; primary_key; not null;"`
	AdvertUrl  string `json:"advertUrl" gorm:"column:advertUrl; not null;"`
	RelativeId uint64 `json:"relativeId" gorm:"column:relativeId; not null;"`
	Remark     string `json:"remark" gorm:"column:remark; not null;"`
	BaseModel
}

func (*Advert) InsertAdvert

func (adv *Advert) InsertAdvert() error

func (*Advert) QueryAdvertList

func (adv *Advert) QueryAdvertList() ([]Advert, error)

func (*Advert) UpdateAdvertByAdvertId

func (adv *Advert) UpdateAdvertByAdvertId() error

type BaseModel

type BaseModel struct {
	CreatedAt time.Time  `json:"createdAt" gorm:"column:createdAt;type:dateTime"`
	UpdatedAt time.Time  `json:"updatedAt" gorm:"column:updatedAt;type:dateTime"`
	DeletedAt *time.Time `json:"-" gorm:"column:deletedAt;type:dateTime" sql:"index"`
}

type Category

type Category struct {
	CategoryId       uint64 `json:"categoryId" gorm:"column:categoryId; primary_key; not null;"`
	CategoryName     string `json:"categoryName" gorm:"column:categoryName; not null; type:varchar(10);"`
	CategoryIcon     string `json:"categoryIcon" gorm:"column:categoryIcon; not null;"`
	CategoryPriority uint8  `json:"categoryPriority" gorm:"column:categoryPriority; not null; default:0;"`
	Status           string `json:"status" gorm:"column:status; not null; default:'active';"`
	ClassifyId       uint64 `json:"classifyId" gorm:"column:classifyId; not null;"`
	BaseModel
}

type Classify

type Classify struct {
	ClassifyId       uint64 `json:"classifyId" gorm:"column:classifyId; not null; primary_key;"`
	ClassifyName     string `json:"classifyName" gorm:"column:classifyName; type: varchar(10); not null;"`
	ClassifyIcon     string `json:"classifyIcon" gorm:"column:classifyIcon; not null;"`
	ClassifyPriority uint8  `json:"classifyPriority" gorm:"column:classifyPriority; default:0; not null;"`
	Status           string `json:"status" gorm:"column:status; not null; default:'active';"`
	BaseModel
}

func (*Classify) CreateCategory

func (cls *Classify) CreateCategory(category *Category) error

func (*Classify) CreateClassify

func (cls *Classify) CreateClassify() error

func (*Classify) QueryClassifies

func (cls *Classify) QueryClassifies() ([]ClassifyVO, error)

type ClassifyVO

type ClassifyVO struct {
	ClassifyId       uint64 `json:"classifyId" gorm:"column:classifyId; not null; primary_key;"`
	ClassifyName     string `json:"classifyName" gorm:"column:classifyName; type: varchar(10); not null;"`
	ClassifyIcon     string `json:"classifyIcon" gorm:"column:classifyIcon; not null;"`
	ClassifyPriority uint8  `json:"classifyPriority" gorm:"column:classifyPriority; default:0; not null;"`

	CategoryId       uint64 `json:"categoryId" gorm:"column:categoryId; primary_key; not null;"`
	CategoryName     string `json:"categoryName" gorm:"column:categoryName; not null; type:varchar(10);"`
	CategoryIcon     string `json:"categoryIcon" gorm:"column:categoryIcon; not null;"`
	CategoryPriority uint8  `json:"categoryPriority" gorm:"column:categoryPriority; not null; default:0;"`
}

type IAddress

type IAddress interface {
	QueryAddresses(userId uint64) (*[]Address, error)
	CreateAddress(dto *AddressDTO) error
	QueryAddressByAddressId(userId uint64, addressId uint64) (*Address, error)
	UpdateAddress(dto *AddressDTO) error
	DeleteAddressByAddressId(userId uint64, addressId uint64) error
	SetDefaultAddress(userId uint64, addressId uint64) error
}

type IAdvert

type IAdvert interface {
	InsertAdvert() error
	UpdateAdvertByAdvertId() error
	QueryAdvertList() ([]Advert, error)
}

type IClassify

type IClassify interface {
	QueryClassifies() (*[]Classify, error)
	CreateClassify() error
	CreateCategory(category *Category) error
}

type IOrders

type IOrders interface {
	QueryOrders(userId uint64, orderType string, pageIndex int) (*[]OrderForm, error)
	PlaceOrder(dto *PlaceOrderDTO) error
	OrderCompleted(userId uint64, orderId uint64) error
	OrderCancel(userId uint64, orderId uint64) error
	QueryOrderDetails(userId uint64, orderId uint64) error
}

type IProduct

type IProduct interface {
	InsertProduct(dtos *ProductDTO) error
	InsertMultipleProducts(dtos *[]ProductDTO) error
	QueryProductsByProductType(productType string, pageIndex int) (*[]Product, error)
	QueryProductDetails(productId uint64) (interface{}, error)
	QueryInventoryDetails(inventoryId uint64) (interface{}, error)
}

type ITeamOperation

type ITeamOperation interface {
	QueryTeamByInvitationCode(invitationCode string) error
	QueryUserTeams(userId uint64) (*TeamVO, error)
}

type IUserOperation

type IUserOperation interface {
	Register(dto UserRegisterDTO) error
	CheckIsUserExistByUserId(userId uint64) (bool, error)
	CheckIsUserExistByTelephone(telephone string) (bool, error)
	QueryByUserId(userId string) *User
	LoginByTelephone(telephone string, password string) error
	LoginByWechat(jsCode string, wechatUserProfile string, invitationCode string) (*UserWechatVO, error)
}

type Inventory

type Inventory struct {
	InventoryId   uint64  `json:"inventoryId" gorm:"column:inventoryId; primary_key; not null;"`
	Quantity      uint    `json:"quantity" gorm:"column:quantity; default: 1000; not null;"`
	OriginPrice   float64 `json:"originPrice" gorm:"column:originPrice; type: decimal(10, 2); default: 1.00; not null;"`
	SalesNum      uint    `json:"salesNum" gorm:"column:salesNum; default: 0; not null;"`
	Commission    string  `json:"commission" gorm:"column:commission; default: '0%'; not null;"`       // description(Product commission, income=originPrice * commission)
	Specification string  `json:"specification" gorm:"column:specification; default: '默认'; not null;"` // description(Product specification...)
	ProductId     uint64  `json:"productId" gorm:"column:productId; not null;"`
	Status        string  `json:"status" gorm:"column:status; default: 'active'; type: varchar(10); not null;"`
	BaseModel
}

库存清单信息

type OrderForm

type OrderForm struct {
	OrderId       uint64     `json:"orderId" gorm:"column:orderId; primary_key; not null;"`
	OrderNumber   int64      `json:"orderNumber" gorm:"column:orderNumber; not null;"`
	TotalAmount   float64    `json:"totalAmount" gorm:"column:totalAmount; type: decimal(10, 2); default: 1.00; not null;"`
	TotalDiscount float64    `json:"totalDiscount" gorm:"column:totalDiscount; type: decimal(10, 2); default: 0.00; not null;"`
	Remark        string     `json:"remark" gorm:"column:remark; not null;"`
	Invoice       string     `json:"invoice" gorm:"column:invoice; type: ENUM('PAPER', 'ELECTRONIC', 'NONE'); default:'ELECTRONIC'; not null;"`
	Status        string     `` /* 141-byte string literal not displayed */
	OutTradeNo    uint64     `json:"outTradeNo" gorm:"column:outTradeNo; not null;"`
	AddressId     uint64     `json:"addressId" gorm:"column:addressId; not null;"`
	UserId        uint64     `json:"userId" gorm:"column:userId; not null;"`
	Outbounds     []Outbound `json:"outbounds" gorm:"column:outbounds;ForeignKey:orderId;"`
	BaseModel
}

订货单

func (*OrderForm) OrderCancel

func (of *OrderForm) OrderCancel(userId uint64, orderId uint64) error

func (*OrderForm) OrderCompleted

func (of *OrderForm) OrderCompleted(userId uint64, orderId uint64) error

func (*OrderForm) PlaceOrder

func (of *OrderForm) PlaceOrder(dto *PlaceOrderDTO) error

func (*OrderForm) QueryOrderDetails

func (of *OrderForm) QueryOrderDetails(userId uint64, orderId uint64) (*OrderForm, error)

func (*OrderForm) QueryOrders

func (of *OrderForm) QueryOrders(userId uint64, orderType string, pageIndex int) (*[]OrderForm, error)

func (*OrderForm) TableName

func (of *OrderForm) TableName() string

type Outbound

type Outbound struct {
	OutboundId       uint64  `json:"outboundId" gorm:"column:outboundId; primary_key; not null;"`
	OrderId          uint64  `json:"orderId" gorm:"column:orderId; not null;"`
	ProductId        uint64  `json:"productId" gorm:"column:productId; not null;"`
	ProductName      string  `json:"productName" gorm:"column:productName; not null;"`
	ProductPic       string  `json:"productPic" gorm:"column:productPic; not null;"`
	ProductThum      string  `json:"productThum" gorm:"column:productThum; not null;"`
	ProductUnitPrice float64 `json:"productUnitPrice" gorm:"column:productUnitPrice; type: decimal(10, 2); not null;"`
	Discount         float64 `json:"discount" gorm:"column:discount; type: decimal(10, 2); not null;"`
	Count            uint8   `json:"count" gorm:"default:1; not null;"`
	Amount           float64 `json:"amount" gorm:"type: decimal(10, 2); default: 0.00; not null;"`
	Status           string  `json:"status" gorm:"column:status; default: 'active'; not null;"`
	BaseModel
}

type OutboundDTO

type OutboundDTO struct {
	ProductId        uint64  `json:"productId" gorm:"column:productId;"`
	ProductName      string  `json:"productName" gorm:"column:productName;"`
	ProductPic       string  `json:"productPic" gorm:"column:productPic;"`
	ProductThum      string  `json:"productThum" gorm:"column:productThum;"`
	ProductUnitPrice float64 `json:"productUnitPrice" gorm:"column:productUnitPrice; type: decimal(10, 2);"`
	Discount         float64 `json:"discount" gorm:"column:discount; type: decimal(10, 2);"`
	Count            uint8   `json:"count" gorm:"default:1;"`
	Amount           float64 `json:"amount" gorm:"type: decimal(10, 2); default: 0.00;"`
}

type Picture

type Picture struct {
	PictureId   uint64 `json:"pictureId" gorm:"column:pictureId; primary_key; not null;"`
	PictureName string `json:"pictureName" gorm:"column:pictureName; not null;"`
	Priority    uint8  `json:"priority" gorm:"column:priority; default: 0; not null;"`
	Status      string `json:"status" gorm:"column:status; default: 'active'; type: varchar(10); not null;"`
	BaseModel
}

type PlaceOrderDTO

type PlaceOrderDTO struct {
	UserId        uint64        `json:"userId" gorm:"column:userId"`
	AddressId     uint64        `json:"addressId" gorm:"column:addressId"`
	TotalDiscount float64       `json:"totalDiscount" gorm:"totalDiscount; type: decimal(10, 2);"`
	TotalAmount   float64       `json:"totalAmount" gorm:"totalAmount; type: decimal(10, 2);"`
	Invoice       string        `json:"invoice" gorm:"column:invoice;"`
	Remark        string        `json:"remark" gorm:"column:remark"`
	Outbounds     []OutboundDTO `json:"products" gorm:"column:products"`
}

type Product

type Product struct {
	ProductId      uint64      `json:"productId" gorm:"column:productId; primary_key; not null;"`
	ProductName    string      `json:"productName" gorm:"column:productName; not null;"`
	ProductSubName string      `json:"productSubName" gorm:"column:productSubName; not null;"`
	ProductPic     string      `json:"productPic" gorm:"column:productPic; not null;"`
	ProductThum    string      `json:"productThum" gorm:"column:productThum; not null;"`
	ProductDesc    string      `json:"productDesc" gorm:"column:productDesc; not null;"`
	Priority       uint8       `json:"priority" gorm:"default:0; not null;"`
	ProductType    string      `json:"productType" gorm:"column:productType; default: 'normal'; type: enum('recommend', 'normal', 'specific'); not null;"` // description(Here will have 3 types, include 'recommend', 'normal', 'specific')
	Status         string      `json:"status" gorm:"column:status; default: 'active'; type: varchar(10); not null;"`
	Inventories    []Inventory `json:"inventories" gorm:"column: inventories;"`
	BaseModel
}

func (*Product) InsertMultipleProducts

func (prod *Product) InsertMultipleProducts(dtos *[]ProductDTO) error

func (*Product) InsertProduct

func (prod *Product) InsertProduct(dto *ProductDTO) error

func (*Product) QueryInventoryDetails

func (prod *Product) QueryInventoryDetails(inventoryId uint64) (interface{}, error)

func (*Product) QueryProductDetails

func (prod *Product) QueryProductDetails(productId uint64) (interface{}, error)

func (*Product) QueryProductsByProductType

func (prod *Product) QueryProductsByProductType(productType string, pageIndex int) (*[]Product, error)

type ProductDTO

type ProductDTO struct {
	Quantity      uint    `json:"quantity"`
	OriginPrice   float64 `json:"originPrice"`
	Commission    string  `json:"commission"`
	Specification string  `json:"specification"`

	ProductName    string `json:"productName"`
	ProductSubName string `json:"productSubName"`
	ProductPic     string `json:"productPic"`
	ProductThum    string `json:"productThum"`
	ProductDesc    string `json:"productDesc"`
	Priority       uint8  `json:"priority"`
	ProductType    string `json:"productType"`
}

type SMS

type SMS struct {
	UserId        uint64    `json:"userId" gorm:"column:userId; not null;"`
	OperationMode string    `json:"operationMode" gorm:"column:operationMode; not null; type:varchar(10);"`
	SecurityCode  string    `json:"securityCode" gorm:"column:securityCode; type:varchar(6); not null;"`
	Telephone     string    `json:"telephone"`
	ExpiresAt     time.Time `json:"expiresAt" gorm:"column:expiresAt; type:dateTime; not null;"`
	CreatedAt     time.Time `json:"createdAt" gorm:"column:createdAt;type:dateTime"`
}

func (*SMS) ObtainSecurityCode

func (sms *SMS) ObtainSecurityCode(telephone string, userId uint64, operationMode string) (*SMS, error)

func (*SMS) VerifySecurityCode

func (sms *SMS) VerifySecurityCode(telephone string, userId uint64, securityCode string, operationMode string) (bool, error)

type Team

type Team struct {
	TeamId         uint64 `json:"teamId" gorm:"column:teamId; primary_key; not null;"`
	TopLevelAgent  uint64 `json:"topLevelAgent" gorm:"column:topLevelAgent; not null;"`
	SuperiorAgent  uint64 `json:"superiorAgent" gorm:"column:superiorAgent; not null;"`
	Status         string `json:"status" gorm:"column:status; default:'active'; not null;"`
	Channel        string `json:"channel" gorm:"column:channel; default:'Wechat'; not null;"`
	InvitationCode string `json:"invitationCode" gorm:"column:invitationCode; unique; type:varchar(6); not null;"`
	UserId         uint64 `json:"userId" gorm:"column:userId;not null;"`
	BaseModel
}

func (*Team) QueryTeamByInvitationCode

func (team *Team) QueryTeamByInvitationCode(invitationCode string) error

func (*Team) QueryUserTeams

func (team *Team) QueryUserTeams(userId uint64) (*TeamVO, error)

type TeamVO

type TeamVO struct {
	Team              Team `json:"team"`
	SecondAgentsCount uint `json:"secondAgentsCount"`
	ThirdAgentsCount  uint `json:"thirdAgentsCount"`
}

type User

type User struct {
	UserId uint64 `json:"userId" gorm:"column:userId;primary_key;not null"`
	UserProfile
	Role      uint16    `json:"role" gorm:"column:role; default:10; not null;"`
	Status    string    `json:"status" gorm:"column:status; type:varchar(10); default:'active'; not null;"`
	Channel   string    `json:"channel" gorm:"column:channel; type:varchar(12); not null;"`
	Addresses []Address `json:"addresses" gorm:"column:addresses;"`
	BaseModel
}

func (*User) BeforeCreate

func (user *User) BeforeCreate(scope *gorm.Scope) error

callbacks hock -- before create, encrypt password

func (*User) CheckIsUserExistByTelephone

func (user *User) CheckIsUserExistByTelephone(telephone string) (bool, error)

func (*User) CheckIsUserExistByUserId

func (user *User) CheckIsUserExistByUserId(userId uint64) (bool, error)

func (*User) LoginByTelephone

func (user *User) LoginByTelephone(telephone string, password string) error

func (*User) LoginByWechat

func (user *User) LoginByWechat(jsCode string, wechatUserProfile string, invitationCode string) (*UserWechatVO, error)

func (*User) QueryByUserId

func (user *User) QueryByUserId(userId string) *User

func (*User) Register

func (user *User) Register(dto UserRegisterDTO) error

type UserProfile

type UserProfile struct {
	Telephone string `json:"telephone" gorm:"column:telephone; type:varchar(11);not null"`
	Username  string `json:"username" gorm:"column:username; type:varchar(18);not null"`
	Password  string `json:"-" gorm:"column:password; type:varchar(24);null"`
	Nickname  string `json:"nickname" gorm:"column:nickname; type:varchar(16);not null;"`
	Male      bool   `json:"male" gorm:"column:male; not null; default:false;"`
	Signature string `json:"signature" gorm:"not null; default:'This guy is lazy...'"`
}

type UserRegisterDTO

type UserRegisterDTO struct {
	Telephone      string `json:"telephone"`
	Password       string `json:"password"`
	Nickname       string `json:"nickname"`
	InvitationCode string `json:"invitationCode"`
}

type UserWechatVO

type UserWechatVO struct {
	User          *User      `json:"user"`
	WechatSession *WxSession `json:"wechatSession"`
}

type WechatMP

type WechatMP struct {
	// contains filtered or unexported fields
}

type Wuid

type Wuid struct {
	H uint  `gorm:"primary_key; AUTO_INCREMENT; not null;"`
	X uint8 `gorm:"unique_index; default: '0'; not null;"`
}

type WxSession

type WxSession struct {
	SessionId         uint64 `json:"sessionId" gorm:"column:sessionId; not null; primary_key;"`
	Skey              string `json:"skey" gorm:"column:skey; not null;"`
	SessionKey        string `json:"sessionKey" gorm:"column:sessionKey; not null;" `
	WechatUserProfile string `json:"wechatUserProfile" gorm:"column:wechatUserProfile; not null;"`
	OpenId            string `json:"openId" gorm:"column:openId; index; not null;"`
	UserId            uint64 `json:"userId" gorm:"column:userId; not null;"`
	BaseModel
}

func (WxSession) TableName

func (WxSession) TableName() string

Jump to

Keyboard shortcuts

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