|
...
|
...
|
@@ -828,106 +828,106 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a |
|
|
|
}
|
|
|
|
|
|
|
|
// 选择员工评估可邀请的用户
|
|
|
|
func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
|
}()
|
|
|
|
//获取被评估的目标用户
|
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
})
|
|
|
|
//获取公司信息
|
|
|
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
})
|
|
|
|
companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
|
|
|
|
"id": param.CompanyId,
|
|
|
|
})
|
|
|
|
targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
|
"id": param.TargetUserId,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
|
|
|
|
}
|
|
|
|
//获取被评估的目标用户的部门
|
|
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
})
|
|
|
|
var targetUserDepartment []*domain.Department
|
|
|
|
if len(targetUser.DepartmentId) > 0 {
|
|
|
|
_, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
|
|
|
|
"ids": targetUser.DepartmentId,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取部门主管的id
|
|
|
|
targetUserCharge := map[int64]struct{}{}
|
|
|
|
for _, v := range targetUserDepartment {
|
|
|
|
for _, vv := range v.ChargeUserIds {
|
|
|
|
targetUserCharge[vv] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
targetUserDepartmentMap := map[int64]struct{}{}
|
|
|
|
for _, v := range targetUserDepartment {
|
|
|
|
targetUserDepartmentMap[v.Id] = struct{}{}
|
|
|
|
}
|
|
|
|
//查询员工数据
|
|
|
|
condition := map[string]interface{}{
|
|
|
|
"companyId": param.CompanyId,
|
|
|
|
"name": param.InviteUserName,
|
|
|
|
"limit": 20,
|
|
|
|
"status": 1,
|
|
|
|
}
|
|
|
|
if param.PageSize > 0 {
|
|
|
|
condition["limit"] = param.PageSize
|
|
|
|
}
|
|
|
|
offset := (param.PageNumber - 1) * param.PageSize
|
|
|
|
if offset > 0 {
|
|
|
|
condition["offset"] = offset
|
|
|
|
}
|
|
|
|
cnt, userList, err := userRepo.Find(condition)
|
|
|
|
if err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
|
|
|
|
}
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
listData := []adapter.SelectInviteUser{}
|
|
|
|
companyName := ""
|
|
|
|
if companyInfo != nil {
|
|
|
|
companyName = companyInfo.Name
|
|
|
|
}
|
|
|
|
for _, v := range userList {
|
|
|
|
item := adapter.SelectInviteUser{
|
|
|
|
UserId: int(v.Id),
|
|
|
|
UserName: v.Name,
|
|
|
|
CompanyName: companyName,
|
|
|
|
IsSupper: false,
|
|
|
|
Types: 2, //默认是不同上级
|
|
|
|
}
|
|
|
|
if _, ok := targetUserCharge[v.Id]; ok {
|
|
|
|
item.IsSupper = true
|
|
|
|
}
|
|
|
|
for _, vv := range v.DepartmentId {
|
|
|
|
if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
|
|
|
|
item.Types = 1 //设为相同上级
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
listData = append(listData, item)
|
|
|
|
}
|
|
|
|
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
|
}
|
|
|
|
// func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
|
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
|
// if err != nil {
|
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
// }
|
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
// }
|
|
|
|
// defer func() {
|
|
|
|
// _ = transactionContext.RollbackTransaction()
|
|
|
|
// }()
|
|
|
|
// //获取被评估的目标用户
|
|
|
|
// userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
|
// "transactionContext": transactionContext,
|
|
|
|
// })
|
|
|
|
// //获取公司信息
|
|
|
|
// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
// "transactionContext": transactionContext,
|
|
|
|
// })
|
|
|
|
// companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
|
|
|
|
// "id": param.CompanyId,
|
|
|
|
// })
|
|
|
|
// targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
|
// "id": param.TargetUserId,
|
|
|
|
// })
|
|
|
|
// if err != nil {
|
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
|
|
|
|
// }
|
|
|
|
// //获取被评估的目标用户的部门
|
|
|
|
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
|
// "transactionContext": transactionContext,
|
|
|
|
// })
|
|
|
|
// var targetUserDepartment []*domain.Department
|
|
|
|
// if len(targetUser.DepartmentId) > 0 {
|
|
|
|
// _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
|
|
|
|
// "ids": targetUser.DepartmentId,
|
|
|
|
// })
|
|
|
|
// if err != nil {
|
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //获取部门主管的id
|
|
|
|
// targetUserCharge := map[int64]struct{}{}
|
|
|
|
// for _, v := range targetUserDepartment {
|
|
|
|
// for _, vv := range v.ChargeUserIds {
|
|
|
|
// targetUserCharge[vv] = struct{}{}
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //
|
|
|
|
// targetUserDepartmentMap := map[int64]struct{}{}
|
|
|
|
// for _, v := range targetUserDepartment {
|
|
|
|
// targetUserDepartmentMap[v.Id] = struct{}{}
|
|
|
|
// }
|
|
|
|
// //查询员工数据
|
|
|
|
// condition := map[string]interface{}{
|
|
|
|
// "companyId": param.CompanyId,
|
|
|
|
// "name": param.InviteUserName,
|
|
|
|
// "limit": 20,
|
|
|
|
// "status": 1,
|
|
|
|
// }
|
|
|
|
// if param.PageSize > 0 {
|
|
|
|
// condition["limit"] = param.PageSize
|
|
|
|
// }
|
|
|
|
// offset := (param.PageNumber - 1) * param.PageSize
|
|
|
|
// if offset > 0 {
|
|
|
|
// condition["offset"] = offset
|
|
|
|
// }
|
|
|
|
// cnt, userList, err := userRepo.Find(condition)
|
|
|
|
// if err != nil {
|
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
|
|
|
|
// }
|
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
// }
|
|
|
|
// listData := []adapter.SelectInviteUser{}
|
|
|
|
// companyName := ""
|
|
|
|
// if companyInfo != nil {
|
|
|
|
// companyName = companyInfo.Name
|
|
|
|
// }
|
|
|
|
// for _, v := range userList {
|
|
|
|
// item := adapter.SelectInviteUser{
|
|
|
|
// UserId: int(v.Id),
|
|
|
|
// UserName: v.Name,
|
|
|
|
// CompanyName: companyName,
|
|
|
|
// IsSupper: false,
|
|
|
|
// Types: 2, //默认是不同上级
|
|
|
|
// }
|
|
|
|
// if _, ok := targetUserCharge[v.Id]; ok {
|
|
|
|
// item.IsSupper = true
|
|
|
|
// }
|
|
|
|
// for _, vv := range v.DepartmentId {
|
|
|
|
// if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
|
|
|
|
// item.Types = 1 //设为相同上级
|
|
|
|
// break
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// listData = append(listData, item)
|
|
|
|
// }
|
|
|
|
// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 根据staffAssessId 获取评估的填写信息
|
|
|
|
func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|
...
|
...
|
|