|
@@ -119,13 +119,13 @@ func (this *ProductController) UnSetProductList() {
|
|
|
defer wg.Done()
|
|
|
switch product.ProductType {
|
|
|
case "report":
|
|
|
- product.RiskLevel, _, _ = services.GetRiskLevel("report", product.SourceId)
|
|
|
+ product.RiskLevel, _, product.PermissionNames, _ = services.GetRiskLevel("report", product.SourceId)
|
|
|
product.ProductType = "报告"
|
|
|
case "video":
|
|
|
- product.RiskLevel, _, _ = services.GetRiskLevel("media", product.SourceId)
|
|
|
+ product.RiskLevel, _, product.PermissionNames, _ = services.GetRiskLevel("media", product.SourceId)
|
|
|
product.ProductType = "视频"
|
|
|
case "audio":
|
|
|
- product.RiskLevel, _, _ = services.GetRiskLevel("media", product.SourceId)
|
|
|
+ product.RiskLevel, _, product.PermissionNames, _ = services.GetRiskLevel("media", product.SourceId)
|
|
|
product.ProductType = "音频"
|
|
|
}
|
|
|
}(product)
|
|
@@ -198,16 +198,16 @@ func (this *ProductController) AddProduct() {
|
|
|
}
|
|
|
switch req.Type {
|
|
|
case "report":
|
|
|
- _, product.Title, err = services.GetRiskLevel("report", req.SourceId)
|
|
|
+ _, product.Title, _, err = services.GetRiskLevel("report", req.SourceId)
|
|
|
product.IsPermanent = true
|
|
|
case "audio":
|
|
|
- _, product.Title, err = services.GetRiskLevel("audio", req.SourceId)
|
|
|
+ _, product.Title, _, err = services.GetRiskLevel("audio", req.SourceId)
|
|
|
product.IsPermanent = true
|
|
|
case "video":
|
|
|
- _, product.Title, err = services.GetRiskLevel("video", req.SourceId)
|
|
|
+ _, product.Title, _, err = services.GetRiskLevel("video", req.SourceId)
|
|
|
product.IsPermanent = true
|
|
|
case "package":
|
|
|
- _, permissionName, err = services.GetRiskLevel("package", req.SourceId)
|
|
|
+ _, permissionName, _, err = services.GetRiskLevel("package", req.SourceId)
|
|
|
default:
|
|
|
br.Msg = "产品类型错误"
|
|
|
br.ErrMsg = "获取产品列表失败,Err:产品类型错误"
|
|
@@ -489,34 +489,42 @@ func (this *ProductController) ProductList() {
|
|
|
return
|
|
|
}
|
|
|
var ListView []*services.ProductView
|
|
|
+ var wg sync.WaitGroup
|
|
|
+ wg.Add(len(List))
|
|
|
for _, product := range List {
|
|
|
- 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
|
|
|
+ go func(product *models.MerchantProduct) {
|
|
|
+ defer 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,
|
|
|
}
|
|
|
- }
|
|
|
- if !product.UpdatedTime.IsZero() {
|
|
|
- view.UpdatedTime = product.UpdatedTime.Format(time.DateTime)
|
|
|
- }
|
|
|
- ListView = append(ListView, view)
|
|
|
+ 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.RiskLevel, _, _, _ = services.GetRiskLevel(string(product.Type), product.Id)
|
|
|
+ ListView = append(ListView, view)
|
|
|
+ }(product)
|
|
|
+
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
resp := new(response.ProductListResp)
|
|
|
resp.List = ListView
|
|
@@ -551,7 +559,7 @@ func (this *ProductController) ProductRisk() {
|
|
|
br.ErrMsg = "无效的产品ID:" + strconv.Itoa(SourceId)
|
|
|
return
|
|
|
}
|
|
|
- riskLevel, _, err := services.GetRiskLevel(ProductType, SourceId)
|
|
|
+ riskLevel, _, _, err := services.GetRiskLevel(ProductType, SourceId)
|
|
|
if err != nil {
|
|
|
utils.FileLog.Error("查询产品风险等级失败", err.Error)
|
|
|
return
|
|
@@ -623,13 +631,13 @@ func (this *ProductController) EditProduct() {
|
|
|
}
|
|
|
switch req.Type {
|
|
|
case "report":
|
|
|
- _, product.Title, err = services.GetRiskLevel("report", req.SourceId)
|
|
|
+ _, product.Title, _, err = services.GetRiskLevel("report", req.SourceId)
|
|
|
case "audio":
|
|
|
- _, product.Title, err = services.GetRiskLevel("audio", req.SourceId)
|
|
|
+ _, product.Title, _, err = services.GetRiskLevel("audio", req.SourceId)
|
|
|
case "video":
|
|
|
- _, product.Title, err = services.GetRiskLevel("video", req.SourceId)
|
|
|
+ _, product.Title, _, err = services.GetRiskLevel("video", req.SourceId)
|
|
|
case "package":
|
|
|
- _, _, err = services.GetRiskLevel("package", req.SourceId)
|
|
|
+ _, _, _, err = services.GetRiskLevel("package", req.SourceId)
|
|
|
default:
|
|
|
br.Msg = "产品类型错误"
|
|
|
br.ErrMsg = "获取产品列表失败,Err:产品类型错误"
|