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 { CreateQuestionClassifyDto } from 'src/assessment-evaluation/dto/dtos-question-manager/question-classify/create-question-classify.dto';
import { UpdateQuestionClassifyDto } from 'src/assessment-evaluation/dto/dtos-question-manager/question-classify/update-question-classify.dto';
import { QuestionClassifyService } from 'src/assessment-evaluation/service/service-question-manager/question-classify.service';

@ApiTags('试题管理 - 试题分类')
@ApiBearerAuth()
// @NoAuthToken()
@Controller('assessmentEvaluation/questionClassify')
export class QuestionClassifyController {
  constructor(
    private readonly questionClassifyService: QuestionClassifyService,
  ) {}

  /* 
    创建试题分类
  */
  @Post()
  async create(
    @Body() createQuestionClassifyDto: CreateQuestionClassifyDto,
    @TokenData() token: any,
  ) {
    createQuestionClassifyDto.creator = createQuestionClassifyDto.updater =
      token.userId;
    return this.questionClassifyService.create(createQuestionClassifyDto);
  }

  /* 
    获取所有试题分类
  */
  @Get()
  async findAll() {
    return this.questionClassifyService.findAll();
  }

  /* 
    更新试题分类
  */
  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Body() updateQuestionClassifyDto: UpdateQuestionClassifyDto,
  ) {
    return this.questionClassifyService.update(+id, updateQuestionClassifyDto);
  }

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