From 7e0823fc3b352cfcbb4a2f21088c00db2c00c395 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期三, 02 八月 2023 17:29:27 +0800 Subject: [PATCH] fix --- service/followRecord.go | 124 +++++++++++++++++++--------------------- 1 files changed, 59 insertions(+), 65 deletions(-) diff --git a/service/followRecord.go b/service/followRecord.go index e765804..44b464b 100644 --- a/service/followRecord.go +++ b/service/followRecord.go @@ -1,65 +1,59 @@ -package service - -import ( - "aps_crm/model" - "aps_crm/pkg/ecode" -) - -type FollowRecordService struct{} - -func (FollowRecordService) AddFollowRecord(followRecord *model.FollowRecord) int { - err := model.NewFollowRecordSearch().Create(followRecord) - if err != nil { - return ecode.FollowRecordExist - } - return ecode.OK -} - -func (FollowRecordService) DeleteFollowRecord(id int) int { - // check followRecord exist - _, err := model.NewFollowRecordSearch().SetId(id).First() - if err != nil { - return ecode.FollowRecordNotExist - } - - // delete followRecord - err = model.NewFollowRecordSearch().SetId(id).Delete() - if err != nil { - return ecode.FollowRecordDeleteErr - } - return ecode.OK -} - -// check followRecord exist -func checkFollowRecordExist(id int) int { - _, err := model.NewFollowRecordSearch().SetId(id).First() - if err != nil { - return ecode.FollowRecordNotExist - } - - return ecode.OK -} - -func (FollowRecordService) UpdateFollowRecord(followRecord *model.FollowRecord) int { - // check followRecord exist - errCode := checkFollowRecordExist(followRecord.Id) - if errCode != ecode.OK { - return errCode - } - - // update followRecord - err := model.NewFollowRecordSearch().SetId(followRecord.Id).Update(followRecord) - if err != nil { - return ecode.FollowRecordUpdateErr - } - return ecode.OK -} - -func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int64, int) { - // get contact list - contacts, total, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() - if err != nil { - return nil, 0, ecode.FollowRecordListErr - } - return contacts, total, ecode.OK -} \ No newline at end of file +package service + +import ( + "aps_crm/model" + "aps_crm/pkg/ecode" +) + +type FollowRecordService struct{} + +func (FollowRecordService) AddFollowRecord(followRecord *model.FollowRecord) int { + err := model.NewFollowRecordSearch().Create(followRecord) + if err != nil { + return ecode.FollowRecordExist + } + return ecode.OK +} + +// check followRecord exist +func checkFollowRecordExist(id int) int { + _, err := model.NewFollowRecordSearch().SetId(id).First() + if err != nil { + return ecode.FollowRecordNotExist + } + + return ecode.OK +} + +func (FollowRecordService) UpdateFollowRecord(followRecord *model.FollowRecord) int { + // check followRecord exist + errCode := checkFollowRecordExist(followRecord.Id) + if errCode != ecode.OK { + return errCode + } + + // update followRecord + err := model.NewFollowRecordSearch().SetId(followRecord.Id).Update(followRecord) + if err != nil { + return ecode.FollowRecordUpdateErr + } + return ecode.OK +} + +func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int64, int) { + // get contact list + contacts, total, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() + if err != nil { + return nil, 0, ecode.FollowRecordListErr + } + return contacts, total, ecode.OK +} + +func (FollowRecordService) DeleteFollowRecord(ids []int) int { + // delete client + err := model.NewFollowRecordSearch().SetIds(ids).Delete() + if err != nil { + return ecode.FollowRecordDeleteErr + } + return ecode.OK +} -- Gitblit v1.8.0