rest_user_service.go
3.2 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
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 {
}
// 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 {
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 referrer, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Undertaker"); err != nil {
return nil, err
} else {
err := json.Unmarshal(referrer.([]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 referrer, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Relevant"); err != nil {
return nil, err
} else {
err := json.Unmarshal(referrer.([]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 referrer, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Salesman"); err != nil {
return nil, err
} else {
err := json.Unmarshal(referrer.([]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 referrer, err := userAdaptor.ToParticipator(companyId, orgId, userId, "Operator"); err != nil {
return nil, err
} else {
err := json.Unmarshal(referrer.([]byte), returnData)
if err != nil {
return nil, err
}
return returnData, nil
}
}
}
func (service *UserService) UserInMenu(companyId int64, orgId int64, userId int64, code string) (bool, error) {
return false, nil
}
func (service *UserService) UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) {
return false, nil
}
func NewUserService() (*UserService, error) {
return &UserService{}, nil
}