作者 郑周

1 返回分组详情,分组下的用户ID

@@ -186,6 +186,7 @@ type( @@ -186,6 +186,7 @@ type(
186 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 186 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
187 ParentId int64 `json:"parentId,omitempty"` // 父级ID 187 ParentId int64 `json:"parentId,omitempty"` // 父级ID
188 Name string `json:"name,omitempty"` // 部门名称 188 Name string `json:"name,omitempty"` // 部门名称
  189 + UserIds []int64 `json:"userIds,omitempty"` // 部门下的用户
189 } 190 }
190 UserSearchRequest{ 191 UserSearchRequest{
191 Page int `json:"page,optional"` 192 Page int `json:"page,optional"`
@@ -4,6 +4,8 @@ import ( @@ -4,6 +4,8 @@ import (
4 "context" 4 "context"
5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
8 10
9 "github.com/zeromicro/go-zero/core/logx" 11 "github.com/zeromicro/go-zero/core/logx"
@@ -24,17 +26,32 @@ func NewSystemGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemG @@ -24,17 +26,32 @@ func NewSystemGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemG
24 } 26 }
25 27
26 func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) { 28 func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) {
  29 + var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
27 var conn = l.svcCtx.DefaultDBConn() 30 var conn = l.svcCtx.DefaultDBConn()
28 department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id) 31 department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id)
29 if err != nil { 32 if err != nil {
30 return nil, xerr.NewErrMsg("数据不存在") 33 return nil, xerr.NewErrMsg("数据不存在")
31 } 34 }
  35 +
  36 + // 部门下的用户
  37 + _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().
  38 + WithKV("companyId", userToken.CompanyId).
  39 + WithKV("auditStatus", domain.UserAuditStatusPassed).
  40 + WithKV("departmentId", department.Id))
  41 + if err != nil {
  42 + return nil, err
  43 + }
  44 + ids := make([]int64, 0)
  45 + for i := range users {
  46 + ids = append(ids, users[i].Id)
  47 + }
32 resp = &types.DepartmentGetResponse{ 48 resp = &types.DepartmentGetResponse{
33 Department: types.Department{ 49 Department: types.Department{
34 Id: department.Id, 50 Id: department.Id,
35 CompanyId: department.CompanyId, 51 CompanyId: department.CompanyId,
36 ParentId: department.ParentId, 52 ParentId: department.ParentId,
37 Name: department.Name, 53 Name: department.Name,
  54 + UserIds: ids,
38 }, 55 },
39 } 56 }
40 return resp, nil 57 return resp, nil
@@ -519,10 +519,11 @@ type Account struct { @@ -519,10 +519,11 @@ type Account struct {
519 } 519 }
520 520
521 type Department struct { 521 type Department struct {
522 - Id int64 `json:"id,omitempty"` // 部门ID  
523 - CompanyId int64 `json:"companyId,omitempty"` // 公司ID  
524 - ParentId int64 `json:"parentId,omitempty"` // 父级ID  
525 - Name string `json:"name,omitempty"` // 部门名称 522 + Id int64 `json:"id,omitempty"` // 部门ID
  523 + CompanyId int64 `json:"companyId,omitempty"` // 公司ID
  524 + ParentId int64 `json:"parentId,omitempty"` // 父级ID
  525 + Name string `json:"name,omitempty"` // 部门名称
  526 + UserIds []int64 `json:"userIds,omitempty"` // 部门下的用户
526 } 527 }
527 528
528 type UserSearchRequest struct { 529 type UserSearchRequest struct {