import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Post,
  Put,
  Req,
  UseGuards,
} from '@nestjs/common';
import { AdminsService } from '../services/admins.service';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
import Admin from '../entities/admin.entity';
import { UpdateDto } from '../dtos/update.dto';
import { DeletesDto } from '../dtos/deletes.dto';
import { Request } from 'express';
import { CreateDto } from '../dtos/create.dto';
import Permission from '../entities/permission.entity';
import { GrantNewPasswordDto } from '../dtos/grant-new-password.dto';
import { SystemAccountGuard } from '@/system/guards/system-account.guard';
import { GenerateKeysService } from '../services/generate-key.service';

@Controller('admin/keys')
export class GenerateKeysController {
  constructor(private readonly generateKeyService: GenerateKeysService) {}

  @Get()
  async index(@Paginate() query: PaginateQuery) {
    return await this.generateKeyService.index(query);
  }

  @Delete(':id')
  async delete(@Param('id') id: Admin['id']) {
    return await this.generateKeyService.delete(id);
  }

  @Post('')
  async create(@Req() request: Request) {
    return await this.generateKeyService.create(request);
  }

  @Post('deletes')
  async deletes(@Body() data: DeletesDto) {
    return await this.generateKeyService.deletes(data.ids);
  }
}
