/**
 * @aurora-catalyst-generated
 * @source cliter/iam/role.aurora.yaml
 */
import { IamCreateRoleDto, IamRoleDto } from '@api/iam/role';
import { IamCreateRolesHandler } from '@app/iam/role';
import { Auth } from '@aurora/decorators';
import { Auditing, AuditingMeta, Timezone } from '@aurorajs.dev/core-back';
import { Body, Controller, Post } from '@nestjs/common';
import { ApiBody, ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[iam] role')
@Controller('iam/roles/create')
@Auth('iam.role.create')
export class IamCreateRolesController {
  constructor(private readonly handler: IamCreateRolesHandler) {}

  @Post()
  @ApiOperation({ summary: 'Create roles in batch' })
  @ApiCreatedResponse({
    description: 'The records has been created successfully.',
    type: [IamRoleDto],
  })
  @ApiBody({ type: [IamCreateRoleDto] })
  async main(
    @Body() payload: IamCreateRoleDto[],
    @Timezone() timezone?: string,
    @Auditing() auditing?: AuditingMeta,
  ) {
    return await this.handler.main(payload, {
      timezone,
      repositoryOptions: { auditing },
    });
  }
}
