|
@@ -828,106 +828,106 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a |
|
@@ -828,106 +828,106 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a |
|
828
|
}
|
828
|
}
|
|
829
|
|
829
|
|
|
830
|
// 选择员工评估可邀请的用户
|
830
|
// 选择员工评估可邀请的用户
|
|
831
|
-func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
|
|
|
|
832
|
- transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
|
833
|
- if err != nil {
|
|
|
|
834
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
835
|
- }
|
|
|
|
836
|
- if err := transactionContext.StartTransaction(); err != nil {
|
|
|
|
837
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
838
|
- }
|
|
|
|
839
|
- defer func() {
|
|
|
|
840
|
- _ = transactionContext.RollbackTransaction()
|
|
|
|
841
|
- }()
|
|
|
|
842
|
- //获取被评估的目标用户
|
|
|
|
843
|
- userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
|
844
|
- "transactionContext": transactionContext,
|
|
|
|
845
|
- })
|
|
|
|
846
|
- //获取公司信息
|
|
|
|
847
|
- companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
848
|
- "transactionContext": transactionContext,
|
|
|
|
849
|
- })
|
|
|
|
850
|
- companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
|
|
|
|
851
|
- "id": param.CompanyId,
|
|
|
|
852
|
- })
|
|
|
|
853
|
- targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
|
854
|
- "id": param.TargetUserId,
|
|
|
|
855
|
- })
|
|
|
|
856
|
- if err != nil {
|
|
|
|
857
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
|
|
|
|
858
|
- }
|
|
|
|
859
|
- //获取被评估的目标用户的部门
|
|
|
|
860
|
- departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
|
861
|
- "transactionContext": transactionContext,
|
|
|
|
862
|
- })
|
|
|
|
863
|
- var targetUserDepartment []*domain.Department
|
|
|
|
864
|
- if len(targetUser.DepartmentId) > 0 {
|
|
|
|
865
|
- _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
|
|
|
|
866
|
- "ids": targetUser.DepartmentId,
|
|
|
|
867
|
- })
|
|
|
|
868
|
- if err != nil {
|
|
|
|
869
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
|
870
|
- }
|
|
|
|
871
|
- }
|
|
|
|
872
|
- //获取部门主管的id
|
|
|
|
873
|
- targetUserCharge := map[int64]struct{}{}
|
|
|
|
874
|
- for _, v := range targetUserDepartment {
|
|
|
|
875
|
- for _, vv := range v.ChargeUserIds {
|
|
|
|
876
|
- targetUserCharge[vv] = struct{}{}
|
|
|
|
877
|
- }
|
|
|
|
878
|
- }
|
|
|
|
879
|
- //
|
|
|
|
880
|
- targetUserDepartmentMap := map[int64]struct{}{}
|
|
|
|
881
|
- for _, v := range targetUserDepartment {
|
|
|
|
882
|
- targetUserDepartmentMap[v.Id] = struct{}{}
|
|
|
|
883
|
- }
|
|
|
|
884
|
- //查询员工数据
|
|
|
|
885
|
- condition := map[string]interface{}{
|
|
|
|
886
|
- "companyId": param.CompanyId,
|
|
|
|
887
|
- "name": param.InviteUserName,
|
|
|
|
888
|
- "limit": 20,
|
|
|
|
889
|
- "status": 1,
|
|
|
|
890
|
- }
|
|
|
|
891
|
- if param.PageSize > 0 {
|
|
|
|
892
|
- condition["limit"] = param.PageSize
|
|
|
|
893
|
- }
|
|
|
|
894
|
- offset := (param.PageNumber - 1) * param.PageSize
|
|
|
|
895
|
- if offset > 0 {
|
|
|
|
896
|
- condition["offset"] = offset
|
|
|
|
897
|
- }
|
|
|
|
898
|
- cnt, userList, err := userRepo.Find(condition)
|
|
|
|
899
|
- if err != nil {
|
|
|
|
900
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
|
|
|
|
901
|
- }
|
|
|
|
902
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
903
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
904
|
- }
|
|
|
|
905
|
- listData := []adapter.SelectInviteUser{}
|
|
|
|
906
|
- companyName := ""
|
|
|
|
907
|
- if companyInfo != nil {
|
|
|
|
908
|
- companyName = companyInfo.Name
|
|
|
|
909
|
- }
|
|
|
|
910
|
- for _, v := range userList {
|
|
|
|
911
|
- item := adapter.SelectInviteUser{
|
|
|
|
912
|
- UserId: int(v.Id),
|
|
|
|
913
|
- UserName: v.Name,
|
|
|
|
914
|
- CompanyName: companyName,
|
|
|
|
915
|
- IsSupper: false,
|
|
|
|
916
|
- Types: 2, //默认是不同上级
|
|
|
|
917
|
- }
|
|
|
|
918
|
- if _, ok := targetUserCharge[v.Id]; ok {
|
|
|
|
919
|
- item.IsSupper = true
|
|
|
|
920
|
- }
|
|
|
|
921
|
- for _, vv := range v.DepartmentId {
|
|
|
|
922
|
- if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
|
|
|
|
923
|
- item.Types = 1 //设为相同上级
|
|
|
|
924
|
- break
|
|
|
|
925
|
- }
|
|
|
|
926
|
- }
|
|
|
|
927
|
- listData = append(listData, item)
|
|
|
|
928
|
- }
|
|
|
|
929
|
- return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
|
930
|
-}
|
831
|
+// func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
|
|
|
|
832
|
+// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
|
833
|
+// if err != nil {
|
|
|
|
834
|
+// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
835
|
+// }
|
|
|
|
836
|
+// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
|
837
|
+// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
838
|
+// }
|
|
|
|
839
|
+// defer func() {
|
|
|
|
840
|
+// _ = transactionContext.RollbackTransaction()
|
|
|
|
841
|
+// }()
|
|
|
|
842
|
+// //获取被评估的目标用户
|
|
|
|
843
|
+// userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
|
844
|
+// "transactionContext": transactionContext,
|
|
|
|
845
|
+// })
|
|
|
|
846
|
+// //获取公司信息
|
|
|
|
847
|
+// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
848
|
+// "transactionContext": transactionContext,
|
|
|
|
849
|
+// })
|
|
|
|
850
|
+// companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
|
|
|
|
851
|
+// "id": param.CompanyId,
|
|
|
|
852
|
+// })
|
|
|
|
853
|
+// targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
|
854
|
+// "id": param.TargetUserId,
|
|
|
|
855
|
+// })
|
|
|
|
856
|
+// if err != nil {
|
|
|
|
857
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
|
|
|
|
858
|
+// }
|
|
|
|
859
|
+// //获取被评估的目标用户的部门
|
|
|
|
860
|
+// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
|
861
|
+// "transactionContext": transactionContext,
|
|
|
|
862
|
+// })
|
|
|
|
863
|
+// var targetUserDepartment []*domain.Department
|
|
|
|
864
|
+// if len(targetUser.DepartmentId) > 0 {
|
|
|
|
865
|
+// _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
|
|
|
|
866
|
+// "ids": targetUser.DepartmentId,
|
|
|
|
867
|
+// })
|
|
|
|
868
|
+// if err != nil {
|
|
|
|
869
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
|
870
|
+// }
|
|
|
|
871
|
+// }
|
|
|
|
872
|
+// //获取部门主管的id
|
|
|
|
873
|
+// targetUserCharge := map[int64]struct{}{}
|
|
|
|
874
|
+// for _, v := range targetUserDepartment {
|
|
|
|
875
|
+// for _, vv := range v.ChargeUserIds {
|
|
|
|
876
|
+// targetUserCharge[vv] = struct{}{}
|
|
|
|
877
|
+// }
|
|
|
|
878
|
+// }
|
|
|
|
879
|
+// //
|
|
|
|
880
|
+// targetUserDepartmentMap := map[int64]struct{}{}
|
|
|
|
881
|
+// for _, v := range targetUserDepartment {
|
|
|
|
882
|
+// targetUserDepartmentMap[v.Id] = struct{}{}
|
|
|
|
883
|
+// }
|
|
|
|
884
|
+// //查询员工数据
|
|
|
|
885
|
+// condition := map[string]interface{}{
|
|
|
|
886
|
+// "companyId": param.CompanyId,
|
|
|
|
887
|
+// "name": param.InviteUserName,
|
|
|
|
888
|
+// "limit": 20,
|
|
|
|
889
|
+// "status": 1,
|
|
|
|
890
|
+// }
|
|
|
|
891
|
+// if param.PageSize > 0 {
|
|
|
|
892
|
+// condition["limit"] = param.PageSize
|
|
|
|
893
|
+// }
|
|
|
|
894
|
+// offset := (param.PageNumber - 1) * param.PageSize
|
|
|
|
895
|
+// if offset > 0 {
|
|
|
|
896
|
+// condition["offset"] = offset
|
|
|
|
897
|
+// }
|
|
|
|
898
|
+// cnt, userList, err := userRepo.Find(condition)
|
|
|
|
899
|
+// if err != nil {
|
|
|
|
900
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
|
|
|
|
901
|
+// }
|
|
|
|
902
|
+// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
903
|
+// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
904
|
+// }
|
|
|
|
905
|
+// listData := []adapter.SelectInviteUser{}
|
|
|
|
906
|
+// companyName := ""
|
|
|
|
907
|
+// if companyInfo != nil {
|
|
|
|
908
|
+// companyName = companyInfo.Name
|
|
|
|
909
|
+// }
|
|
|
|
910
|
+// for _, v := range userList {
|
|
|
|
911
|
+// item := adapter.SelectInviteUser{
|
|
|
|
912
|
+// UserId: int(v.Id),
|
|
|
|
913
|
+// UserName: v.Name,
|
|
|
|
914
|
+// CompanyName: companyName,
|
|
|
|
915
|
+// IsSupper: false,
|
|
|
|
916
|
+// Types: 2, //默认是不同上级
|
|
|
|
917
|
+// }
|
|
|
|
918
|
+// if _, ok := targetUserCharge[v.Id]; ok {
|
|
|
|
919
|
+// item.IsSupper = true
|
|
|
|
920
|
+// }
|
|
|
|
921
|
+// for _, vv := range v.DepartmentId {
|
|
|
|
922
|
+// if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
|
|
|
|
923
|
+// item.Types = 1 //设为相同上级
|
|
|
|
924
|
+// break
|
|
|
|
925
|
+// }
|
|
|
|
926
|
+// }
|
|
|
|
927
|
+// listData = append(listData, item)
|
|
|
|
928
|
+// }
|
|
|
|
929
|
+// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
|
930
|
+// }
|
|
931
|
|
931
|
|
|
932
|
// 根据staffAssessId 获取评估的填写信息
|
932
|
// 根据staffAssessId 获取评估的填写信息
|
|
933
|
func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|
933
|
func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|