/**
 * @aurora-catalyst-generated
 * @source cliter/iam/role.aurora.yaml
 */
import { IamRoleDto, IamUpdateRolesDto } from '@api/iam/role';
import { IamUpdateRolesHandler } from '@app/iam/role';
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')
@Controller('iam/roles/update')
@Auth('iam.role.update')
export class IamUpdateRolesController {
  constructor(private readonly handler: IamUpdateRolesHandler) {}

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