zhangqian
2023-08-07 4b63908ad085bc570623f7b0c0fd397b2ae7a80d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package service
 
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/pkg/ecode"
)
 
type FollowupService struct{}
 
func (FollowupService) AddServiceFollowup(serviceFollowup *model.ServiceFollowup) int {
    err := model.NewServiceFollowupSearch().Create(serviceFollowup)
    if err != nil {
        return ecode.ServiceFollowupExist
    }
 
    return ecode.OK
}
 
func (FollowupService) DeleteServiceFollowup(id int) int {
    _, err := model.NewServiceFollowupSearch().SetId(id).Find()
    if err != nil {
        return ecode.ServiceFollowupNotExist
    }
 
    err = model.NewServiceFollowupSearch().SetId(id).Delete()
    if err != nil {
        return ecode.ServiceFollowupNotExist
    }
    return ecode.OK
}
 
func (FollowupService) UpdateServiceFollowup(serviceFollowup *model.ServiceFollowup) int {
    // check serviceFollowup exist
    _, err := model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).Find()
    if err != nil {
        return ecode.ServiceFollowupNotExist
    }
 
    err = model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).Update(serviceFollowup)
    if err != nil {
        return ecode.ServiceFollowupSetErr
    }
 
    return ecode.OK
}
 
func (FollowupService) GetServiceFollowupList(page, pageSize int, keywordType constvar.ServiceFollowupKeywordType, keyword string) ([]*model.ServiceFollowup, int64, int) {
    // get contact list
    contacts, total, err := model.NewServiceFollowupSearch().
        SetKeywordType(keywordType).
        SetKeyword(keyword).
        SetPage(page, pageSize).FindAll()
    if err != nil {
        return nil, 0, ecode.ServiceFollowupListErr
    }
    return contacts, total, ecode.OK
}