| 40 | } |
| 41 | |
| 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 | |
| 76 | func (m *imlTeamModule) UpdateMemberRole(ctx context.Context, id string, input *team_dto.UpdateMemberRole) error { |
| 77 | _, err := m.teamService.Get(ctx, id) |