import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';

import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { TokenData } from 'src/common/decorator/token-data.decorator';
import { CourseNotesService } from '../service/course-notes.service';
import {
  CourseNotesDto,
  updateNoteDto,
} from '../dto/course-notes/course-nots.dto';
import { PaginationDTO } from '../common/pagination.dto';
@ApiTags('课堂笔记')
@ApiBearerAuth()
// @NoAuthToken()
@Controller('course-notes')
export class CourseNotesController {
  constructor(private readonly service: CourseNotesService) {}
  @Get()
  @ApiOperation({ summary: '获取笔记列表' })
  findMyNoteList(
    @Query() pageInfo: PaginationDTO,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.findNotes(pageInfo, tokenInfo);
  }
  @Get(':id')
  @ApiOperation({ summary: '获取某个笔记详细信息' })
  findOneNote(@Param('id') id: number, @TokenData() tokenInfo: any) {
    return this.service.findOneNote(id, tokenInfo);
  }
  // 更新课件的学习信息
  @Post()
  @ApiOperation({ summary: '新建笔记' })
  createNote(@Body() noteInfo: CourseNotesDto, @TokenData() tokenInfo: any) {
    return this.service.createNote(noteInfo, tokenInfo);
  }
  @Patch(':id')
  @ApiOperation({ summary: '更新笔记' })
  updateNote(
    @Param('id') id: number,
    @Body() noteInfo: updateNoteDto,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.updateNote(id, noteInfo, tokenInfo);
  }
  @Delete(':id')
  @ApiOperation({ summary: '删除笔记' })
  deleteNote(@Param('id') id: number, @TokenData() tokenInfo: any) {
    return this.service.deleteNote(id, tokenInfo);
  }
}
