From 5f815df137f6edaaaddf869097b7e2718324acc6 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 13 十月 2023 13:53:22 +0800 Subject: [PATCH] 跟进记录简单数据权限 --- service/saleChance.go | 54 +++++++++++++++++++++++++++++++++++------------------- 1 files changed, 35 insertions(+), 19 deletions(-) diff --git a/service/saleChance.go b/service/saleChance.go index 03b01c3..1610c07 100644 --- a/service/saleChance.go +++ b/service/saleChance.go @@ -15,21 +15,6 @@ return ecode.OK } -func (SaleChanceService) DeleteSaleChance(id int) int { - // check saleChange exist - _, err := model.NewSaleChanceSearch().SetId(id).Find() - if err != nil { - return ecode.SaleChanceNotExist - } - - // delete saleChange - err = model.NewSaleChanceSearch().SetId(id).Delete() - if err != nil { - return ecode.SaleChanceDeleteErr - } - return ecode.OK -} - func (SaleChanceService) UpdateSaleChance(saleChange *model.SaleChance) int { // update saleChange err := model.NewSaleChanceSearch().SetId(saleChange.Id).Update(saleChange) @@ -54,11 +39,42 @@ return ecode.OK } -func (SaleChanceService) GetSaleChanceList(page, pageSize int, keyword string) ([]*model.SaleChance, int) { +func (SaleChanceService) GetSaleChanceList(page, pageSize int, data map[string]interface{}) ([]*model.SaleChance, int64, int) { // get contact list - contacts, err := model.NewSaleChanceSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() + contacts, total, err := model.NewSaleChanceSearch().SetPage(page, pageSize).SetSearchMap(data).FindAll() if err != nil { - return nil, ecode.SaleChanceListErr + return nil, 0, ecode.SaleChanceListErr } - return contacts, ecode.OK + return contacts, total, ecode.OK +} + +// push +func (SaleChanceService) PushSaleChance(id, step int) int { + // check saleChange exist + errCode := CheckSaleChangeExist(id) + if errCode != ecode.OK { + return errCode + } + // check step + _, err := model.NewSaleStageSearch().SetId(step).Find() + if err != nil { + return ecode.SaleStageNotExist + } + + // push saleChange + err = model.NewSaleChanceSearch().SetId(id).Update(&model.SaleChance{SaleStageId: step}) + if err != nil { + return ecode.SaleChanceUpdateErr + } + + return ecode.OK +} + +func (SaleChanceService) DeleteSaleChance(ids []int) int { + // delete client + err := model.NewSaleChanceSearch().SetIds(ids).Delete() + if err != nil { + return ecode.SaleChanceDeleteErr + } + return ecode.OK } -- Gitblit v1.8.0