0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-12 20:50:31 +02:00
gitea/models/organization/team_group.go
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 401e633f01
rename tables in group-related query conditions
2026-04-02 20:00:52 -04:00

35 lines
1.3 KiB
Go

package organization
import (
"context"
"code.gitea.io/gitea/models/db"
group_model "code.gitea.io/gitea/models/group"
"code.gitea.io/gitea/models/perm"
"code.gitea.io/gitea/models/unit"
)
func GetTeamsWithAccessToGroup(ctx context.Context, orgID, groupID int64, mode perm.AccessMode) ([]*Team, error) {
teams := make([]*Team, 0)
inCond := group_model.ParentGroupCond(ctx, "repo_group_team.group_id", groupID)
return teams, db.GetEngine(ctx).Distinct("team.*").Where("repo_group_team.access_mode >= ?", mode).
Join("INNER", "repo_group_team", "repo_group_team.team_id = team.id and repo_group_team.org_id = ?", orgID).
And("repo_group_team.org_id = ?", orgID).
And(inCond).
OrderBy("name").
Find(&teams)
}
func GetTeamsWithAccessToGroupUnit(ctx context.Context, orgID, groupID int64, mode perm.AccessMode, unitType unit.Type) ([]*Team, error) {
teams := make([]*Team, 0)
inCond := group_model.ParentGroupCond(ctx, "repo_group_team.group_id", groupID)
return teams, db.GetEngine(ctx).Where("repo_group_team.access_mode >= ?", mode).
Join("INNER", "repo_group_team", "repo_group_team.team_id = team.id").
Join("INNER", "repo_group_unit", "repo_group_unit.team_id = team.id").
And("repo_group_team.org_id = ?", orgID).
And(inCond).
And("repo_group_unit.type = ?", unitType).
OrderBy("name").
Find(&teams)
}