rest_user_service.go
3.7 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package domain_service
import (
"encoding/json"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/service_gateway/adaptor"
)
type UserService struct {
}
// UserFrom 获取普通用户
func (service *UserService) UserFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) {
var returnData *domain.User
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if user, err := userAdaptor.ToParticipator(companyId, orgId, userId, "User"); err != nil {
return nil, err
} else {
if user != nil {
err := json.Unmarshal(user.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
// ReferrerFrom 获取推荐人
func (service *UserService) ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error) {
var returnData *domain.Referrer
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if referrer, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Referrer"); err != nil {
return nil, err
} else {
if referrer != nil {
err := json.Unmarshal(referrer.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
// UndertakerFrom 获取承接人
func (service *UserService) UndertakerFrom(companyId int64, orgId int64, userId int64) (*domain.Undertaker, error) {
var returnData *domain.Undertaker
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if undertaker, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Undertaker"); err != nil {
return nil, err
} else {
if undertaker != nil {
err := json.Unmarshal(undertaker.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
// RelevantFrom 获取相关人
func (service *UserService) RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) {
var returnData *domain.Relevant
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if relevant, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Relevant"); err != nil {
return nil, err
} else {
if relevant != nil {
err := json.Unmarshal(relevant.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
// SalesmanFrom 获取业务员
func (service *UserService) SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) {
var returnData *domain.Salesman
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if salesman, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Salesman"); err != nil {
return nil, err
} else {
if salesman != nil {
err := json.Unmarshal(salesman.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
// OperatorFrom 获取操作人
func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) {
var returnData *domain.User
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if operator, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Operator"); err != nil {
return nil, err
} else {
if operator != nil {
err := json.Unmarshal(operator.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
func NewUserService() (*UserService, error) {
return &UserService{}, nil
}