/**
 * @aurora-catalyst-generated
 * @source cliter/iam/user.aurora.yaml
 */
import { IamUpdateUsersDto, IamUserDto } from '@api/iam/user';
import { IamUpdateUsersHandler } from '@app/iam/user';
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] user')
@Controller('iam/users/update')
@Auth('iam.user.update')
export class IamUpdateUsersController {
  constructor(private readonly handler: IamUpdateUsersHandler) {}

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