|
@@ -1,7 +1,9 @@
|
|
package dao
|
|
package dao
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "errors"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/sirupsen/logrus"
|
|
|
|
+ "gorm.io/gorm"
|
|
"youngee_b_api/app/entity"
|
|
"youngee_b_api/app/entity"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -25,6 +27,20 @@ func (d ProductPhotoDAO) GetProductPhotoByProductID(productId int64) ([]entity.P
|
|
return productPhotos, nil
|
|
return productPhotos, nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 获取所属商品的主图详情
|
|
|
|
+func (d ProductPhotoDAO) GetMainProductPhotoInfoByProductID(productId int64) (*entity.ProductPhoto, error) {
|
|
|
|
+ var productPhoto entity.ProductPhoto
|
|
|
|
+ err := Db.Where("product_id = ? AND symbol = ?", productId, 1).First(&productPhoto).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
+ return nil, nil
|
|
|
|
+ } else {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return &productPhoto, nil
|
|
|
|
+}
|
|
|
|
+
|
|
// 获取所属商品的主图
|
|
// 获取所属商品的主图
|
|
func (d ProductPhotoDAO) GetMainPhotoByProductID(productId int64) (string, error) {
|
|
func (d ProductPhotoDAO) GetMainPhotoByProductID(productId int64) (string, error) {
|
|
var productPhoto entity.ProductPhoto
|
|
var productPhoto entity.ProductPhoto
|