| | |
| | | // @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) { |
| | |
| | | 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 |
| | |
| | | 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, |