From 34e1e9dbc7a750048c0825b8f91b07ed526ae577 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期五, 22 九月 2023 15:41:48 +0800
Subject: [PATCH] 1.根据产品获取出入库历史记录

---
 controllers/product_controller.go |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index 0f57587..ab40488 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -274,3 +274,33 @@
 	}
 	util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛")
 }
+
+// ListOperation
+// @Tags      浜у搧
+// @Summary   浜у搧鍘嗗彶鍑哄叆搴撲俊鎭�
+// @Produce   application/json
+// @Param		 object  body  request.QueryOperationList true  "鏌ヨ鍙傛暟"
+// @Success   200 {object} util.ResponseList{data=[]models.Operation}	"鎴愬姛"
+// @Router    /api-wms/v1/product/listOperaton [post]
+func (slf ProductController) ListOperation(c *gin.Context) {
+	var params request.QueryOperationList
+	if err := c.BindJSON(&params); err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
+		return
+	}
+	if !params.PageInfo.Check() {
+		util.ResponseFormat(c, code.RequestParamError, "椤电爜淇℃伅閿欒")
+		return
+	}
+
+	search := models.NewOperationSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetOrder("created_at desc")
+	search.SetOrm(search.Orm.InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation_details.product_id=?", params.ProductId))
+
+	list, total, err := search.Find()
+	if err != nil {
+		util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
+		return
+	}
+
+	util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
+}

--
Gitblit v1.8.0