作者 tangxvhui

修改 员工直属上级 展示

@@ -8,4 +8,7 @@ prod 环境 http://performance-back-prd.fjmaimaimai.com/ @@ -8,4 +8,7 @@ prod 环境 http://performance-back-prd.fjmaimaimai.com/
8 前端页面地址 8 前端页面地址
9 test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login 9 test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login
10 10
11 -测试账号 17708397664 密码123456  
  11 +测试账号 17708397664 密码123456
  12 +
  13 +
  14 +短信模板ID:5475050 短信内容: 您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦
@@ -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 {
@@ -832,3 +832,77 @@ func (srv StaffAssessServeice) ListTargetUserSuperAssess(param *query.ListTarget @@ -832,3 +832,77 @@ func (srv StaffAssessServeice) ListTargetUserSuperAssess(param *query.ListTarget
832 } 832 }
833 return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil 833 return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
834 } 834 }
  835 +
  836 +// 选择员工评估可邀请的用户
  837 +func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
  838 + transactionContext, err := factory.CreateTransactionContext(nil)
  839 + if err != nil {
  840 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  841 + }
  842 + if err := transactionContext.StartTransaction(); err != nil {
  843 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  844 + }
  845 + defer func() {
  846 + _ = transactionContext.RollbackTransaction()
  847 + }()
  848 + //获取被评估的目标用户
  849 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  850 + "transactionContext": transactionContext,
  851 + })
  852 + //获取公司信息
  853 + companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
  854 + "transactionContext": transactionContext,
  855 + })
  856 + companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
  857 + "id": param.CompanyId,
  858 + })
  859 + targetUser, err := userRepo.FindOne(map[string]interface{}{
  860 + "id": param.TargetUserId,
  861 + })
  862 + if err != nil {
  863 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
  864 + }
  865 +
  866 + //查询员工数据
  867 + condition := map[string]interface{}{
  868 + "companyId": param.CompanyId,
  869 + "name": param.InviteUserName,
  870 + "limit": 20,
  871 + "status": 1,
  872 + }
  873 + if param.PageSize > 0 {
  874 + condition["limit"] = param.PageSize
  875 + }
  876 + offset := (param.PageNumber - 1) * param.PageSize
  877 + if offset > 0 {
  878 + condition["offset"] = offset
  879 + }
  880 + cnt, userList, err := userRepo.Find(condition)
  881 + if err != nil {
  882 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
  883 + }
  884 + if err := transactionContext.CommitTransaction(); err != nil {
  885 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  886 + }
  887 + listData := []adapter.SelectInviteUser{}
  888 + companyName := ""
  889 + if companyInfo != nil {
  890 + companyName = companyInfo.Name
  891 + }
  892 + for _, v := range userList {
  893 + _ = v
  894 + _ = companyName
  895 + item := adapter.SelectInviteUser{
  896 + UserId: int(v.Id),
  897 + UserName: v.Name,
  898 + CompanyName: companyName,
  899 + IsSupper: false,
  900 + Types: 2, //默认是不同上级
  901 + }
  902 + if targetUser.ParentId == v.ParentId {
  903 + item.Types = 1
  904 + }
  905 + listData = append(listData, item)
  906 + }
  907 + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
  908 +}
@@ -143,12 +143,10 @@ func (c *StaffAssessController) SelectAssessInviteUser() { @@ -143,12 +143,10 @@ func (c *StaffAssessController) SelectAssessInviteUser() {
143 c.Response(nil, e) 143 c.Response(nil, e)
144 return 144 return
145 } 145 }
146 - // paramReq.CompanyId = 1  
147 - // paramReq.TargetUserId = 1  
148 userReq := middlewares.GetUser(c.Ctx) 146 userReq := middlewares.GetUser(c.Ctx)
149 paramReq.CompanyId = int(userReq.CompanyId) 147 paramReq.CompanyId = int(userReq.CompanyId)
150 paramReq.TargetUserId = int(userReq.UserId) 148 paramReq.TargetUserId = int(userReq.UserId)
151 - data, err := srv.SelectAssessInviteUser(paramReq) 149 + data, err := srv.SelectAssessInviteUserV2(paramReq)
152 c.Response(data, err) 150 c.Response(data, err)
153 } 151 }
154 152