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

@ApiTags('focus-items')
@Controller('focus-items')
export class FocusItemsController {
  constructor(private readonly focusItemsService: FocusItemsService) {}

  @Get()
  @ApiOperation({ summary: '获取待巩固项列表' })
  async findAll(@CurrentUser() user: UserPayload, @Query() pagination: PaginationDto) {
    return this.focusItemsService.findAll(String(user?.id || 'anonymous'), pagination);
  }

  @Post()
  @ApiOperation({ summary: '创建待巩固项' })
  async create(@CurrentUser() user: UserPayload, @Body() dto: any) {
    return this.focusItemsService.create(String(user?.id || 'anonymous'), dto);
  }

  @Patch(':id')
  @ApiOperation({ summary: '更新待巩固项' })
  async update(@Param('id') id: string, @Body() dto: any) {
    return this.focusItemsService.update(id, dto);
  }

  @Post(':id/complete')
  @ApiOperation({ summary: '完成待巩固项' })
  async complete(@Param('id') id: string) {
    return this.focusItemsService.complete(id);
  }
}
