| 143 | } |
| 144 | |
| 145 | func (m *imlTeamModule) Delete(ctx context.Context, id string) error { |
| 146 | err := m.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 147 | count, err := m.serviceService.Count(ctx, "", map[string]interface{}{ |
| 148 | "team": id, |
| 149 | "is_delete": false, |
| 150 | }) |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | if count != 0 { |
| 155 | return fmt.Errorf("team has projects,cannot delete") |
| 156 | } |
| 157 | err = m.service.Delete(ctx, id) |
| 158 | if err != nil { |
| 159 | return err |
| 160 | } |
| 161 | return nil |
| 162 | }) |
| 163 | return err |
| 164 | } |