zhangqian
2023-08-29 0d86d93cff554f54f83927d4f8bf03ed8c847883
api/v1/purchase/purchase.go
@@ -29,7 +29,7 @@
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param     data  body     purchaserequest.AddPurchase   true  "采购单用户名, 采购单手机号码"
// @Param     data  body     purchaserequest.AddPurchase   true  "采购单,采购单产品"
// @Success   200   {object}  response.Response{msg=string}  "创建采购单"
// @Router    /purchase/purchase [post]
func (e *PurchaseApi) CreatePurchase(c *gin.Context) {
@@ -149,7 +149,26 @@
      response.FailWithMessage("获取失败", c)
      return
   }
   response.OkWithDetailed(purchaseRes.PurchaseResponse{Purchase: data, ProductList: productList}, "获取成功", c)
   respProductList := make([]*purchaseRes.PurchaseProducts, len(productList))
   err = mapstructure.Decode(productList, &respProductList)
   if err != nil {
      global.GVA_LOG.Error("获取失败!", zap.Error(err))
      response.FailWithMessage("获取失败", c)
      return
   }
   for k, item := range productList {
      respProductList[k].Amount = item.Amount
      respProductList[k].Price = item.Price
      respProductList[k].Total = item.Total
      err = mapstructure.Decode(item.Product, &respProductList[k])
      if err != nil {
         global.GVA_LOG.Error("获取失败!", zap.Error(err))
         response.FailWithMessage("获取失败", c)
         return
      }
   }
   response.OkWithDetailed(purchaseRes.PurchaseResponse{Purchase: data, ProductList: respProductList}, "获取成功", c)
}
// GetPurchaseList
@@ -173,14 +192,14 @@
      response.FailWithMessage(err.Error(), c)
      return
   }
   PurchaseList, total, err := service.NewPurchaseService().GetPurchaseList(pageInfo)
   purchaseList, total, err := service.NewPurchaseService().GetPurchaseList(pageInfo)
   if err != nil {
      global.GVA_LOG.Error("获取失败!", zap.Error(err))
      response.FailWithMessage("获取失败"+err.Error(), c)
      return
   }
   response.OkWithDetailed(response.PageResult{
      List:     PurchaseList,
      List:     purchaseList,
      Total:    total,
      Page:     pageInfo.Page,
      PageSize: pageInfo.PageSize,