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 { OnlineIssuesService } from '../service/online-issues.service';
import {
  CourseNotesDto,
  updateNoteDto,
} from '../dto/course-notes/course-nots.dto';
import { PaginationDTO } from '../common/pagination.dto';
import {
  createIssuesDto,
  updateIssuesDto,
} from '../dto/online-issues/online-issues.dto';
import { AnswerDto } from '../dto/online-issues/online-answer.dto';
@ApiTags('在线答疑')
@ApiBearerAuth()
@Controller('online-issues')
export class OnlineAnswerController {
  constructor(private readonly service: OnlineIssuesService) {}
  @Get('/myteacher')
  @ApiOperation({ summary: '根据token获取信息' })
  findMyteacher(@TokenData() tokenInfo: any) {
    return this.service.findMyteacherStudent(tokenInfo);
  }
  @Get()
  @ApiOperation({ summary: '获取我的提问列表' })
  findMyIssuesList(
    @Query() pageInfo: PaginationDTO,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.findMyIssues(pageInfo, tokenInfo);
  }

  @Get('/my-answer')
  @ApiOperation({ summary: '获取我的回答列表' })
  findMyAnswerList(
    @Query() pageInfo: PaginationDTO,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.findMyAnswer(pageInfo, tokenInfo);
  }

  @Post()
  @ApiOperation({ summary: '新建问题' })
  createIssues(@Body() issues: createIssuesDto, @TokenData() tokenInfo: any) {
    console.log(tokenInfo, 'xxxxxxxxxxxxxxxxxx');

    return this.service.createIssues(issues, tokenInfo);
  }
  @Post('update-issues')
  @ApiOperation({ summary: '编辑问题' })
  editorIssues(@Body() issues: updateIssuesDto, @TokenData() tokenInfo: any) {
    return this.service.editorIssues(issues, tokenInfo);
  }
  @Post('answer')
  @ApiOperation({ summary: '回答问题' })
  answer(@Body() issues: AnswerDto) {
    return this.service.answer(issues);
  }
  @Get(':id')
  @ApiOperation({ summary: '查询某个问题详情' })
  findMyIssuesOne(@Param('id') id: number, @TokenData() tokenInfo: any) {
    return this.service.findMyIssuesOne(id, tokenInfo);
  }
  // 查询我的老师下的所有学员接口
}
