import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  Delete,
  Patch,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { TokenData } from 'src/common/decorator/token-data.decorator';
import { CreateQuestionDifficultyLevelDto } from 'src/assessment-evaluation/dto/dtos-question-manager/question-difficulty-level/create-question-difficulty-level.dto';
import { UpdateQuestionDifficultyLevelDto } from 'src/assessment-evaluation/dto/dtos-question-manager/question-difficulty-level/update-question-difficulty-level.dto';
import { QuestionDifficultyLevelService } from 'src/assessment-evaluation/service/service-question-manager/question-difficulty-level.service';

@ApiTags('试题管理 - 难易程度')
@ApiBearerAuth()
@Controller('assessmentEvaluation/questionDifficultyLevel')
export class QuestionDifficultyLevelController {
  constructor(
    private readonly questionDifficultyLevelService: QuestionDifficultyLevelService,
  ) {}

  /* 
    创建试题难度
  */
  @Post()
  async create(
    @Body() createquestionDifficultyLevelDto: CreateQuestionDifficultyLevelDto,
    @TokenData() token: any,
  ) {
    createquestionDifficultyLevelDto.creator =
      createquestionDifficultyLevelDto.updater = token.userId;
    return this.questionDifficultyLevelService.create(
      createquestionDifficultyLevelDto,
    );
  }

  /* 
    获取所有试题难度
  */
  @Get()
  async findAll() {
    return this.questionDifficultyLevelService.findAll();
  }

  /* 
    更新试题难度 
  */
  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Body() updatequestionDifficultyLevelDto: UpdateQuestionDifficultyLevelDto,
  ) {
    return this.questionDifficultyLevelService.update(
      +id,
      updatequestionDifficultyLevelDto,
    );
  }

  /* 
    删除试题难度
  */
  @Delete(':id')
  async remove(@Param('id') id: string) {
    return this.questionDifficultyLevelService.remove(+id);
  }
}
