/**
 * @aurora-catalyst-generated
 * @source cliter/iam/role-account.aurora.yaml
 */
import { IamRoleAccountDto, IamUpdateRolesAccountsDto } from '@api/iam/role-account';
import { IamUpdateRolesAccountsHandler } from '@app/iam/role-account';
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] role-account')
@Controller('iam/roles-accounts/update')
@Auth('iam.roleAccount.update')
export class IamUpdateRolesAccountsController {
  constructor(private readonly handler: IamUpdateRolesAccountsHandler) {}

  @Put()
  @ApiOperation({ summary: 'Update roles-accounts' })
  @ApiOkResponse({
    description: 'The record has been successfully updated.',
    type: IamRoleAccountDto,
  })
  async main(
    @Body('payload') payload: IamUpdateRolesAccountsDto,
    @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 },
    });
  }
}
