|
@@ -187,10 +187,10 @@ func (this *ProductController) AddProduct() {
|
|
|
} else {
|
|
|
var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
|
index := rnd.Intn(len(imageList))
|
|
|
- product.CoverSrc = imageList[index].SrcUrl
|
|
|
+ product.CoverSrc = imageList[index].Id
|
|
|
}
|
|
|
} else {
|
|
|
- product.CoverSrc = req.CoverSrc
|
|
|
+ product.CoverUrl = req.CoverSrc
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -495,13 +495,21 @@ func (this *ProductController) ProductList() {
|
|
|
PublishedTime: product.CreatedTime.Format(time.DateTime),
|
|
|
Price: fmt.Sprintf("¥%s", product.Price),
|
|
|
SaleStatus: CNSaleStatusMap[product.SaleStatus],
|
|
|
- CoverSrc: product.CoverSrc,
|
|
|
+ CoverSrc: product.CoverUrl,
|
|
|
ValidDays: product.ValidDays,
|
|
|
Creator: product.Creator,
|
|
|
IsPermanent: product.IsPermanent,
|
|
|
Description: product.Description,
|
|
|
SourceId: product.SourceId,
|
|
|
}
|
|
|
+ if product.CoverUrl == "" && product.CoverSrc > 0 {
|
|
|
+ image, imageErr := models.GetImageById(product.CoverSrc)
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Warn("获取图片资源失败,err:%s,imageId:%d", imageErr, product.CoverSrc)
|
|
|
+ } else {
|
|
|
+ view.CoverSrc = image.SrcUrl
|
|
|
+ }
|
|
|
+ }
|
|
|
if !product.UpdatedTime.IsZero() {
|
|
|
view.UpdatedTime = product.UpdatedTime.Format(time.DateTime)
|
|
|
}
|
|
@@ -602,10 +610,10 @@ func (this *ProductController) EditProduct() {
|
|
|
} else {
|
|
|
var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
|
index := rnd.Intn(len(imageList))
|
|
|
- product.CoverSrc = imageList[index].SrcUrl
|
|
|
+ product.CoverSrc = imageList[index].Id
|
|
|
}
|
|
|
} else {
|
|
|
- product.CoverSrc = req.CoverSrc
|
|
|
+ product.CoverUrl = req.CoverSrc
|
|
|
}
|
|
|
|
|
|
}
|