dao

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound = errors.New("该记录不存在")
)

Functions

func InitTable

func InitTable(db *gorm.DB)

Types

type BrandCategorys

type BrandCategorys struct {
	Id         int32 `gorm:"column:id;primaryKey;autoIncrement;not null"`
	BrandId    int32 `gorm:"column:brand_id;uniqueIndex:idx_brand_category;not null"`
	CategoryId int32 `gorm:"column:category_id;uniqueIndex:idx_brand_category;not null"`
	Uid        int32 `gorm:"column:uid;not null"`
	CreateAt   int64 `gorm:"column:create_at"`
	UpdateAt   int64 `gorm:"column:update_at"`
	DeleteAt   int64 `gorm:"column:delete_at"`
}

type Brands

type Brands struct {
	Id       int32  `gorm:"column:id;primaryKey;autoIncrement;not null"`
	Name     string `gorm:"column:name;type:varchar(30);unique;not null"`
	Uid      int32  `gorm:"column:uid;not null"`
	CreateAt int64  `gorm:"column:create_at"`
	UpdateAt int64  `gorm:"column:update_at"`
	DeleteAt int64  `gorm:"column:delete_at"`
}

type Categorys

type Categorys struct {
	Id       int32         `gorm:"column:id;primaryKey;autoIncrement;not null"`
	Name     string        `gorm:"column:name;type:varchar(30);not null"`
	Level    int           `gorm:"column:level;type:int;index;not null;default:1;comment:'1代表一级分类, 2代表二级分类, 3代表三级分类'"`
	ParentId sql.NullInt32 `gorm:"column:parentId;default:0;not null"`
	RootId   sql.NullInt32 `gorm:"column:root_id;default:0;index;not null"`
	Uid      int32         `gorm:"column:uid;not null"`
	CreateAt int64         `gorm:"column:create_at"`
	UpdateAt int64         `gorm:"column:update_at"`
	DeleteAt int64         `gorm:"column:delete_at"`
}

type ImageList

type ImageList []string

func (*ImageList) Scan

func (i *ImageList) Scan(value interface{}) error

func (ImageList) Value

func (i ImageList) Value() (driver.Value, error)

type Product

type Product interface {
	UpsertProduct(ctx context.Context, p Products) (Products, error)
	DeleteProduct(ctx context.Context, id, uid int32) error
	QueryProductInfoById(ctx context.Context, id int32) (Products, error)
	QueryProductList(ctx context.Context, p Products, pNum, pSize int32) ([]Products, error)
	AddClick(ctx context.Context, id, uid int32) error
	AddFavorite(ctx context.Context, id, uid int32) error
	GetProductBySn(ctx context.Context, sn string) error
	QueryCategoryList(ctx context.Context, num, size int32) ([]Categorys, error)
	QueryCategoryById(ctx context.Context, id int32) (Categorys, error)
	QueryCategoryByName(ctx context.Context, name string) (Categorys, error)
	InsertCategory(ctx context.Context, c Categorys) (Categorys, error)
	UpdateCategory(ctx context.Context, c Categorys) error
	DeleteCategory(ctx context.Context, id, uid int32) error
	QueryBrandById(ctx context.Context, id int32) (Brands, error)
	QueryBrandByName(ctx context.Context, name string) (Brands, error)
	InsertBrand(ctx context.Context, c Brands) (Brands, error)
	UpdateBrand(ctx context.Context, c Brands) error
	DeleteBrand(ctx context.Context, id, uid int32) error
	QueryBrandList(ctx context.Context, num, size int32) ([]Brands, error)
	QueryBrandByUid(ctx context.Context, uid int32) ([]Brands, error)
	BatchProductsByIds(ctx context.Context, ids []int32) ([]Products, error)
}

func NewProductDao

func NewProductDao(db *gorm.DB, logger *zap.Logger) Product

type ProductRecord

type ProductRecord struct {
	Id        int32 `gorm:"column:id;primaryKey;autoIncrement;not null"`
	ProductId int32 `gorm:"column:product_id;uniqueIndex:idx_prod_u;index;not null"`
	Uid       int32 `gorm:"column:uid;uniqueIndex:idx_prod_u;index;not null"`
	Like      bool  `gorm:"column:like;not null"`
	Look      bool  `gorm:"column:look;not null"`
	CreateAt  int64 `gorm:"column:create_at"`
	UpdateAt  int64 `gorm:"column:update_at"`
	DeleteAt  int64 `gorm:"column:delete_at"`
}

type Products

type Products struct {
	Id          int32     `gorm:"column:id;primaryKey;autoIncrement;not null"`
	Name        string    `gorm:"column:name;type:varchar(30);not null"`
	CategoryId  int32     `gorm:"column:category_id;not null"`
	BrandId     int32     `gorm:"column:brand_id;not null"`
	Description string    `gorm:"column:description;type:varchar(255);not null"`
	Sn          string    `gorm:"column:sn;unique;type:varchar(255);not null"`
	Uid         int32     `gorm:"column:uid;not null"`
	IsNew       bool      `gorm:"column:is_new;not null"`
	IsHot       bool      `gorm:"column:is_hot;not null"`
	OnSale      bool      `gorm:"column:on_sale;not null"`
	Click       int32     `gorm:"column:click;default:0;not null"`
	Sale        int32     `gorm:"column:sale;default:0;not null"`
	Favorite    int32     `gorm:"column:favorite;default:0;not null"`
	MarkPrice   float32   `gorm:"column:mark_price;not null"`
	ShopPrice   float32   `gorm:"column:shop_price;not null"`
	Picture     string    `gorm:"column:picture;not null"`
	Images      ImageList `gorm:"column:images;not null"`
	CreateAt    int64     `gorm:"column:create_at"`
	UpdateAt    int64     `gorm:"column:update_at"`
	DeleteAt    int64     `gorm:"column:delete_at"`
}

Jump to

Keyboard shortcuts

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