From a8da652180b1081a273dd614188b1a9b87953383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 9 Jan 2025 18:41:38 -0500 Subject: [PATCH] update `team_list.go` add `GetUserGroupTeams` function --- models/organization/team_list.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/models/organization/team_list.go b/models/organization/team_list.go index 0274f9c5ba..a429e534df 100644 --- a/models/organization/team_list.go +++ b/models/organization/team_list.go @@ -126,6 +126,18 @@ func GetUserRepoTeams(ctx context.Context, orgID, userID, repoID int64) (teams T Find(&teams) } +// GetUserGroupTeams returns teams in a group that a user has access to +func GetUserGroupTeams(ctx context.Context, groupID, userID int64) (teams TeamList, err error) { + err = db.GetEngine(ctx). + Where("`group_team`.group_id = ?", groupID). + Join("INNER", "group_team", "`group_team`.team_id = `team`.id"). + Join("INNER", "team_user", "`team_user`.team_id = `team`.id"). + And("`team_user`.uid = ?", userID). + Asc("`team`.name"). + Find(&teams) + return +} + func GetTeamsByOrgIDs(ctx context.Context, orgIDs []int64) (TeamList, error) { teams := make([]*Team, 0, 10) return teams, db.GetEngine(ctx).Where(builder.In("org_id", orgIDs)).Find(&teams)