作者 郑周

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

... ... @@ -186,6 +186,7 @@ type(
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
UserIds []int64 `json:"userIds,omitempty"` // 部门下的用户
}
UserSearchRequest{
Page int `json:"page,optional"`
... ...
... ... @@ -4,6 +4,8 @@ import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
... ... @@ -24,17 +26,32 @@ func NewSystemGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemG
}
func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
var conn = l.svcCtx.DefaultDBConn()
department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsg("数据不存在")
}
// 部门下的用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().
WithKV("companyId", userToken.CompanyId).
WithKV("auditStatus", domain.UserAuditStatusPassed).
WithKV("departmentId", department.Id))
if err != nil {
return nil, err
}
ids := make([]int64, 0)
for i := range users {
ids = append(ids, users[i].Id)
}
resp = &types.DepartmentGetResponse{
Department: types.Department{
Id: department.Id,
CompanyId: department.CompanyId,
ParentId: department.ParentId,
Name: department.Name,
UserIds: ids,
},
}
return resp, nil
... ...
... ... @@ -519,10 +519,11 @@ type Account struct {
}
type Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
UserIds []int64 `json:"userIds,omitempty"` // 部门下的用户
}
type UserSearchRequest struct {
... ...