From cd9a3c446cff66e589cdb26163c3e2baf4bc6a1e Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 30 八月 2023 13:37:19 +0800
Subject: [PATCH] fix
---
service/contract.go | 30 +++++++++++++-----------------
1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/service/contract.go b/service/contract.go
index a1e56e5..2072299 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{}) ([]*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).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(ids []int) int {
+ // delete client
+ err := model.NewContractSearch().SetIds(ids).Delete()
+ if err != nil {
+ return ecode.ContractDeleteErr
+ }
+ return ecode.OK
}
--
Gitblit v1.8.0