From 4f526b034a6e13a521ad71dcbdbea97043d6ea19 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 20 三月 2024 19:21:20 +0800
Subject: [PATCH] 发货信息字段完善

---
 service/contract.go |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/service/contract.go b/service/contract.go
index a1e56e5..b6825ef 100644
--- a/service/contract.go
+++ b/service/contract.go
@@ -16,19 +16,6 @@
 	return ecode.OK
 }
 
-func (ContractService) DeleteContract(id int) int {
-	_, err := model.NewContractSearch().SetId(id).Find()
-	if err != nil {
-		return ecode.ContractNotExist
-	}
-
-	err = model.NewContractSearch().SetId(id).Delete()
-	if err != nil {
-		return ecode.ContractNotExist
-	}
-	return ecode.OK
-}
-
 func (ContractService) UpdateContract(contract *model.Contract) int {
 	// check contract exist
 	_, err := model.NewContractSearch().SetId(contract.Id).Find()
@@ -44,11 +31,20 @@
 	return ecode.OK
 }
 
-func (ContractService) GetContractList(page, pageSize int, keyword string) ([]*model.Contract, int) {
+func (ContractService) GetContractList(page, pageSize int, data map[string]interface{}, keyword string) ([]*model.Contract, int64, int) {
 	// get contact list
-	contacts, err := model.NewContractSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll()
+	contacts, total, err := model.NewContractSearch().SetPage(page, pageSize).SetSearchMap(data).SetKeyword(keyword).FindAll()
 	if err != nil {
-		return nil, ecode.ContractListErr
+		return nil, 0, ecode.ContractListErr
 	}
-	return contacts, ecode.OK
+	return contacts, total, ecode.OK
+}
+
+func (ContractService) DeleteContract(id int) int {
+	// delete client
+	err := model.NewContractSearch().SetId(id).Delete()
+	if err != nil {
+		return ecode.ContractDeleteErr
+	}
+	return ecode.OK
 }

--
Gitblit v1.8.0