import { Controller, Get, Post, UseGuards, Param } from '@nestjs/common';
import { DataExportService } from './data-export.service';
import { JwtAuthGuard } from '../../common/guards/jwt.guard';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { Workspace } from '../../common/decorators/workspace.decorator';

@Controller('data-export')
@UseGuards(JwtAuthGuard)
export class DataExportController {
  constructor(private readonly dataExportService: DataExportService) {}

  @Get('workspace')
  async exportWorkspace(@Workspace('id') wsId: string, @CurrentUser('userId') userId: string) {
    return this.dataExportService.exportWorkspace(wsId, userId);
  }

  @Get('me')
  async exportMyData(@CurrentUser('userId') userId: string, @Workspace('id') wsId: string) {
    return this.dataExportService.exportUser(userId, wsId);
  }

  @Get('user/:userId')
  async exportUser(
    @Param('userId') targetUserId: string,
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
  ) {
    return this.dataExportService.exportUser(targetUserId, wsId);
  }
}