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

import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { NoAuthToken } from 'src/common/decorator/no-token.decorator';
import {
  CourseStudyDiscussionDto,
  updateStudyDiscussionkudoDto,
} from '../dto/course-my/course-study-discussion.dto';
import { updateEvaluate } from '../dto/course-my/course-study-evaluate.dto';
import { CourseStudyCoursewareDto } from '../dto/course-my/course-study-courseware.dto';
import {
  CourseStudyExerciseDto,
  updateExercise,
} from '../dto/course-my/course-study-exercise.dto';
import { myCourseService } from '../service/my-course.service';
import {
  findMyCourse_All,
  findMyCourse_Type,
} from '../dto/course-my/course-study-record.dto';
import { TokenData } from 'src/common/decorator/token-data.decorator';

@ApiTags('我的课程')
@ApiBearerAuth()
// @NoAuthToken()
@Controller('my-course')
export class CourseMyController {
  constructor(private readonly service: myCourseService) {}
  @Post('')
  @ApiOperation({ summary: '查询所有课程信息' })
  findMycourseList_All(
    @Body() findInfo: findMyCourse_All,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.findAllMyCourseList(findInfo, tokenInfo);
  }
  @Post('type')
  @ApiOperation({ summary: '查询符合分类的课程信息' })
  findMycourseList(
    @Body() findInfo: findMyCourse_Type,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.findMycourseList(findInfo, tokenInfo);
  }
  @Get('exercise/:id')
  @ApiOperation({ summary: '查询课程下试题信息' })
  findOneRecordExercise(@Param('id') id: string, @TokenData() tokenInfo: any) {
    return this.service.findOneRecordExercise(+id, tokenInfo);
  }
  @Get('comment/:cid')
  @ApiOperation({ summary: '查询课程下试题信息' })
  findComment(@Param('cid') id: string, @TokenData() tokenInfo: any) {
    return this.service.findComment(+id);
  }

  // 更新课件的学习信息
  @Post('ware')
  @ApiOperation({ summary: '更新课件学习信息' })
  updateStudy_ware(
    @Body() wareInfo: CourseStudyCoursewareDto,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.updateStudy_ware(wareInfo, tokenInfo);
  }
  @Get(':id')
  @ApiOperation({ summary: '查询某个课程的具体学习信息' })
  fingOneRecord(@Param('id') id: string, @TokenData() tokenInfo: any) {
    return this.service.fingOneRecord(+id, tokenInfo);
  }
  // 更新评价信息
  @Post('eveal')
  @ApiOperation({ summary: '更新评价信息' })
  updateStudy_eveal(@Body() evealInfo: updateEvaluate) {
    return this.service.updateStudy_eveal(evealInfo);
  }
  // 评论提交
  @Post('discussion')
  @ApiOperation({ summary: '评论提交接口' })
  updateStudy_discussion(
    @Body() discussionInfo: CourseStudyDiscussionDto,
    @TokenData() tokenInfo: any,
  ) {
    return this.service.updateStudy_discussion(discussionInfo, tokenInfo);
  }
  // 更新练习题信息
  @Post('exercise')
  @ApiOperation({ summary: '课程练习题答题信息' })
  manageStudy_exercise(
    @Body() exercise: updateExercise,
    @TokenData() TokenData,
  ) {
    return this.service.manageStudy_exercise(exercise, TokenData);
  }
  @Post('discussion/kudos')
  @ApiOperation({ summary: '评论点赞' })
  updateStudyDiscussionKudos(
    @Body() kudos: updateStudyDiscussionkudoDto,
    @TokenData() tokenInfo,
  ) {
    return this.service.updateStudyDiscussionKudos(kudos, tokenInfo);
  }
}
