正在显示
1 个修改的文件
包含
10 行增加
和
2 行删除
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/query" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/query" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" |
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" | ||
12 | "time" | 13 | "time" |
13 | ) | 14 | ) |
14 | 15 | ||
@@ -486,6 +487,7 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -486,6 +487,7 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
486 | userRepository = value | 487 | userRepository = value |
487 | } | 488 | } |
488 | var company *domain.Company | 489 | var company *domain.Company |
490 | + var mapCompany = make(map[int64]*domain.Company) | ||
489 | var dtoUsers []*dto.UserDto | 491 | var dtoUsers []*dto.UserDto |
490 | queryOptions := utils.ObjectToMap(listUserQuery) | 492 | queryOptions := utils.ObjectToMap(listUserQuery) |
491 | if len(listUserQuery.Phone) > 0 { | 493 | if len(listUserQuery.Phone) > 0 { |
@@ -502,8 +504,14 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -502,8 +504,14 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
502 | for i := range users { | 504 | for i := range users { |
503 | user := users[i] | 505 | user := users[i] |
504 | userDto := &dto.UserDto{} | 506 | userDto := &dto.UserDto{} |
505 | - if company == nil && user.CompanyId != 0 { | ||
506 | - _, company, _ = factory.FastPgCompany(transactionContext, user.CompanyId) | 507 | + var ok bool |
508 | + if company, ok = mapCompany[user.CompanyId]; !ok { | ||
509 | + _, company, err = factory.FastPgCompany(transactionContext, user.CompanyId) | ||
510 | + if err != nil { | ||
511 | + log.Logger.Error(err.Error()) | ||
512 | + continue | ||
513 | + } | ||
514 | + mapCompany[company.CompanyId] = company | ||
507 | } | 515 | } |
508 | if listUserQuery.PullRealTime { | 516 | if listUserQuery.PullRealTime { |
509 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) | 517 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) |
-
请 注册 或 登录 后发表评论