|
@@ -52,6 +52,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
@@ -52,6 +52,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
52
|
var isPrincipal bool
|
52
|
var isPrincipal bool
|
|
53
|
var status int
|
53
|
var status int
|
|
54
|
var uids []int64
|
54
|
var uids []int64
|
|
|
|
55
|
+ var addEmployees []map[string]interface{}
|
|
|
|
56
|
+ var editEmployees []map[string]interface{}
|
|
55
|
var data map[string]interface{}
|
57
|
var data map[string]interface{}
|
|
56
|
if err := json.Unmarshal([]byte(syncEmployeeCallbackCommand.Data), &data); err != nil {
|
58
|
if err := json.Unmarshal([]byte(syncEmployeeCallbackCommand.Data), &data); err != nil {
|
|
57
|
return false, err
|
59
|
return false, err
|
|
@@ -86,8 +88,111 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
@@ -86,8 +88,111 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
86
|
uids = append(uids, int64(uid.(float64)))
|
88
|
uids = append(uids, int64(uid.(float64)))
|
|
87
|
}
|
89
|
}
|
|
88
|
}
|
90
|
}
|
|
|
|
91
|
+ if value, ok := data["add"]; ok {
|
|
|
|
92
|
+ for _, addEmployee := range value.([]interface{}) {
|
|
|
|
93
|
+ addEmployees = append(addEmployees, addEmployee.(map[string]interface{}))
|
|
|
|
94
|
+ }
|
|
|
|
95
|
+ }
|
|
|
|
96
|
+ if value, ok := data["edit"]; ok {
|
|
|
|
97
|
+ for _, editEmployee := range value.([]interface{}) {
|
|
|
|
98
|
+ editEmployees = append(editEmployees, editEmployee.(map[string]interface{}))
|
|
|
|
99
|
+ }
|
|
|
|
100
|
+ }
|
|
89
|
if syncEmployeeCallbackCommand.Module == "employee" {
|
101
|
if syncEmployeeCallbackCommand.Module == "employee" {
|
|
90
|
switch syncEmployeeCallbackCommand.Action {
|
102
|
switch syncEmployeeCallbackCommand.Action {
|
|
|
|
103
|
+ case "import":
|
|
|
|
104
|
+ var companyId int64
|
|
|
|
105
|
+ var uid int64
|
|
|
|
106
|
+ var employeeName string
|
|
|
|
107
|
+ var employeeAccount string
|
|
|
|
108
|
+ var employeeAvatarUrl string
|
|
|
|
109
|
+ var isPrincipal bool
|
|
|
|
110
|
+ var status int
|
|
|
|
111
|
+ for _, addEmployee := range addEmployees {
|
|
|
|
112
|
+ if value, ok := addEmployee["company_id"]; ok {
|
|
|
|
113
|
+ companyId = int64(value.(float64))
|
|
|
|
114
|
+ }
|
|
|
|
115
|
+ if value, ok := addEmployee["id"]; ok {
|
|
|
|
116
|
+ uid = int64(value.(float64))
|
|
|
|
117
|
+ }
|
|
|
|
118
|
+ if value, ok := addEmployee["name"]; ok {
|
|
|
|
119
|
+ employeeName = value.(string)
|
|
|
|
120
|
+ }
|
|
|
|
121
|
+ if value, ok := addEmployee["phone"]; ok {
|
|
|
|
122
|
+ employeeAccount = value.(string)
|
|
|
|
123
|
+ }
|
|
|
|
124
|
+ if value, ok := addEmployee["avatar"]; ok {
|
|
|
|
125
|
+ employeeAvatarUrl = value.(string)
|
|
|
|
126
|
+ }
|
|
|
|
127
|
+ if value, ok := addEmployee["admin_type"]; ok {
|
|
|
|
128
|
+ if int(value.(float64)) == 2 {
|
|
|
|
129
|
+ isPrincipal = true
|
|
|
|
130
|
+ } else {
|
|
|
|
131
|
+ isPrincipal = false
|
|
|
|
132
|
+ }
|
|
|
|
133
|
+ }
|
|
|
|
134
|
+ if value, ok := addEmployee["status"]; ok {
|
|
|
|
135
|
+ status = int(value.(float64))
|
|
|
|
136
|
+ }
|
|
|
|
137
|
+ employee := &domain.Employee{
|
|
|
|
138
|
+ CompanyId: companyId,
|
|
|
|
139
|
+ EmployeeInfo: &domain.EmployeeInfo{
|
|
|
|
140
|
+ Uid: uid,
|
|
|
|
141
|
+ EmployeeName: employeeName,
|
|
|
|
142
|
+ EmployeeAccount: employeeAccount,
|
|
|
|
143
|
+ EmployeeAvatarUrl: employeeAvatarUrl,
|
|
|
|
144
|
+ IsPrincipal: isPrincipal,
|
|
|
|
145
|
+ },
|
|
|
|
146
|
+ Status: status,
|
|
|
|
147
|
+ SuMoney: 0,
|
|
|
|
148
|
+ }
|
|
|
|
149
|
+ if _, err := employeeRepository.Save(employee); err != nil {
|
|
|
|
150
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
151
|
+ }
|
|
|
|
152
|
+ }
|
|
|
|
153
|
+ for _, editEmployee := range editEmployees {
|
|
|
|
154
|
+ if value, ok := editEmployee["company_id"]; ok {
|
|
|
|
155
|
+ companyId = int64(value.(float64))
|
|
|
|
156
|
+ }
|
|
|
|
157
|
+ if value, ok := editEmployee["id"]; ok {
|
|
|
|
158
|
+ uid = int64(value.(float64))
|
|
|
|
159
|
+ }
|
|
|
|
160
|
+ if value, ok := editEmployee["name"]; ok {
|
|
|
|
161
|
+ employeeName = value.(string)
|
|
|
|
162
|
+ }
|
|
|
|
163
|
+ if value, ok := editEmployee["phone"]; ok {
|
|
|
|
164
|
+ employeeAccount = value.(string)
|
|
|
|
165
|
+ }
|
|
|
|
166
|
+ if value, ok := editEmployee["avatar"]; ok {
|
|
|
|
167
|
+ employeeAvatarUrl = value.(string)
|
|
|
|
168
|
+ }
|
|
|
|
169
|
+ if value, ok := editEmployee["admin_type"]; ok {
|
|
|
|
170
|
+ if int(value.(float64)) == 2 {
|
|
|
|
171
|
+ isPrincipal = true
|
|
|
|
172
|
+ } else {
|
|
|
|
173
|
+ isPrincipal = false
|
|
|
|
174
|
+ }
|
|
|
|
175
|
+ }
|
|
|
|
176
|
+ if value, ok := editEmployee["status"]; ok {
|
|
|
|
177
|
+ status = int(value.(float64))
|
|
|
|
178
|
+ }
|
|
|
|
179
|
+ employee, err := employeeRepository.FindOne(map[string]interface{}{"uid": uid})
|
|
|
|
180
|
+ if err == nil && employee != nil {
|
|
|
|
181
|
+ updateData := make(map[string]interface{})
|
|
|
|
182
|
+ updateData["employeeName"] = employeeName
|
|
|
|
183
|
+ updateData["employeeAccount"] = employeeAccount
|
|
|
|
184
|
+ updateData["employeeAvatarUrl"] = employeeAvatarUrl
|
|
|
|
185
|
+ updateData["isPrincipal"] = isPrincipal
|
|
|
|
186
|
+ updateData["status"] = status
|
|
|
|
187
|
+ if err := employee.Update(updateData); err != nil {
|
|
|
|
188
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
|
189
|
+ }
|
|
|
|
190
|
+ if _, err := employeeRepository.Save(employee); err != nil {
|
|
|
|
191
|
+ return false, nil
|
|
|
|
192
|
+ }
|
|
|
|
193
|
+ }
|
|
|
|
194
|
+ }
|
|
|
|
195
|
+ break
|
|
91
|
case "add":
|
196
|
case "add":
|
|
92
|
employee := &domain.Employee{
|
197
|
employee := &domain.Employee{
|
|
93
|
CompanyId: companyId,
|
198
|
CompanyId: companyId,
|