| 1216 | } |
| 1217 | |
| 1218 | func (i *imlAppModule) CreateApp(ctx context.Context, teamID string, input *service_dto.CreateApp) (*service_dto.App, error) { |
| 1219 | if input.Id == "" { |
| 1220 | input.Id = uuid.New().String() |
| 1221 | } |
| 1222 | userId := utils.UserId(ctx) |
| 1223 | mo := &service.Create{ |
| 1224 | Id: input.Id, |
| 1225 | Name: input.Name, |
| 1226 | Description: input.Description, |
| 1227 | Team: teamID, |
| 1228 | AsApp: true, |
| 1229 | } |
| 1230 | // 判断用户是否在团队内 |
| 1231 | members, err := i.teamMemberService.Members(ctx, []string{teamID}, []string{userId}) |
| 1232 | if err != nil { |
| 1233 | return nil, err |
| 1234 | } |
| 1235 | if len(members) == 0 { |
| 1236 | return nil, fmt.Errorf("master is not in team") |
| 1237 | } |
| 1238 | |
| 1239 | err = i.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 1240 | return i.serviceService.Create(ctx, mo) |
| 1241 | }) |
| 1242 | if err != nil { |
| 1243 | return nil, err |
| 1244 | } |
| 1245 | return i.GetApp(ctx, input.Id) |
| 1246 | } |
| 1247 | |
| 1248 | func (i *imlAppModule) UpdateApp(ctx context.Context, appId string, input *service_dto.UpdateApp) (*service_dto.App, error) { |
| 1249 | // userId := utils.UserId(ctx) |