From e0a433e9c31594527a3bf7766c0bfb2cbbceffdb Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期三, 26 七月 2023 10:09:04 +0800
Subject: [PATCH] fix add pageInfo, keyword to all the list

---
 service/saleChance.go |   41 ++++++++++++++++++++---------------------
 1 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/service/saleChance.go b/service/saleChance.go
index c609f25..03b01c3 100644
--- a/service/saleChance.go
+++ b/service/saleChance.go
@@ -8,43 +8,33 @@
 type SaleChanceService struct{}
 
 func (SaleChanceService) AddSaleChance(saleChange *model.SaleChance) int {
-	err := model.NewSaleChangeSearch().Create(saleChange)
+	err := model.NewSaleChanceSearch().Create(saleChange)
 	if err != nil {
-		return ecode.SaleChangeExist
+		return ecode.SaleChanceExist
 	}
 	return ecode.OK
 }
 
 func (SaleChanceService) DeleteSaleChance(id int) int {
 	// check saleChange exist
-	_, err := model.NewSaleChangeSearch().SetId(id).Find()
+	_, err := model.NewSaleChanceSearch().SetId(id).Find()
 	if err != nil {
-		return ecode.SaleChangeNotExist
+		return ecode.SaleChanceNotExist
 	}
 
 	// delete saleChange
-	err = model.NewSaleChangeSearch().SetId(id).Delete()
+	err = model.NewSaleChanceSearch().SetId(id).Delete()
 	if err != nil {
-		return ecode.SaleChangeDeleteErr
+		return ecode.SaleChanceDeleteErr
 	}
 	return ecode.OK
 }
 
-func (SaleChanceService) GetSaleChanceList() (int, []*model.SaleChance) {
-	// get saleChange list
-	saleChanges, err := model.NewSaleChangeSearch().FindAll()
-	if err != nil {
-		return ecode.SaleChangeListErr, nil
-	}
-
-	return ecode.OK, saleChanges
-}
-
 func (SaleChanceService) UpdateSaleChance(saleChange *model.SaleChance) int {
 	// update saleChange
-	err := model.NewSaleChangeSearch().SetId(saleChange.Id).Update(saleChange)
+	err := model.NewSaleChanceSearch().SetId(saleChange.Id).Update(saleChange)
 	if err != nil {
-		return ecode.SaleChangeUpdateErr
+		return ecode.SaleChanceUpdateErr
 	}
 
 	return ecode.OK
@@ -52,14 +42,23 @@
 
 // CheckSaleChangeExist check saleChange exist
 func CheckSaleChangeExist(id int) int {
-	tmp, err := model.NewSaleChangeSearch().SetId(id).Find()
+	tmp, err := model.NewSaleChanceSearch().SetId(id).Find()
 	if err != nil {
-		return ecode.SaleChangeNotExist
+		return ecode.SaleChanceNotExist
 	}
 
 	if tmp.Id == 0 {
-		return ecode.SaleChangeNotExist
+		return ecode.SaleChanceNotExist
 	}
 
 	return ecode.OK
 }
+
+func (SaleChanceService) GetSaleChanceList(page, pageSize int, keyword string) ([]*model.SaleChance, int) {
+	// get contact list
+	contacts, err := model.NewSaleChanceSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll()
+	if err != nil {
+		return nil, ecode.SaleChanceListErr
+	}
+	return contacts, ecode.OK
+}

--
Gitblit v1.8.0