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

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