فهرست منبع

conversrc->converUrl

kobe6258 3 ماه پیش
والد
کامیت
1c935f6571
3فایلهای تغییر یافته به همراه11 افزوده شده و 7 حذف شده
  1. 1 0
      domian/media/media_service.go
  2. 3 3
      domian/merchant/merchant_product.go
  3. 7 4
      models/merchant/merchant_product.go

+ 1 - 0
domian/media/media_service.go

@@ -348,6 +348,7 @@ func convertMediaDTO(media mediaDao.Media, fullTime bool) MediaDTO {
 			MediaName:             media.MediaName,
 			SourceType:            media.SourceType,
 			CoverSrc:              media.CoverSrc,
+			CoverUrl:              media.CoverSrc,
 			MediaPlayMilliseconds: media.MediaPlayMilliseconds,
 			PermissionIDs:         media.PermissionIDs,
 			PublishedTime:         media.PublishedTime.Format(time.DateOnly),

+ 3 - 3
domian/merchant/merchant_product.go

@@ -58,8 +58,8 @@ func GetMerchantProductById(id int) (productDTO MerchantProductDTO, err error) {
 	productDTO = convertToDTO(product)
 	return
 }
-func convertToDTO(product merchantDao.MerchantProduct) (productDTO MerchantProductDTO) {
-	productDTO = MerchantProductDTO{
+func convertToDTO(product merchantDao.MerchantProduct) MerchantProductDTO {
+	return MerchantProductDTO{
 		Id:          product.Id,
 		Title:       product.Title,
 		CoverSrc:    product.CoverSrc,
@@ -67,7 +67,7 @@ func convertToDTO(product merchantDao.MerchantProduct) (productDTO MerchantProdu
 		Description: product.Description,
 		ProductTile: product.Title,
 		Price:       product.Price,
-		RiskLevel:   "",
+		RiskLevel:   product.RiskLevel,
 		Type:        string(product.Type),
 		TypeCN:      typeTransfer[product.Type],
 		IsPermanent: product.IsPermanent,

+ 7 - 4
models/merchant/merchant_product.go

@@ -16,7 +16,7 @@ type MerchantProductType string
 
 const (
 	detailColumns         = "id,source_id,title,cover_src,cover_url,description,price,type,is_permanent,valid_days,sale_status,created_time,updated_time"
-	detailColumnsWithRisk = "id,source_id,title,cover_src,cover_url,description,price,type,is_permanent,valid_days,sale_status,created_time,updated_time,permissions.risk_level as risk_level"
+	detailColumnsWithRisk = "merchant_products.id,source_id,title,cover_src,cover_url,description,price,type,is_permanent,valid_days,sale_status,created_time,updated_time,permissions.risk_level as risk_level"
 	sourceIdColumn        = "id,source_id"
 )
 const (
@@ -62,9 +62,8 @@ func GetMerchantProductBySourceId(sourceId int, productType ...MerchantProductTy
 	db := models.Main()
 	if len(productType) > 0 {
 		if len(productType) == 1 {
-
 			if productType[0] == Package {
-				err = db.Select(detailColumnsWithRisk).InnerJoins("permissions  on permissions.permission_id=source_id")
+				err = db.Select(detailColumnsWithRisk).Joins("left join permissions  on permissions.permission_id=source_id").Where("source_id =? and type = ? and deleted =?", sourceId, productType[0], 0).First(&product).Error
 			} else {
 				err = db.Select(detailColumns).Where("source_id =? and type = ? and deleted =?", sourceId, productType[0], 0).First(&product).Error
 			}
@@ -92,7 +91,11 @@ func GetProductListBySourceIds(ids []int, detail bool, productType ...MerchantPr
 	}
 	if len(productType) > 0 {
 		if len(productType) == 1 {
-			err = db.Select(columns).Where("source_id in ? and type = ? and deleted =? order by created_time desc", ids, productType[0], false).Find(&productList).Error
+			if productType[0] == Package {
+				err = db.Select(detailColumnsWithRisk).Joins("left join permissions  on permissions.permission_id=source_id").Where("source_id in ? and type = ? and deleted =? order by created_time desc", ids, productType[0], false).Find(&productList).Error
+			} else {
+				err = db.Select(columns).Where("source_id in ? and type = ? and deleted =? order by created_time desc", ids, productType[0], false).Find(&productList).Error
+			}
 		} else {
 			err = db.Select(columns).Where("source_id in ? and type in (?) and deleted =? by created_time desc", ids, productType, false).Find(&productList).Error
 		}