import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  Delete,
  Patch,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { CreateExamClassifyDto } from 'src/assessment-evaluation/dto/dtos-exam-manager/exam-classify/create-exam-classify.dto';
import { UpdateExamClassifyDto } from 'src/assessment-evaluation/dto/dtos-exam-manager/exam-classify/update-exam-classify.dto';
import { ExamClassifyService } from 'src/assessment-evaluation/service/service-exam-manager/exam-classify.service';
import { TokenData } from 'src/common/decorator/token-data.decorator';

@ApiTags('考试管理 - 考试分类')
@ApiBearerAuth()
// @NoAuthToken()
@Controller('assessmentEvaluation/ExamClassify')
export class ExamClassifyController {
  constructor(private readonly ExamClassifyService: ExamClassifyService) {}

  @Post()
  /* 用于创建新考试分类的函数。 */
  async create(
    @Body() CreateExamClassifyDto: CreateExamClassifyDto,
    @TokenData() token: any,
  ) {
    CreateExamClassifyDto.creator = CreateExamClassifyDto.updater =
      token.userId;
    return this.ExamClassifyService.create(CreateExamClassifyDto);
  }

  @Get()
  /* 用于查找所有考试分类的函数。 */
  async findAll() {
    return this.ExamClassifyService.findAll();
  }

  @Patch(':id')
  /* 更新考试分类的功能。 */
  async update(
    @Param('id') id: string,
    @Body() UpdateExamClassifyDto: UpdateExamClassifyDto,
  ) {
    return this.ExamClassifyService.update(+id, UpdateExamClassifyDto);
  }

  @Delete(':id')
  /* 删除考试分类的功能。 */
  async remove(@Param('id') id: string) {
    return this.ExamClassifyService.remove(+id);
  }
}
