新增系统商品

This commit is contained in:
2023-12-21 17:19:30 +08:00
parent b38c3f17cd
commit a988ba3743
9 changed files with 376 additions and 51 deletions
+36 -10
View File
@@ -59,8 +59,8 @@ func (r *Product) GetPlatformProductPage(c *gin.Context) {
responses.OkWithData(result, c)
}
// GetPlatformProduct 平台商品详情
func (r *Product) GetPlatformProduct(c *gin.Context) {
// GetProductPlatform 平台商品详情
func (r *Product) GetProductPlatform(c *gin.Context) {
id := c.Param("product_platform_id")
if id == "" {
responses.FailWithMessage("缺少参数", c)
@@ -76,7 +76,7 @@ func (r *Product) GetPlatformProduct(c *gin.Context) {
// 业务处理
productService := service.ProductService{}
getPlatformProductResponses, err := productService.GetPlatformProduct(productPlatformId)
getPlatformProductResponses, err := productService.GetProductPlatform(productPlatformId)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return
@@ -85,10 +85,10 @@ func (r *Product) GetPlatformProduct(c *gin.Context) {
responses.OkWithData(getPlatformProductResponses, c)
}
// GetSystemProductPage 获取系统商品列表-分页
func (r *Product) GetSystemProductPage(c *gin.Context) {
// GetProductPage 获取商品列表-分页
func (r *Product) GetProductPage(c *gin.Context) {
productRequest := requests.ProductRequest{}
req := productRequest.GetPlatformProductPage
req := productRequest.GetProductPage
if err := c.ShouldBind(&req); err != nil {
responses.FailWithMessage(err.Error(), c)
return
@@ -108,15 +108,15 @@ func (r *Product) GetSystemProductPage(c *gin.Context) {
req.PageSize = 20
}
productPlatformDao := dao.ProductPlatformDao{}
productPlatform, total, err := productPlatformDao.GetPlatformProductPageSearch(req, req.Page, req.PageSize)
productDao := dao.ProductDao{}
product, total, err := productDao.GetProductPageSearch(req, req.Page, req.PageSize)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return
}
// 处理返回值
GetProductPlatformPageResponses := dto.GetProductPlatformListDto(productPlatform)
GetProductPageResponses := dto.GetProductListDto(product)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return
@@ -126,6 +126,32 @@ func (r *Product) GetSystemProductPage(c *gin.Context) {
result["page"] = req.Page
result["page_size"] = req.PageSize
result["total"] = total
result["data"] = GetProductPlatformPageResponses
result["data"] = GetProductPageResponses
responses.OkWithData(result, c)
}
// GetProduct 商品详情
func (r *Product) GetProduct(c *gin.Context) {
id := c.Param("product_id")
if id == "" {
responses.FailWithMessage("缺少参数", c)
return
}
// 将 id 转换为 int64 类型
productId, err := strconv.ParseInt(id, 10, 64)
if err != nil {
responses.Fail(c)
return
}
// 业务处理
productService := service.ProductService{}
getPlatformProductResponses, err := productService.GetProduct(productId)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return
}
responses.OkWithData(getPlatformProductResponses, c)
}