From 0cc034256b85bd3eb2e9482231d6e5649624cde2 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期一, 13 十一月 2023 11:50:59 +0800
Subject: [PATCH] 增加取消接口,及相关修改

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

diff --git a/controllers/operation.go b/controllers/operation.go
index 08031a9..d9b4200 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -763,3 +763,38 @@
 	}
 	util.ResponseFormat(c, code.Success, companies)
 }
+
+// Cancel
+//
+//	@Tags		鍏ュ簱/鍑哄簱
+//	@Summary	鍙栨秷
+//	@Produce	application/json
+//	@Param		id	path		int			true	"id"
+//	@Success	200	{object}	util.Response	"鎴愬姛"
+//	@Router		/api-wms/v1/operation/cancel/{id} [put]
+func (slf OperationController) Cancel(c *gin.Context) {
+	id, err := strconv.Atoi(c.Param("id"))
+	if err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "閿欒鐨刬d鍊�")
+		return
+	}
+	if id == 0 {
+		util.ResponseFormat(c, code.RequestParamError, "id涓�0")
+		return
+	}
+	operation, err := models.NewOperationSearch().SetPreload(true).SetID(id).First()
+	if err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鏈壘鍒扮浉鍏冲嚭鍏ュ簱淇℃伅:"+err.Error())
+		return
+	}
+	if operation.Status != constvar.OperationStatus_Ready {
+		util.ResponseFormat(c, code.RequestError, "璇ュ嚭鍏ュ簱淇℃伅鏃犳硶鍙栨秷")
+		return
+	}
+	operation.Status = constvar.OperationStatus_Cancel
+	if err := models.NewOperationSearch().Save(operation); err != nil {
+		util.ResponseFormat(c, code.SaveFail, err.Error())
+		return
+	}
+	util.ResponseFormat(c, code.Success, "鎿嶄綔鎴愬姛")
+}

--
Gitblit v1.8.0