|
@@ -7,39 +7,40 @@ import (
|
|
|
merchantService "eta/eta_mini_ht_api/domian/merchant"
|
|
|
reportDomain "eta/eta_mini_ht_api/domian/report"
|
|
|
"eta/eta_mini_ht_api/models/config"
|
|
|
+ "eta/eta_mini_ht_api/models/image"
|
|
|
"eta/eta_mini_ht_api/models/media"
|
|
|
configService "eta/eta_mini_ht_api/service/config"
|
|
|
mediaService "eta/eta_mini_ht_api/service/media"
|
|
|
"eta/eta_mini_ht_api/service/order"
|
|
|
reportService "eta/eta_mini_ht_api/service/report"
|
|
|
"fmt"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type ProductDTO struct {
|
|
|
- Title string `json:"title"`
|
|
|
- SourceTile string `json:"sourceTile"`
|
|
|
- Abstract string `json:"abstract"`
|
|
|
- Src string `json:"src"`
|
|
|
- PermissionNames string `json:"permissionNames"`
|
|
|
- Description string `json:"description"`
|
|
|
- Price string `json:"price"`
|
|
|
- CoverSrc string `json:"coverSrc"`
|
|
|
- RiskLevel string `json:"riskLevel"`
|
|
|
- Type string `json:"type"`
|
|
|
- BeginDate string `json:"beginDate"`
|
|
|
- EndDate string `json:"endDate"`
|
|
|
- SourceId int `json:"sourceId"`
|
|
|
- ReportId int `json:"reportId"`
|
|
|
- MediaId int `json:"mediaId"`
|
|
|
+ Title string `json:"title"`
|
|
|
+ SourceTile string `json:"sourceTile"`
|
|
|
+ Abstract string `json:"abstract"`
|
|
|
+ Src string `json:"src"`
|
|
|
+ PermissionNames []string `json:"permissionNames"`
|
|
|
+ Description string `json:"description"`
|
|
|
+ Price string `json:"price"`
|
|
|
+ CoverSrc int `json:"coverSrc"`
|
|
|
+ CoverUrl string `json:"coverUrl"`
|
|
|
+ RiskLevel string `json:"riskLevel"`
|
|
|
+ Type string `json:"type"`
|
|
|
+ BeginDate string `json:"beginDate"`
|
|
|
+ EndDate string `json:"endDate"`
|
|
|
+ SourceId int `json:"sourceId"`
|
|
|
+ ReportId int `json:"reportId"`
|
|
|
+ MediaId int `json:"mediaId"`
|
|
|
}
|
|
|
|
|
|
-func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel, sourceTitle, sourceAbsract, sourceSrc, permissionNames string, err error) {
|
|
|
+func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel, sourceTitle, sourceAbsract, coverSrc, sourceSrc string, permissionNames []string, err error) {
|
|
|
switch product.Type {
|
|
|
case "package":
|
|
|
permissionRisk, permissionErr := config.PermissionsByPermissionId(product.SourceId)
|
|
|
- permissionNames = permissionRisk.Name
|
|
|
+ permissionNames = []string{permissionRisk.Name}
|
|
|
if permissionErr != nil {
|
|
|
logger.Error("获取权限信息失败[permissionId:%d]", product.SourceId)
|
|
|
} else {
|
|
@@ -47,7 +48,7 @@ func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel,
|
|
|
}
|
|
|
case "audio", "video":
|
|
|
mediaInfo, mediaErr := media.GetMediaById(product.Type, product.SourceId)
|
|
|
- sourceTitle, sourceSrc = mediaInfo.MediaName, mediaInfo.Src
|
|
|
+ sourceTitle, coverSrc, sourceSrc = mediaInfo.MediaName, mediaInfo.CoverSrc, mediaInfo.Src
|
|
|
if mediaErr != nil {
|
|
|
logger.Error("获取媒体信息失败[mediaType:%s,mediaId:%d]", product.Type, product.SourceId)
|
|
|
}
|
|
@@ -59,14 +60,24 @@ func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel,
|
|
|
if permissionErr != nil {
|
|
|
logger.Error("获取权限信息失败[permissionIds:%v]", permissionIds)
|
|
|
}
|
|
|
- permissionNamesList := mediaService.GetMediaPermissionNames(permissionIds)
|
|
|
- permissionNames = strings.Join(permissionNamesList, ",")
|
|
|
+ permissionNames = mediaService.GetMediaPermissionNames(permissionIds)
|
|
|
+ //permissionNames = strings.Join(permissionNamesList, ",")
|
|
|
riskNum := configService.GetHighestRiskLevel(permissions)
|
|
|
riskLevel = fmt.Sprintf("R%d", riskNum)
|
|
|
}
|
|
|
case "report":
|
|
|
report, reportErr := reportDomain.GetReportById(product.SourceId)
|
|
|
- sourceAbsract, sourceTitle = report.Abstract, report.Title
|
|
|
+ var coverSrcId int
|
|
|
+ sourceAbsract, sourceTitle, coverSrcId = report.Abstract, report.Title, report.CoverSrc
|
|
|
+ if coverSrcId > 0 {
|
|
|
+ var imageSrc string
|
|
|
+ imageSrc, coverSrcErr := image.GetImageSrc(coverSrcId)
|
|
|
+ if coverSrcErr != nil {
|
|
|
+ logger.Error("获取图片资源失败:%v,资源ID:%d", err, coverSrcId)
|
|
|
+ } else {
|
|
|
+ coverSrc = imageSrc
|
|
|
+ }
|
|
|
+ }
|
|
|
if reportErr != nil {
|
|
|
logger.Error("获取研报信息失败[reportId:%d]", product.SourceId)
|
|
|
} else {
|
|
@@ -87,9 +98,8 @@ func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel,
|
|
|
riskLevel = fmt.Sprintf("R%d", riskNum)
|
|
|
}
|
|
|
}
|
|
|
- var permissionNamesList []string
|
|
|
- _, permissionNamesList = reportService.GetReportPermissionNames(report.OrgId, report.Source)
|
|
|
- permissionNames = strings.Join(permissionNamesList, ",")
|
|
|
+ _, permissionNames = reportService.GetReportPermissionNames(report.OrgId, report.Source)
|
|
|
+ //permissionNames = strings.Join(permissionNamesList, ",")
|
|
|
}
|
|
|
default:
|
|
|
logger.Warn("不支持的产品类型[%s]", product.Type)
|
|
@@ -103,7 +113,7 @@ func GetProductInfoById(productId int) (product ProductDTO, err error) {
|
|
|
return
|
|
|
}
|
|
|
product = convertToProductDTO(merchantProduct)
|
|
|
- product.RiskLevel, product.SourceTile, product.Abstract, product.Src, product.PermissionNames, err = GetProductRiskLevel(merchantProduct)
|
|
|
+ product.RiskLevel, product.SourceTile, product.Abstract, product.CoverUrl, product.Src, product.PermissionNames, err = GetProductRiskLevel(merchantProduct)
|
|
|
if err != nil {
|
|
|
logger.Error("获取风险等级失败[productId:%d]", productId)
|
|
|
}
|
|
@@ -118,11 +128,20 @@ func convertToProductDTO(product merchantService.MerchantProductDTO) (productDTO
|
|
|
Price: product.Price.String(),
|
|
|
RiskLevel: product.RiskLevel,
|
|
|
CoverSrc: product.CoverSrc,
|
|
|
+ CoverUrl: product.CoverUrl,
|
|
|
Type: product.Type,
|
|
|
BeginDate: beginDate.Format(time.DateOnly),
|
|
|
EndDate: endDate.Format(time.DateOnly),
|
|
|
SourceId: product.SourceId,
|
|
|
}
|
|
|
+ if product.CoverUrl == "" && product.CoverSrc > 0 {
|
|
|
+ imageSrc, err := image.GetImageSrc(product.CoverSrc)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取图片地址失败:%v,资源Id:%d", err, product.CoverSrc)
|
|
|
+ } else {
|
|
|
+ productDTO.CoverUrl = imageSrc
|
|
|
+ }
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|