package dao import ( "github.com/gin-gonic/gin" "github.com/jmoiron/sqlx" bannerproto "service/api/proto/banner/proto" catalogproto "service/api/proto/catalog/proto" productproto "service/api/proto/product/proto" "service/app/mix/conf" "service/dbstruct" "service/library/logger" ) type IStore interface { // 商品 CreateProduct(ctx *gin.Context, product *dbstruct.Product) error UpdateProduct(ctx *gin.Context, product *dbstruct.Product) error DeleteProduct(ctx *gin.Context, id int64) error GetProductList(ctx *gin.Context, req *productproto.OpListReq) ([]*dbstruct.Product, error) GetProductById(ctx *gin.Context, id string) (*dbstruct.Product, error) // 分类 CreateCatalog(ctx *gin.Context, catalog *dbstruct.Catalog) error UpdateCatalog(ctx *gin.Context, catalog *dbstruct.Catalog) error DeleteCatalog(ctx *gin.Context, id int64) error GetCatalogList(ctx *gin.Context, req *catalogproto.OpListReq) ([]*dbstruct.Catalog, error) GetCatalogListByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.Catalog, error) // banner CreateBanner(ctx *gin.Context, banner *dbstruct.Banner) error UpdateBanner(ctx *gin.Context, banner *dbstruct.Banner) error DeleteBanner(ctx *gin.Context, id int64) error GetBannerList(ctx *gin.Context, req *bannerproto.OpListReq) ([]*dbstruct.Banner, error) GetBannerListByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.Banner, error) // resource SetL2CatalogIndex(ctx *gin.Context, list []*dbstruct.L2CatalogIndex) error GetL2CatalogIndex(ctx *gin.Context, l1Id int64) ([]*dbstruct.L2CatalogIndex, error) SetBannerIndex(ctx *gin.Context, list []*dbstruct.BannerIndex) error GetBannerIndex(ctx *gin.Context) ([]*dbstruct.BannerIndex, error) // image SaveImage(ctx *gin.Context, image *dbstruct.Image) error SaveVideo(ctx *gin.Context, video *dbstruct.Video) error // video // vas CreateOrder(ctx *gin.Context, tx *sqlx.Tx, order *dbstruct.Order) error } type Store struct { *Mongo *Mysql } func NewStore(cfg *conf.ConfigSt) (store *Store, err error) { mongo, err := NewMongo(cfg) if err != nil { logger.Error("NewMongo fail, err: %v", err) return } mysql, err := NewMysql(cfg) if err != nil { logger.Error("NewMysql fail, err: %v", err) return } store = &Store{ Mongo: mongo, Mysql: mysql, } return }