作者 yangfu

fix: 用户按部门搜索修改

@@ -531,6 +531,18 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in @@ -531,6 +531,18 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in
531 queryOptions["userBaseId"] = userBase.UserBaseId 531 queryOptions["userBaseId"] = userBase.UserBaseId
532 } 532 }
533 } 533 }
  534 + if len(listUserQuery.DepName) > 0 {
  535 + orgRepository, _, _ := factory.FastPgOrg(transactionContext, 0)
  536 + _, orgs, err := orgRepository.Find(map[string]interface{}{"companyId": listUserQuery.CompanyId, "matchOrgName": listUserQuery.DepName})
  537 + if err != nil {
  538 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  539 + }
  540 + if len(orgs) > 0 {
  541 + queryOptions["inDepartmentIds"] = domain.Organizations(orgs).OrgIds()
  542 + }
  543 + listUserQuery.DepName = ""
  544 + delete(queryOptions, "depName")
  545 + }
534 if count, users, err := userRepository.Find(queryOptions); err != nil { 546 if count, users, err := userRepository.Find(queryOptions); err != nil {
535 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 547 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
536 } else { 548 } else {
@@ -2,6 +2,7 @@ package domain @@ -2,6 +2,7 @@ package domain
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/tal-tech/go-zero/core/collection"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
6 "strconv" 7 "strconv"
7 "strings" 8 "strings"
@@ -243,3 +244,13 @@ type BatchAddOrgItem struct { @@ -243,3 +244,13 @@ type BatchAddOrgItem struct {
243 // 失败理由 244 // 失败理由
244 FailReason string `json:"failReason"` 245 FailReason string `json:"failReason"`
245 } 246 }
  247 +
  248 +type Organizations []*Org
  249 +
  250 +func (list Organizations) OrgIds() []int64 {
  251 + set := collection.NewSet()
  252 + for i := range list {
  253 + set.Add(list[i].OrgId)
  254 + }
  255 + return set.KeysInt64()
  256 +}