From 854ef02e9a8b9683d9f7db58bb1023a94654b969 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 16 八月 2023 10:13:45 +0800
Subject: [PATCH] 销售退货单批量删除接口

---
 api/v1/serviceContract.go |   60 ++++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/api/v1/serviceContract.go b/api/v1/serviceContract.go
index d354aa2..99bfb1e 100644
--- a/api/v1/serviceContract.go
+++ b/api/v1/serviceContract.go
@@ -6,6 +6,7 @@
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
+	"aps_crm/pkg/structx"
 	"github.com/gin-gonic/gin"
 )
 
@@ -26,13 +27,13 @@
 		return
 	}
 
-	errCode, serviceContract := checkServiceContractParams(params.ServiceContract)
-	if errCode != ecode.OK {
-		ctx.Fail(errCode)
+	serviceContract := new(model.ServiceContract)
+	if err := structx.AssignTo(params, serviceContract); err != nil {
+		ctx.Fail(ecode.ParamsErr)
 		return
 	}
 
-	errCode = serviceContractService.AddServiceContract(&serviceContract)
+	errCode := serviceContractService.AddServiceContract(serviceContract)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
@@ -41,22 +42,45 @@
 	ctx.Ok()
 }
 
-// Delete
+//// Delete
+////
+////	@Tags		ServiceContract
+////	@Summary	鍒犻櫎鏈嶅姟鍚堝悓
+////	@Produce	application/json
+////	@Param		object	body		request.DeleteServiceContract true	"鏌ヨ鍙傛暟"
+////	@Success	200	{object}	contextx.Response{}
+////	@Router		/api/serviceContract/delete [delete]
+//func (s *ServiceContractApi) Delete(c *gin.Context) {
+//	var params request.DeleteServiceContract
+//	ctx, ok := contextx.NewContext(c, &params)
+//	if !ok {
+//		return
+//	}
 //
-//	@Tags		ServiceContract
-//	@Summary	鍒犻櫎鏈嶅姟鍚堝悓
-//	@Produce	application/json
-//	@Param		object	body		request.DeleteServiceContract true	"鏌ヨ鍙傛暟"
-//	@Success	200	{object}	contextx.Response{}
-//	@Router		/api/serviceContract/delete [delete]
-func (s *ServiceContractApi) Delete(c *gin.Context) {
-	var params request.DeleteServiceContract
+//	errCode := serviceContractService.DeleteServiceContract(params.Ids)
+//	if errCode != ecode.OK {
+//		ctx.Fail(errCode)
+//		return
+//	}
+//
+//	ctx.Ok()
+//}
+
+// BatchDelete
+// @Tags	ServiceContract
+// @Summary	鎵归噺鍒犻櫎鏈嶅姟鍚堝悓
+// @Produce	application/json
+// @Param	object	body request.CommonIds	true "鍙傛暟"
+// @Success	200	{object}	contextx.Response{}
+// @Router		/api/serviceContract/delete [delete]
+func (s *ServiceContractApi) BatchDelete(c *gin.Context) {
+	var params request.CommonIds
 	ctx, ok := contextx.NewContext(c, &params)
 	if !ok {
 		return
 	}
 
-	errCode := serviceContractService.DeleteServiceContract(params.Ids)
+	errCode := serviceContractService.BatchDeleteServiceContract(params.Ids)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
@@ -80,15 +104,15 @@
 		return
 	}
 
-	errCode, serviceContract := checkServiceContractParams(params.ServiceContract)
-	if errCode != ecode.OK {
-		ctx.Fail(errCode)
+	serviceContract := new(model.ServiceContract)
+	if err := structx.AssignTo(params, serviceContract); err != nil {
+		ctx.Fail(ecode.ParamsErr)
 		return
 	}
 
 	serviceContract.Id = params.Id
 
-	errCode = serviceContractService.UpdateServiceContract(&serviceContract)
+	errCode := serviceContractService.UpdateServiceContract(serviceContract)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return

--
Gitblit v1.8.0