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

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