|
@@ -1182,108 +1182,114 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma |
|
@@ -1182,108 +1182,114 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma |
|
1182
|
}
|
1182
|
}
|
|
1183
|
|
1183
|
|
|
1184
|
// 获取员工的上级是谁
|
1184
|
// 获取员工的上级是谁
|
|
1185
|
-func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
|
|
|
|
1186
|
- departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
|
1187
|
- "transactionContext": transactionContext,
|
|
|
|
1188
|
- })
|
|
|
|
1189
|
- userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
|
1190
|
- "transactionContext": transactionContext,
|
|
|
|
1191
|
- })
|
|
|
|
1192
|
-
|
|
|
|
1193
|
- var departmemtList []*domain.Department
|
|
|
|
1194
|
- var err error
|
|
|
|
1195
|
- if len(targetUser.DepartmentId) > 0 {
|
|
|
|
1196
|
- _, departmemtList, err = departmentRepo.Find(map[string]interface{}{
|
|
|
|
1197
|
- "ids": targetUser.DepartmentId,
|
|
|
|
1198
|
- })
|
|
|
|
1199
|
- if err != nil {
|
|
|
|
1200
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的部门列表"+err.Error())
|
|
|
|
1201
|
- }
|
|
|
|
1202
|
- }
|
|
|
|
1203
|
- if len(departmemtList) == 0 {
|
|
|
|
1204
|
- //找不到员工的部门
|
|
|
|
1205
|
- companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
1206
|
- "transactionContext": transactionContext,
|
|
|
|
1207
|
- })
|
|
|
|
1208
|
- companyData, err := companyRepo.FindOne(map[string]interface{}{
|
|
|
|
1209
|
- "id": targetUser.CompanyId,
|
|
|
|
1210
|
- })
|
|
|
|
1211
|
- if err != nil {
|
|
|
|
1212
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
|
|
|
|
1213
|
- }
|
|
|
|
1214
|
- //公司作为最顶级
|
|
|
|
1215
|
- departmemtList = append(departmemtList, &domain.Department{
|
|
|
|
1216
|
- Id: 0,
|
|
|
|
1217
|
- CompanyId: companyData.Id,
|
|
|
|
1218
|
- Level: 0,
|
|
|
|
1219
|
- Name: companyData.Name,
|
|
|
|
1220
|
- ParentId: 0,
|
|
|
|
1221
|
- ChargeUserIds: companyData.ChargeUserIds,
|
|
|
|
1222
|
- Path: "",
|
|
|
|
1223
|
- CreatedAt: time.Time{},
|
|
|
|
1224
|
- UpdatedAt: time.Time{},
|
|
|
|
1225
|
- DeletedAt: &time.Time{},
|
|
|
|
1226
|
- })
|
1185
|
+// func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
|
|
|
|
1186
|
+// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
|
1187
|
+// "transactionContext": transactionContext,
|
|
|
|
1188
|
+// })
|
|
|
|
1189
|
+// userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
|
1190
|
+// "transactionContext": transactionContext,
|
|
|
|
1191
|
+// })
|
|
1227
|
|
1192
|
|
|
1228
|
- }
|
|
|
|
1229
|
- //获取部门管理员
|
|
|
|
1230
|
- var chargeUserIds []int64
|
|
|
|
1231
|
- var targetUserAsManager *domain.Department
|
|
|
|
1232
|
-loop:
|
|
|
|
1233
|
- for _, v := range departmemtList {
|
|
|
|
1234
|
- if len(v.ChargeUserIds) == 0 {
|
|
|
|
1235
|
- continue
|
|
|
|
1236
|
- }
|
|
|
|
1237
|
- //检查员工自身是否是管理员
|
|
|
|
1238
|
- for _, vv := range v.ChargeUserIds {
|
|
|
|
1239
|
- if vv == targetUser.Id {
|
|
|
|
1240
|
- targetUserAsManager = v
|
|
|
|
1241
|
- break loop
|
|
|
|
1242
|
- }
|
|
|
|
1243
|
- }
|
|
|
|
1244
|
- chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
|
1245
|
- }
|
|
|
|
1246
|
- if targetUserAsManager != nil {
|
|
|
|
1247
|
- //清空原有的管理员
|
|
|
|
1248
|
- chargeUserIds = []int64{}
|
|
|
|
1249
|
- //员工自身是否是管理员,查找父级部门
|
|
|
|
1250
|
- _, parentDepartment, err := departmentRepo.Find(map[string]interface{}{
|
|
|
|
1251
|
- "id": targetUserAsManager.ParentId,
|
|
|
|
1252
|
- })
|
|
|
|
1253
|
- if err != nil {
|
|
|
|
1254
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工现在部门的父级"+err.Error())
|
|
|
|
1255
|
- }
|
|
|
|
1256
|
- for _, v := range parentDepartment {
|
|
|
|
1257
|
- chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
|
1258
|
- }
|
|
|
|
1259
|
- }
|
1193
|
+// var departmemtList []*domain.Department
|
|
|
|
1194
|
+// var err error
|
|
|
|
1195
|
+// if len(targetUser.DepartmentId) > 0 {
|
|
|
|
1196
|
+// _, departmemtList, err = departmentRepo.Find(map[string]interface{}{
|
|
|
|
1197
|
+// "ids": targetUser.DepartmentId,
|
|
|
|
1198
|
+// })
|
|
|
|
1199
|
+// if err != nil {
|
|
|
|
1200
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的部门列表"+err.Error())
|
|
|
|
1201
|
+// }
|
|
|
|
1202
|
+// }
|
|
|
|
1203
|
+// if len(departmemtList) == 0 {
|
|
|
|
1204
|
+// //找不到员工的部门
|
|
|
|
1205
|
+// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
1206
|
+// "transactionContext": transactionContext,
|
|
|
|
1207
|
+// })
|
|
|
|
1208
|
+// companyData, err := companyRepo.FindOne(map[string]interface{}{
|
|
|
|
1209
|
+// "id": targetUser.CompanyId,
|
|
|
|
1210
|
+// })
|
|
|
|
1211
|
+// if err != nil {
|
|
|
|
1212
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
|
|
|
|
1213
|
+// }
|
|
|
|
1214
|
+// //公司作为最顶级
|
|
|
|
1215
|
+// departmemtList = append(departmemtList, &domain.Department{
|
|
|
|
1216
|
+// Id: 0,
|
|
|
|
1217
|
+// CompanyId: companyData.Id,
|
|
|
|
1218
|
+// Level: 0,
|
|
|
|
1219
|
+// Name: companyData.Name,
|
|
|
|
1220
|
+// ParentId: 0,
|
|
|
|
1221
|
+// ChargeUserIds: companyData.ChargeUserIds,
|
|
|
|
1222
|
+// Path: "",
|
|
|
|
1223
|
+// CreatedAt: time.Time{},
|
|
|
|
1224
|
+// UpdatedAt: time.Time{},
|
|
|
|
1225
|
+// DeletedAt: &time.Time{},
|
|
|
|
1226
|
+// })
|
|
1260
|
|
1227
|
|
|
1261
|
- var chargeUserList []*domain.User
|
|
|
|
1262
|
- if len(chargeUserIds) > 0 {
|
|
|
|
1263
|
- _, chargeUserList, err = userRepo.Find(map[string]interface{}{
|
|
|
|
1264
|
- "ids": chargeUserIds,
|
|
|
|
1265
|
- "status": 1, //正常的用户
|
|
|
|
1266
|
- })
|
|
|
|
1267
|
- if err != nil {
|
|
|
|
1268
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
|
|
|
|
1269
|
- }
|
|
|
|
1270
|
- }
|
|
|
|
1271
|
- return chargeUserList, nil
|
|
|
|
1272
|
-}
|
1228
|
+// }
|
|
|
|
1229
|
+// //获取部门管理员
|
|
|
|
1230
|
+// var chargeUserIds []int64
|
|
|
|
1231
|
+// var targetUserAsManager *domain.Department
|
|
|
|
1232
|
+// loop:
|
|
|
|
1233
|
+// for _, v := range departmemtList {
|
|
|
|
1234
|
+// if len(v.ChargeUserIds) == 0 {
|
|
|
|
1235
|
+// continue
|
|
|
|
1236
|
+// }
|
|
|
|
1237
|
+// //检查员工自身是否是管理员
|
|
|
|
1238
|
+// for _, vv := range v.ChargeUserIds {
|
|
|
|
1239
|
+// if vv == targetUser.Id {
|
|
|
|
1240
|
+// targetUserAsManager = v
|
|
|
|
1241
|
+// break loop
|
|
|
|
1242
|
+// }
|
|
|
|
1243
|
+// }
|
|
|
|
1244
|
+// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
|
1245
|
+// }
|
|
|
|
1246
|
+// if targetUserAsManager != nil {
|
|
|
|
1247
|
+// //清空原有的管理员
|
|
|
|
1248
|
+// chargeUserIds = []int64{}
|
|
|
|
1249
|
+// //员工自身是否是管理员,查找父级部门
|
|
|
|
1250
|
+// _, parentDepartment, err := departmentRepo.Find(map[string]interface{}{
|
|
|
|
1251
|
+// "id": targetUserAsManager.ParentId,
|
|
|
|
1252
|
+// })
|
|
|
|
1253
|
+// if err != nil {
|
|
|
|
1254
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工现在部门的父级"+err.Error())
|
|
|
|
1255
|
+// }
|
|
|
|
1256
|
+// for _, v := range parentDepartment {
|
|
|
|
1257
|
+// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
|
1258
|
+// }
|
|
|
|
1259
|
+// }
|
|
1273
|
|
1260
|
|
|
1274
|
-// TODO
|
|
|
|
1275
|
-func (srv *StaffAssessServeice) getStaffSuperV2(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
|
1261
|
+// var chargeUserList []*domain.User
|
|
|
|
1262
|
+// if len(chargeUserIds) > 0 {
|
|
|
|
1263
|
+// _, chargeUserList, err = userRepo.Find(map[string]interface{}{
|
|
|
|
1264
|
+// "ids": chargeUserIds,
|
|
|
|
1265
|
+// "status": 1, //正常的用户
|
|
|
|
1266
|
+// })
|
|
|
|
1267
|
+// if err != nil {
|
|
|
|
1268
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
|
|
|
|
1269
|
+// }
|
|
|
|
1270
|
+// }
|
|
|
|
1271
|
+// return chargeUserList, nil
|
|
|
|
1272
|
+// }
|
|
1276
|
|
1273
|
|
|
|
|
1274
|
+// 获取员工的上级是谁
|
|
|
|
1275
|
+func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
|
|
|
|
1276
|
+ if targetUser.ParentId == 0 {
|
|
|
|
1277
|
+ return nil, nil
|
|
|
|
1278
|
+ }
|
|
1277
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
1279
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
1278
|
"transactionContext": transactionContext,
|
1280
|
"transactionContext": transactionContext,
|
|
1279
|
})
|
1281
|
})
|
|
1280
|
|
1282
|
|
|
1281
|
- userRepo.Find(map[string]interface{}{})
|
|
|
|
1282
|
-
|
|
|
|
1283
|
- return nil, nil
|
1283
|
+ userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
|
1284
|
+ "id": targetUser.ParentId,
|
|
|
|
1285
|
+ })
|
|
|
|
1286
|
+ if err != nil {
|
|
|
|
1287
|
+ return nil, err
|
|
|
|
1288
|
+ }
|
|
|
|
1289
|
+ return []*domain.User{userData}, nil
|
|
1284
|
}
|
1290
|
}
|
|
1285
|
|
1291
|
|
|
1286
|
-func (srv *StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) {
|
1292
|
+func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) {
|
|
1287
|
cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": context})
|
1293
|
cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": context})
|
|
1288
|
_, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessId, "limit": 1})
|
1294
|
_, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessId, "limit": 1})
|
|
1289
|
if err != nil || len(caches) == 0 {
|
1295
|
if err != nil || len(caches) == 0 {
|