You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
487 B
Go
24 lines
487 B
Go
package service
|
|
|
|
import (
|
|
e "errors"
|
|
"gold-shop/errors"
|
|
"gold-shop/global"
|
|
"gold-shop/model"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var ProductService = productService{}
|
|
|
|
type productService struct {
|
|
}
|
|
|
|
func (productService) GetProductInfo(productID int) (*model.Product, error) {
|
|
product := &model.Product{}
|
|
err := global.DB.Where("product_id", productID).First(product).Error
|
|
if e.Is(err, gorm.ErrRecordNotFound) {
|
|
return nil, errors.NewBusinessError("商品不存在")
|
|
}
|
|
return product, nil
|
|
}
|