Ver Fonte

产品列表

kobe6258 há 4 meses atrás
pai
commit
8ca09d70f1

+ 6 - 17
controllers/product/product_controller.go

@@ -5,7 +5,6 @@ import (
 	"eta/eta_mini_ht_api/common/utils/page"
 	"eta/eta_mini_ht_api/controllers"
 	productService "eta/eta_mini_ht_api/service/product"
-	"fmt"
 )
 
 var (
@@ -90,29 +89,19 @@ func (p *ProductController) RelatePackage(productId int) {
 // @Description 获取商品信息
 // @Success 200 {object} controllers.BaseResponse
 // @router /productSearch [get]
-func (p *ProductController) ProductSearch(productType, key string) {
+func (p *ProductController) ProductSearch(productType, key string, isSignal bool) {
 	controllers.Wrap(&p.BaseController, func() (result *controllers.WrapData, err error) {
 		result = p.InitWrapData("搜索产品信息失败")
 		if !productMap[productType] {
-			p.FailedResult("搜索产品信息失败", result)
 			err = exception.New(exception.ProductTypeError)
+			p.FailedResult("搜索产品信息失败", result)
 			return
 		}
-		//for i := 0; i < len(productMap); i++ {
-		//	//if productType == productMap[i] {
-		//	//	productList, err := productService.ProductSearch(productType, key)
-		//	//	if err != nil {
-		//	//		p.FailedResult("搜索产品信息失败", result)
-		//	//		return
-		//	//	}
-		//	}
+		//if isSignal {
+		//	productList, err := productService.ProductSearch(productType, key)
+		//} else {
+		//	productList, err := productService.PackageSearch(key)
 		//}
-		fmt.Printf("productType:%v,key:%v\n", productType, key)
-		if err != nil {
-			p.FailedResult("获取关联套餐信息失败", result)
-			err = exception.New(exception.ProductTypeError)
-			return
-		}
 		if err != nil {
 			p.FailedResult("搜索产品信息失败", result)
 			return

+ 15 - 2
domian/merchant/merchant_product.go

@@ -105,9 +105,9 @@ func GetTotalPageCountByProductType(productType string) (total int64, latestId i
 	return merchantDao.GetTotalPageCountByProductType(typeKindTransfer[productType])
 }
 
-func GetProductListByProductType(productType string, info page.PageInfo) (dtoList []MerchantProductDTO, err error) {
+func GetProductPageByProductType(productType string, info page.PageInfo) (dtoList []MerchantProductDTO, err error) {
 	offset := page.StartIndex(info.Current, info.PageSize)
-	productList, err := merchantDao.GetProductListByProductType(typeKindTransfer[productType], info.LatestId, offset, info.PageSize)
+	productList, err := merchantDao.GetProductPageByProductType(typeKindTransfer[productType], info.LatestId, offset, info.PageSize)
 	if err != nil {
 		logger.Error("获取商品列表失败[productType:%v,pageInfo:%v],err:%v", productType, info, err)
 		return
@@ -118,3 +118,16 @@ func GetProductListByProductType(productType string, info page.PageInfo) (dtoLis
 	}
 	return
 }
+
+func GetProductListByProductType(productType string) (dtoList []MerchantProductDTO, err error) {
+	productList, err := merchantDao.GetProductListByProductType(typeKindTransfer[productType], false)
+	if err != nil {
+		logger.Error("获取商品列表失败[productType:%v,pageInfo:%v],err:%v", productType, err)
+		return
+	}
+	for _, product := range productList {
+		productDTO := convertToDTO(product)
+		dtoList = append(dtoList, productDTO)
+	}
+	return
+}

+ 17 - 1
models/merchant/merchant_product.go

@@ -110,7 +110,7 @@ func GetTotalPageCountByProductType(productType MerchantProductType) (total int6
 	return
 }
 
-func GetProductListByProductType(productType MerchantProductType, id int64, offset int, limit int) (list []MerchantProduct, err error) {
+func GetProductPageByProductType(productType MerchantProductType, id int64, offset int, limit int) (list []MerchantProduct, err error) {
 	db := models.Main()
 	if productType == "" {
 		err = errors.New("productType参数不能为空")
@@ -119,3 +119,19 @@ func GetProductListByProductType(productType MerchantProductType, id int64, offs
 	err = db.Select(detailColumns).Where("id <= ? and type = ? and deleted =? order by created_time desc limit ?,? ", id, productType, false, offset, limit).Find(&list).Error
 	return
 }
+
+func GetProductListByProductType(productType MerchantProductType, detail bool) (list []MerchantProduct, err error) {
+	db := models.Main()
+	var columns string
+	if detail {
+		columns = detailColumns
+	} else {
+		columns = sourceIdColumn
+	}
+	if productType == "" {
+		err = errors.New("productType参数不能为空")
+		return
+	}
+	err = db.Select(columns).Where("id <= ? and type = ? and deleted =? order by created_time desc limit ?,? ", productType, false).Find(&list).Error
+	return
+}

+ 1 - 0
routers/commentsRouter.go

@@ -162,6 +162,7 @@ func init() {
             MethodParams: param.Make(
 				param.New("productType"),
 				param.New("key"),
+				param.New("isSignal"),
 			),
             Filters: nil,
             Params: nil})

+ 15 - 1
service/product/product_service.go

@@ -231,7 +231,7 @@ func GetTotalPageCountByProductType(productType string) (total int64, latestId i
 
 func ProductList(productType string, info page.PageInfo) (dtoList []ProductDTO, err error) {
 	var merchantProductList []merchantService.MerchantProductDTO
-	merchantProductList, err = merchantService.GetProductListByProductType(productType, info)
+	merchantProductList, err = merchantService.GetProductPageByProductType(productType, info)
 	for _, product := range merchantProductList {
 		productDTO := convertToProductDTO(product)
 		productDTO.RiskLevel, productDTO.SourceTile, productDTO.Abstract, productDTO.CoverUrl, productDTO.Src, productDTO.PermissionNames, err = GetProductRiskLevel(product)
@@ -239,3 +239,17 @@ func ProductList(productType string, info page.PageInfo) (dtoList []ProductDTO,
 	}
 	return
 }
+
+func ProductSearch(productType string, key string) (list []ProductDTO, err error) {
+	var merchantProductList []merchantService.MerchantProductDTO
+	merchantProductList, err = merchantService.GetProductListByProductType(productType)
+	for _, product := range merchantProductList {
+		productDTO := convertToProductDTO(product)
+		list = append(list, productDTO)
+	}
+	return
+}
+
+func PackageSearch(key string) (interface{}, interface{}) {
+
+}

+ 2 - 0
service/report/report_service.go

@@ -48,6 +48,7 @@ type PublishRankedReport struct {
 	Price             string         `json:"price"`
 	IsSubscribe       bool           `json:"isSubscribe"`
 	Login             bool           `json:"login"`
+	ProductId         int            `json:"productId"`
 }
 
 type HotRankedReport struct {
@@ -571,6 +572,7 @@ func convertToPublishRankedReportList(dtoList []reportService.ReportDTO) (report
 			Price:             dto.Price,
 			RiskLevel:         dto.RiskLevel,
 			Login:             dto.Login,
+			ProductId:         dto.ProductId,
 		}
 		reports = append(reports, report)
 	}