47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package biz
|
|
|
|
import (
|
|
"context"
|
|
"geo/internal/data/impl"
|
|
"geo/internal/data/model"
|
|
"geo/internal/entitys"
|
|
|
|
"github.com/go-viper/mapstructure/v2"
|
|
)
|
|
|
|
type ProductBiz struct {
|
|
productImpl *impl.ProductImpl
|
|
productSourceImpl *impl.ProductSourceImpl
|
|
}
|
|
|
|
func NewProductBiz(productImpl *impl.ProductImpl, productSourceImpl *impl.ProductSourceImpl) *ProductBiz {
|
|
return &ProductBiz{
|
|
productImpl: productImpl,
|
|
productSourceImpl: productSourceImpl,
|
|
}
|
|
}
|
|
|
|
func (p *ProductBiz) GetBrandInfo(ctx context.Context, productId int32) (*entitys.BrandInfo, error) {
|
|
var product model.Product
|
|
err := p.productImpl.GetByKey(ctx, p.productImpl.PrimaryKey(), productId, &product)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var BrandInfo entitys.BrandInfo
|
|
err = mapstructure.Decode(product, &BrandInfo)
|
|
|
|
return &BrandInfo, err
|
|
}
|
|
|
|
func (p *ProductBiz) CreateAndUploadArticle(ctx context.Context, content string) error {
|
|
//var product model.Product
|
|
//err := p.productImpl.GetByKey(ctx, p.productImpl.PrimaryKey(), productId, &product)
|
|
//if err != nil {
|
|
// return nil, err
|
|
//}
|
|
//var BrandInfo entitys.BrandInfo
|
|
//err = mapstructure.Decode(product, &BrandInfo)
|
|
|
|
return nil
|
|
}
|