@@ -39,6 +39,40 @@ type imlTeamModule struct {
3939 transaction store.ITransaction `autowired:""`
4040}
4141
42+ func (m * imlTeamModule ) SimpleTeams (ctx context.Context , keyword string ) ([]* team_dto.SimpleTeam , error ) {
43+ teams , err := m .teamService .Search (ctx , keyword , nil )
44+ if err != nil {
45+ return nil , err
46+ }
47+ projects , err := m .serviceService .Search (ctx , "" , nil )
48+ projectCount := make (map [string ]int64 )
49+ appCount := make (map [string ]int64 )
50+ for _ , p := range projects {
51+ if p .AsServer {
52+ if _ , ok := projectCount [p .Team ]; ! ok {
53+ projectCount [p .Team ] = 0
54+ }
55+ projectCount [p .Team ]++
56+ }
57+ if p .AsApp {
58+ if _ , ok := appCount [p .Team ]; ! ok {
59+ appCount [p .Team ] = 0
60+ }
61+ appCount [p .Team ]++
62+ }
63+ }
64+
65+ return utils .SliceToSlice (teams , func (s * team.Team ) * team_dto.SimpleTeam {
66+ return & team_dto.SimpleTeam {
67+ Id : s .Id ,
68+ Name : s .Name ,
69+ Description : s .Description ,
70+ ServiceNum : projectCount [s .Id ],
71+ AppNum : appCount [s .Id ],
72+ }
73+ }), nil
74+ }
75+
4276func (m * imlTeamModule ) UpdateMemberRole (ctx context.Context , id string , input * team_dto.UpdateMemberRole ) error {
4377 _ , err := m .teamService .Get (ctx , id )
4478 if err != nil {
@@ -157,7 +191,7 @@ func (m *imlTeamModule) Edit(ctx context.Context, id string, input *team_dto.Edi
157191 return m .GetTeam (ctx , id )
158192}
159193
160- func (m * imlTeamModule ) SimpleTeams (ctx context.Context , keyword string ) ([]* team_dto.SimpleTeam , error ) {
194+ func (m * imlTeamModule ) MySimpleTeams (ctx context.Context , keyword string ) ([]* team_dto.SimpleTeam , error ) {
161195 userID := utils .UserId (ctx )
162196 memberMap , err := m .teamMemberService .FilterMembersForUser (ctx , userID )
163197 if err != nil {
0 commit comments