新增系统商品
This commit is contained in:
+26
-2
@@ -9,8 +9,8 @@ import (
|
||||
type ProductService struct {
|
||||
}
|
||||
|
||||
// GetPlatformProduct 平台商品详情
|
||||
func (r *ProductService) GetPlatformProduct(productPlatformId int64) (g *dto.ProductPlatformDto, err error) {
|
||||
// GetProductPlatform 平台商品详情
|
||||
func (r *ProductService) GetProductPlatform(productPlatformId int64) (g *dto.ProductPlatformDto, err error) {
|
||||
// 获取平台商品数据
|
||||
productPlatformDao := dao.ProductPlatformDao{}
|
||||
productPlatform, err := productPlatformDao.GetProductPlatformById(productPlatformId)
|
||||
@@ -23,3 +23,27 @@ func (r *ProductService) GetPlatformProduct(productPlatformId int64) (g *dto.Pro
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// GetProduct 商品详情
|
||||
func (r *ProductService) GetProduct(productId int64) (g *dto.ProductDto, err error) {
|
||||
// 获取商品数据
|
||||
productDao := dao.ProductDao{}
|
||||
product, err := productDao.GetProductById(productId)
|
||||
if err != nil || product == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取商品库存数据
|
||||
productPlatformAmountDao := dao.ProductPlatformAmountDao{}
|
||||
productPlatformAmount, err := productPlatformAmountDao.GetProductPlatformAmountByProductPlatformId(product.ProductPlatformId)
|
||||
|
||||
// 处理返回值
|
||||
g = dto.GetProductDto(product)
|
||||
|
||||
if productPlatformAmount != nil {
|
||||
// 加载库存
|
||||
g.LoadProductAmount(productPlatformAmount)
|
||||
}
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user