@@ -206,33 +206,6 @@ export class IoTDevicePayloadDecoderDataTargetConnectionController {
206206 }
207207 }
208208
209- @Delete ( ":id" )
210- @ApplicationAdmin ( )
211- @ApiNotFoundResponse ( {
212- description : "If the id of the entity doesn't exist" ,
213- } )
214- async delete (
215- @Req ( ) req : AuthenticatedRequest ,
216- @Param ( "id" , new ParseIntPipe ( ) ) id : number
217- ) : Promise < DeleteResponseDto > {
218- try {
219- const oldConnection = await this . service . findOne ( id ) ;
220- await this . checkUserHasWriteAccessToAllIotDevices (
221- oldConnection . iotDevices . map ( x => x . id ) ,
222- req
223- ) ;
224- const result = await this . service . delete ( id ) ;
225- if ( result . affected === 0 ) {
226- throw new NotFoundException ( ErrorCodes . IdDoesNotExists ) ;
227- }
228- AuditLog . success ( ActionType . DELETE , IoTDevicePayloadDecoderDataTargetConnection . name , req . user . userId , id ) ;
229- return new DeleteResponseDto ( result . affected ) ;
230- } catch ( err ) {
231- AuditLog . fail ( ActionType . DELETE , IoTDevicePayloadDecoderDataTargetConnection . name , req . user . userId , id ) ;
232- throw err ;
233- }
234- }
235-
236209 @Put ( "appendCopiedDevice/:id" )
237210 @ApplicationAdmin ( )
238211 @ApiNotFoundResponse ( {
@@ -259,4 +232,31 @@ export class IoTDevicePayloadDecoderDataTargetConnectionController {
259232 throw err ;
260233 }
261234 }
235+
236+ @Delete ( ":id" )
237+ @ApplicationAdmin ( )
238+ @ApiNotFoundResponse ( {
239+ description : "If the id of the entity doesn't exist" ,
240+ } )
241+ async delete (
242+ @Req ( ) req : AuthenticatedRequest ,
243+ @Param ( "id" , new ParseIntPipe ( ) ) id : number
244+ ) : Promise < DeleteResponseDto > {
245+ try {
246+ const oldConnection = await this . service . findOne ( id ) ;
247+ await this . checkUserHasWriteAccessToAllIotDevices (
248+ oldConnection . iotDevices . map ( x => x . id ) ,
249+ req
250+ ) ;
251+ const result = await this . service . delete ( id ) ;
252+ if ( result . affected === 0 ) {
253+ throw new NotFoundException ( ErrorCodes . IdDoesNotExists ) ;
254+ }
255+ AuditLog . success ( ActionType . DELETE , IoTDevicePayloadDecoderDataTargetConnection . name , req . user . userId , id ) ;
256+ return new DeleteResponseDto ( result . affected ) ;
257+ } catch ( err ) {
258+ AuditLog . fail ( ActionType . DELETE , IoTDevicePayloadDecoderDataTargetConnection . name , req . user . userId , id ) ;
259+ throw err ;
260+ }
261+ }
262262}
0 commit comments