作者 tangxvhui

暂存

... ... @@ -1592,36 +1592,37 @@ func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.T
log.Logger.Error("获取公司信息," + err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
}
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //查找员工的部门
// var departmentList []*domain.Department
// if len(userData.DepartmentId) > 0 {
// }
var supperUserList []*domain.User
if len(userData.DepartmentId) > 0 {
_, departmentList, err := departmentRepo.Find(map[string]interface{}{
"ids": userData.DepartmentId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
}
var chargeUserIds []int64
for _, v := range departmentList {
chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
}
if len(chargeUserIds) > 0 {
_, supperUserList, err = userRepo.Find(map[string]interface{}{
"ids": chargeUserIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
}
}
}
// var supperUserList []*domain.User
// if len(userData.DepartmentId) > 0 {
// _, departmentList, err := departmentRepo.Find(map[string]interface{}{
// "ids": userData.DepartmentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
// }
// var chargeUserIds []int64
// for _, v := range departmentList {
// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
// }
// if len(chargeUserIds) > 0 {
// _, supperUserList, err = userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
// }
// }
// }
supperUserList, _ := srv.getStaffSuper(transactionContext, *userData)
userInfo := adapter.StaffInfo{
UserName: userData.Name,
CompanyName: companyData.Name,
... ... @@ -1719,7 +1720,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
}
//保存信息
for i := range assessContentList {
_, err = assessContentRepo.Save(assessContentList[i])
... ... @@ -1774,7 +1774,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA
}
//获取员工的上级是谁 ,TODO
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]domain.User, error) {
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -1793,6 +1793,28 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran
}
}
if len(departmemtList) == 0 {
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyData, err := companyRepo.FindOne(map[string]interface{}{
"id": targetUser.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
}
//公司作为最顶级
departmemtList = append(departmemtList, &domain.Department{
Id: 0,
CompanyId: companyData.Id,
Level: 0,
Name: companyData.Name,
ParentId: 0,
ChargeUserIds: companyData.ChargeUserIds,
Path: "",
CreatedAt: time.Time{},
UpdatedAt: time.Time{},
DeletedAt: &time.Time{},
})
}
//获取部门管理员
... ... @@ -1836,14 +1858,5 @@ loop:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
}
}
if len(chargeUserList) == 0 {
//如果都找不到数据
}
// _, chargeUserList, err := userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// })
return nil, nil
return chargeUserList, nil
}
... ...