import { Body, Controller, Get, Post, Patch, Delete, Param, UseGuards } from '@nestjs/common';
import { DataRetentionService } from './data-retention.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-retention')
@UseGuards(JwtAuthGuard)
export class DataRetentionController {
  constructor(private readonly dataRetentionService: DataRetentionService) {}

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

  @Post()
  async create(
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
    @Body() dto: any,
  ) {
    return this.dataRetentionService.create(wsId, userId, dto);
  }

  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
    @Body() dto: any,
  ) {
    return this.dataRetentionService.update(id, wsId, userId, dto);
  }

  @Delete(':id')
  async delete(
    @Param('id') id: string,
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
  ) {
    return this.dataRetentionService.delete(id, wsId, userId);
  }
}