model

package
v0.0.0-...-93b8502 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DB

func DB() *gorm.DB

func Goods2xlsx

func Goods2xlsx()

Types

type AdminUsers

type AdminUsers struct {
	BaseModel
	IsAdmin     int8                  `gorm:"column:is_admin;type:tinyint(1);not null;default:0" json:"is_admin"`                                   // 是否是总管理员
	Nickname    string                `gorm:"column:nickname;type:varchar(60);not null;default:''" json:"nickname"`                                 // 用户昵称
	Username    string                `gorm:"uniqueIndex:a_u_username_unique;column:username;type:varchar(60);not null;default:''" json:"username"` // 用户名
	Password    string                `gorm:"column:password;type:varchar(255);not null;default:''" json:"password"`                                // 密码
	Mobile      string                `gorm:"uniqueIndex:a_u_mobile_unique;column:mobile;type:varchar(15);not null;default:''" json:"mobile"`       // 手机号
	Email       string                `gorm:"column:email;type:varchar(120);not null;default:''" json:"email"`                                      // 邮箱
	Avatar      string                `gorm:"column:avatar;type:varchar(160);not null;default:''" json:"avatar"`                                    // 头像
	Status      bool                  `gorm:"column:status;type:tinyint(1);not null;default:0" json:"status"`                                       // 状态,0正常,1禁用
	LoginAt     utils.FormatDate      `gorm:"column:login_at;type:timestamp;default:null" json:"login_at"`                                          // 登录时间
	LoginIP     string                `gorm:"column:login_ip;type:varchar(15);not null;default:''" json:"login_ip"`                                 // 最后一次登录ip
	LastLoginAt utils.FormatDate      `gorm:"column:last_login_at;type:timestamp;default:null" json:"last_login_at"`                                // 上一次登录时间
	LastLoginIP string                `gorm:"column:last_login_ip;type:varchar(15);not null;default:''" json:"last_login_ip"`                       // 上一次登录ip
	DeletedAt   soft_delete.DeletedAt ``                                                                                                            // 删除时间戳
	/* 142-byte string literal not displayed */
}

AdminUsers 总管理员表

func NewAdminUsers

func NewAdminUsers() *AdminUsers

func (*AdminUsers) ChangePassword

func (u *AdminUsers) ChangePassword() error

ChangePassword 修改密码

func (*AdminUsers) ComparePasswords

func (u *AdminUsers) ComparePasswords(password string) bool

ComparePasswords 比对用户密码是否正确

func (*AdminUsers) GetUserById

func (u *AdminUsers) GetUserById(id uint) *AdminUsers

GetUserById 根据uid获取用户信息

func (*AdminUsers) GetUserInfo

func (u *AdminUsers) GetUserInfo(username string) *AdminUsers

GetUserInfo 根据名称获取用户信息

func (*AdminUsers) PasswordHash

func (u *AdminUsers) PasswordHash(pwd string) (string, error)

PasswordHash 密码hash并自动加盐

func (*AdminUsers) Register

func (u *AdminUsers) Register() error

Register 用户注册,写入到DB

type BaseModel

type BaseModel struct {
	ID        uint             `gorm:"column:id;type:int(11) unsigned AUTO_INCREMENT;not null;primarykey" json:"id"`
	CreatedAt utils.FormatDate `gorm:"column:created_at;type:timestamp;<-:create" json:"created_at"`
	UpdatedAt utils.FormatDate `gorm:"column:updated_at;type:timestamp" json:"updated_at"`
}

func (*BaseModel) DB

func (model *BaseModel) DB() *gorm.DB

type ContainsDeleteBaseModel

type ContainsDeleteBaseModel struct {
	BaseModel
	DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at;type:int(11) unsigned;not null;default:0;index" json:"-"`
}

type GoodBean

type GoodBean struct {
	ID        uint   `json:"id"`
	Position  uint   `json:"position"` //在列表中的位置
	GoodsName string `json:"goodsName"`
	Barcode   string `json:"barcode"`
	Price     string `json:"price"`
	Brand     string `json:"brand"`
	Supplier  string `json:"supplier"`
	Standard  string `json:"standard"`
	Spec      string `json:"spec"`
}

type Goods

type Goods struct {
	BaseModel
	GoodsName string `gorm:"column:goods_name" json:"goodsName"`
	Barcode   string `gorm:"column:barcode" json:"barcode"`
	Brand     string `gorm:"column:brand" json:"brand"`
	Price     string `gorm:"column:price" json:"price"`
	Spec      string `gorm:"column:spec" json:"spec"`
	Supplier  string `gorm:"column:supplier" json:"supplier"`
}

func NewGoods

func NewGoods() *Goods

func NewGoodsEx

func NewGoodsEx(GoodsName, Barcode, Brand, Price, Spec, Supplier string) *Goods

func (*Goods) Destory

func (g *Goods) Destory() error

删除商品信息

func (*Goods) GetGoods

func (g *Goods) GetGoods(barcode string) *Goods

GetUserInfo 根据barcode获取商品信息

func (*Goods) GetGoodsList

func (u *Goods) GetGoodsList(p *dto.Page) (list []*Goods, err error)

func (*Goods) Register

func (g *Goods) Register() error

注册商品信息

func (Goods) TableName

func (Goods) TableName() string

func (*Goods) Update

func (g *Goods) Update() error

更新商品信息

func (*Goods) UpdatePrice

func (g *Goods) UpdatePrice(price string) error

更新商品信息

type Orders

type Orders struct {
	BaseModel
	Money string `gorm:"column:money" json:"money"`
	Count uint   `gorm:"column:count" json:"count"`
}

func NewOrders

func NewOrders() *Orders

func (*Orders) Create

func (g *Orders) Create(req *dto.OrdersDto) (err error)

创建订单信息

func (*Orders) Destory

func (g *Orders) Destory() error

删除订单信息

func (*Orders) List

func (u *Orders) List(p *dto.OrdersDto) (list []*Orders, err error)

func (Orders) TableName

func (Orders) TableName() string

func (*Orders) Update

func (g *Orders) Update() error

更新订单 信息

type OrdersDetail

type OrdersDetail struct {
	BaseModel
	OrdersID  uint   `gorm:"column:orders_id" json:"ordersID"` // 订单ID
	GoodsID   uint   `gorm:"column:goods_id" json:"goodsID"`   // 商品ID
	GoodsName string `gorm:"column:goods_name" json:"goodsName"`
	Barcode   string `gorm:"column:barcode" json:"barcode"`
	Brand     string `gorm:"column:brand" json:"brand"`
	Price     string `gorm:"column:price" json:"price"`
	Spec      string `gorm:"column:spec" json:"spec"`
	Count     uint   `gorm:"column:count" json:"count"` //商品计数
}

func (*OrdersDetail) Detail

func (g *OrdersDetail) Detail(id uint) *OrdersDetail

根据id获取订单详细信息

func (OrdersDetail) TableName

func (OrdersDetail) TableName() string

Jump to

Keyboard shortcuts

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