/**
 * @aurora-catalyst-generated
 * @source cliter/iam/tenant.aurora.yaml
 */
import { IamTenantDto, IamUpdateTenantsDto } from '@api/iam/tenant';
import { IamUpdateTenantsHandler } from '@app/iam/tenant';
import { Auth } from '@aurora/decorators';
import { Auditing, AuditingMeta, Timezone } from '@aurorajs.dev/core-back';
import { QueryStatement } from '@aurorajs.dev/core-common';
import { Body, Controller, Put } from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[iam] tenant')
@Controller('iam/tenants/update')
@Auth('iam.tenant.update')
export class IamUpdateTenantsController {
  constructor(private readonly handler: IamUpdateTenantsHandler) {}

  @Put()
  @ApiOperation({ summary: 'Update tenants' })
  @ApiOkResponse({ description: 'The record has been successfully updated.', type: IamTenantDto })
  async main(
    @Body('payload') payload: IamUpdateTenantsDto,
    @Body('query') queryStatement?: QueryStatement,
    @Body('constraint') constraint?: QueryStatement,
    @Timezone() timezone?: string,
    @Auditing() auditing?: AuditingMeta,
  ) {
    return await this.handler.main(payload, queryStatement, constraint, {
      timezone,
      repositoryOptions: { auditing },
    });
  }
}
