/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/authorization-code.aurora.yaml
 */
import { OAuthAuthorizationCodeDto } from '@api/o-auth/authorization-code';
import { OAuthDeleteAuthorizationCodesHandler } from '@app/o-auth/authorization-code';
import { Auth } from '@aurora/decorators';
import { Timezone } from '@aurorajs.dev/core-back';
import { QueryStatement } from '@aurorajs.dev/core-common';
import { Body, Controller, Delete } from '@nestjs/common';
import { ApiBody, ApiOkResponse, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';

@ApiTags('[o-auth] authorization-code')
@Controller('o-auth/authorization-codes/delete')
@Auth('oAuth.authorizationCode.delete')
export class OAuthDeleteAuthorizationCodesController {
  constructor(private readonly handler: OAuthDeleteAuthorizationCodesHandler) {}

  @Delete()
  @ApiOperation({ summary: 'Delete authorization-codes in batch according to query' })
  @ApiOkResponse({
    description: 'The records has been deleted successfully.',
    type: [OAuthAuthorizationCodeDto],
  })
  @ApiBody({ type: QueryStatement })
  @ApiQuery({ name: 'query', type: QueryStatement })
  async main(
    @Body('query') queryStatement?: QueryStatement,
    @Body('constraint') constraint?: QueryStatement,
    @Timezone() timezone?: string,
  ) {
    return await this.handler.main(queryStatement, constraint, {
      timezone,
    });
  }
}
