/**
 * @aurora-catalyst-generated
 * @source cliter/iam/permission.aurora.yaml
 */
import { IamPermissionDto, IamUpdatePermissionsDto } from '@api/iam/permission';
import { IamUpdatePermissionsHandler } from '@app/iam/permission';
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] permission')
@Controller('iam/permissions/update')
@Auth('iam.permission.update')
export class IamUpdatePermissionsController {
  constructor(private readonly handler: IamUpdatePermissionsHandler) {}

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