|
@@ -488,46 +488,36 @@ func (this *ProductController) ProductList() {
|
|
|
return
|
|
|
}
|
|
|
var ListView []*services.ProductView
|
|
|
- var wg sync.WaitGroup
|
|
|
- wg.Add(len(List))
|
|
|
for _, product := range List {
|
|
|
- go func(product *models.MerchantProduct) {
|
|
|
- defer func() {
|
|
|
- wg.Done()
|
|
|
- }()
|
|
|
- view := &services.ProductView{
|
|
|
- Id: product.Id,
|
|
|
- ProductName: product.Title,
|
|
|
- ProductType: CNProductMap[product.Type],
|
|
|
- PublishedTime: product.CreatedTime.Format(time.DateTime),
|
|
|
- Price: fmt.Sprintf("¥%s", product.Price),
|
|
|
- SaleStatus: CNSaleStatusMap[product.SaleStatus],
|
|
|
- CoverSrc: product.CoverUrl,
|
|
|
- ValidDays: product.ValidDays,
|
|
|
- Creator: product.Creator,
|
|
|
- IsPermanent: product.IsPermanent,
|
|
|
- Description: product.Description,
|
|
|
- SourceId: product.SourceId,
|
|
|
- CreatedTime: product.CreatedTime.Format(time.DateTime),
|
|
|
- }
|
|
|
- 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)
|
|
|
+ view := &services.ProductView{
|
|
|
+ Id: product.Id,
|
|
|
+ ProductName: product.Title,
|
|
|
+ ProductType: CNProductMap[product.Type],
|
|
|
+ PublishedTime: product.CreatedTime.Format(time.DateTime),
|
|
|
+ Price: fmt.Sprintf("¥%s", product.Price),
|
|
|
+ SaleStatus: CNSaleStatusMap[product.SaleStatus],
|
|
|
+ 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
|
|
|
}
|
|
|
- view.RiskLevel, _, _, _ = services.GetRiskLevel(string(product.Type), product.SourceId)
|
|
|
-
|
|
|
- ListView = append(ListView, view)
|
|
|
- }(product)
|
|
|
+ }
|
|
|
+ if !product.UpdatedTime.IsZero() {
|
|
|
+ view.UpdatedTime = product.UpdatedTime.Format(time.DateTime)
|
|
|
+ }
|
|
|
+ view.RiskLevel, _, _, _ = services.GetRiskLevel(string(product.Type), product.SourceId)
|
|
|
|
|
|
+ ListView = append(ListView, view)
|
|
|
}
|
|
|
- wg.Wait()
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
resp := new(response.ProductListResp)
|
|
|
resp.List = ListView
|