import { Controller, Get, Post, Body, Param, Query } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { ActiveRecallService } from './active-recall.service';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { PaginationDto } from '../../common/dto/pagination.dto';
import type { UserPayload } from '../../common/types';

@ApiTags('active-recall')
@Controller('active-recalls')
export class ActiveRecallController {
  constructor(private readonly service: ActiveRecallService) {}

  @Get()
  @ApiOperation({ summary: '获取主动回忆问题列表' })
  async findAll(@CurrentUser() user: UserPayload, @Query() pagination: PaginationDto) {
    return this.service.findByUserId(String(user?.id || 'anonymous'), pagination);
  }

  @Post(':id/submit')
  @ApiOperation({ summary: '提交主动回忆回答' })
  async submit(@CurrentUser() user: UserPayload, @Param('id') id: string, @Body() body: any) {
    return this.service.submit(String(user?.id || 'anonymous'), id, body);
  }
}
