正在显示
5 个修改的文件
包含
35 行增加
和
13 行删除
| @@ -59,6 +59,7 @@ type ( | @@ -59,6 +59,7 @@ type ( | ||
| 59 | DepartmentListRequest { | 59 | DepartmentListRequest { |
| 60 | Page int `json:"page"` | 60 | Page int `json:"page"` |
| 61 | Size int `json:"size"` | 61 | Size int `json:"size"` |
| 62 | + IncludeRootCompany bool `json:"includeRootCompany,optional"` // 包含公司(把公司当作部门作为顶级节点 部门ID:0) | ||
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | DepartmentListResponse { | 65 | DepartmentListResponse { |
| @@ -209,7 +209,7 @@ type( | @@ -209,7 +209,7 @@ type( | ||
| 209 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) | 209 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) |
| 210 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 | 210 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 |
| 211 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) | 211 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) |
| 212 | - DepartmentId int64 `json:"departmentId,optional"` // 按部门过滤 | 212 | + DepartmentId *int64 `json:"departmentId,optional"` // 按部门过滤 |
| 213 | } | 213 | } |
| 214 | MiniUserNewsRequest{ | 214 | MiniUserNewsRequest{ |
| 215 | AuthorId int64 `json:"authorId,optional"` // 特定作者ID | 215 | AuthorId int64 `json:"authorId,optional"` // 特定作者ID |
| @@ -274,7 +274,7 @@ type( | @@ -274,7 +274,7 @@ type( | ||
| 274 | Position string `json:"position"`// 职位 | 274 | Position string `json:"position"`// 职位 |
| 275 | } | 275 | } |
| 276 | Department struct { | 276 | Department struct { |
| 277 | - Id int64 `json:"id,omitempty"` // 部门ID | 277 | + Id int64 `json:"id"` // 部门ID |
| 278 | CompanyId int64 `json:"companyId"` // 公司ID | 278 | CompanyId int64 `json:"companyId"` // 公司ID |
| 279 | ParentId int64 `json:"parentId"` // 父级ID | 279 | ParentId int64 `json:"parentId"` // 父级ID |
| 280 | Name string `json:"name"` // 部门名称 | 280 | Name string `json:"name"` // 部门名称 |
| @@ -39,6 +39,17 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty | @@ -39,6 +39,17 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty | ||
| 39 | Total: total, | 39 | Total: total, |
| 40 | List: make([]types.Department, 0), | 40 | List: make([]types.Department, 0), |
| 41 | } | 41 | } |
| 42 | + if req.IncludeRootCompany { | ||
| 43 | + company, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId) | ||
| 44 | + if company != nil { | ||
| 45 | + resp.List = append(resp.List, types.Department{ | ||
| 46 | + Id: 0, | ||
| 47 | + CompanyId: company.Id, | ||
| 48 | + ParentId: -1, | ||
| 49 | + Name: company.Name, | ||
| 50 | + }) | ||
| 51 | + } | ||
| 52 | + } | ||
| 42 | for _, item := range list { | 53 | for _, item := range list { |
| 43 | to := types.Department{ | 54 | to := types.Department{ |
| 44 | Id: item.Id, | 55 | Id: item.Id, |
| @@ -43,11 +43,15 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | @@ -43,11 +43,15 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | ||
| 43 | onlyUsers = article.WhoRead | 43 | onlyUsers = article.WhoRead |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | - if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions(). | ||
| 47 | - WithKV("name", req.Keywords).WithKV("departmentId", req.DepartmentId).WithFindOnly()); err != nil { | 46 | + queryOptions := domain.NewQueryOptions(). |
| 47 | + WithKV("name", req.Keywords).WithFindOnly() | ||
| 48 | + if req.DepartmentId != nil && *req.DepartmentId > 0 { | ||
| 49 | + queryOptions.WithKV("departmentId", *req.DepartmentId) | ||
| 50 | + } | ||
| 51 | + if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, queryOptions); err != nil { | ||
| 48 | return nil, xerr.NewErrMsgErr("用户列表获取失败", err) | 52 | return nil, xerr.NewErrMsgErr("用户列表获取失败", err) |
| 49 | } | 53 | } |
| 50 | - if len(onlyUsers) > 0 { | 54 | + if len(onlyUsers) > 0 || (req.DepartmentId != nil && *req.DepartmentId == 0) { |
| 51 | onlyUsersMap := lo.KeyBy(onlyUsers, func(item int64) int64 { | 55 | onlyUsersMap := lo.KeyBy(onlyUsers, func(item int64) int64 { |
| 52 | return item | 56 | return item |
| 53 | }) | 57 | }) |
| @@ -55,6 +59,11 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | @@ -55,6 +59,11 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | ||
| 55 | if _, ok := onlyUsersMap[item.Id]; ok { | 59 | if _, ok := onlyUsersMap[item.Id]; ok { |
| 56 | return false | 60 | return false |
| 57 | } | 61 | } |
| 62 | + if req.DepartmentId != nil && *req.DepartmentId == 0 { | ||
| 63 | + if len(item.Departments) > 0 { | ||
| 64 | + return false | ||
| 65 | + } | ||
| 66 | + } | ||
| 58 | return true | 67 | return true |
| 59 | }) | 68 | }) |
| 60 | } | 69 | } |
| @@ -562,7 +562,7 @@ type MiniUsersListRequest struct { | @@ -562,7 +562,7 @@ type MiniUsersListRequest struct { | ||
| 562 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) | 562 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) |
| 563 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 | 563 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 |
| 564 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) | 564 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) |
| 565 | - DepartmentId int64 `json:"departmentId,optional"` // 按部门过滤 | 565 | + DepartmentId *int64 `json:"departmentId,optional"` // 按部门过滤 |
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | type MiniUserNewsRequest struct { | 568 | type MiniUserNewsRequest struct { |
| @@ -632,11 +632,11 @@ type Account struct { | @@ -632,11 +632,11 @@ type Account struct { | ||
| 632 | } | 632 | } |
| 633 | 633 | ||
| 634 | type Department struct { | 634 | type Department struct { |
| 635 | - Id int64 `json:"id,omitempty"` // 部门ID | ||
| 636 | - CompanyId int64 `json:"companyId"` // 公司ID | ||
| 637 | - ParentId int64 `json:"parentId"` // 父级ID | ||
| 638 | - Name string `json:"name"` // 部门名称 | ||
| 639 | - UserIds []int64 `json:"userIds"` // 部门下的用户 | 635 | + Id int64 `json:"id"` // 部门ID |
| 636 | + CompanyId int64 `json:"companyId"` // 公司ID | ||
| 637 | + ParentId int64 `json:"parentId"` // 父级ID | ||
| 638 | + Name string `json:"name"` // 部门名称 | ||
| 639 | + UserIds []int64 `json:"userIds"` // 部门下的用户 | ||
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | type UserSearchRequest struct { | 642 | type UserSearchRequest struct { |
| @@ -1727,8 +1727,9 @@ type DepartmentUpdateRequest struct { | @@ -1727,8 +1727,9 @@ type DepartmentUpdateRequest struct { | ||
| 1727 | } | 1727 | } |
| 1728 | 1728 | ||
| 1729 | type DepartmentListRequest struct { | 1729 | type DepartmentListRequest struct { |
| 1730 | - Page int `json:"page"` | ||
| 1731 | - Size int `json:"size"` | 1730 | + Page int `json:"page"` |
| 1731 | + Size int `json:"size"` | ||
| 1732 | + IncludeRootCompany bool `json:"includeRootCompany,optional"` // 包含公司(把公司当作部门作为顶级节点 部门ID:0) | ||
| 1732 | } | 1733 | } |
| 1733 | 1734 | ||
| 1734 | type DepartmentListResponse struct { | 1735 | type DepartmentListResponse struct { |
-
请 注册 或 登录 后发表评论