Ver código fonte

增加系统配置接口

kobe6258 4 meses atrás
pai
commit
b0c0eb352d
2 arquivos alterados com 26 adições e 37 exclusões
  1. 26 36
      controllers/product.go
  2. 0 1
      services/product.go

+ 26 - 36
controllers/product.go

@@ -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

+ 0 - 1
services/product.go

@@ -175,7 +175,6 @@ type ProductView struct {
 	SaleStatus      string
 	Creator         string
 	Description     string
-	CreatedTime     string
 }
 
 func GetRiskLevel(productType string, id int) (riskLevel string, productName string, permissionName string, err error) {