1234567891011121314151617181920212223242526272829303132333435 |
- package repo
- import (
- "assetcenter/db/model"
- "go.mongodb.org/mongo-driver/bson/primitive"
- )
- // 获取用户的团队成员
- func TeamGetUserTeamers(ctx *RepoSession, userId string, includeSelf bool) []primitive.ObjectID {
- out := []primitive.ObjectID{}
- user := &model.User{}
- RepoSeachDoc(ctx, &DocSearchOptions{CollectName: CollectionUser, Query: Map{"_id": userId}, Project: []string{"teamId"}}, user)
- //没有团队
- if len(user.TeamId) < 1 {
- return out
- }
- uid, _ := primitive.ObjectIDFromHex(userId)
- if includeSelf {
- out = append(out, uid)
- }
- //团队人员
- ok, list := RepoSeachDocsMap(ctx, &DocsSearchOptions{CollectName: CollectionUser, Query: Map{"teamId": user.TeamId}, Project: []string{"_id"}})
- if !ok {
- return out
- }
- for _, item := range list {
- out = append(out, item["_id"].(primitive.ObjectID))
- }
- return out
- }
|