/**
 * @aurora-catalyst-generated
 * @source cliter/iam/role.aurora.yaml
 */
import { IamUpdateRoleByIdDto } from '@api/iam/role';
import { IamInheritPermissionsRoleRoleHandler } 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, Post } from '@nestjs/common';
import { ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[iam] role')
@Controller('iam/role/inherit-permissions-role')
@Auth('iam.role.update')
export class IamInheritPermissionsRoleRoleController {
  constructor(private readonly handler: IamInheritPermissionsRoleRoleHandler) {}

  @Post()
  @ApiOperation({ summary: 'inherit-permissions-role role' })
  @ApiCreatedResponse({
    description: 'The operation has been successfully executed.',
    type: Boolean,
  })
  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 },
    });
  }
}
