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

@ApiTags('试卷管理 - 试卷分类')
@ApiBearerAuth()
// @NoAuthToken()
@Controller('assessmentEvaluation/ExamPaperClassify')
export class ExamPaperClassifyController {
  constructor(
    private readonly ExamPaperClassifyService: ExamPaperClassifyService,
  ) {}

  /*
   创建试卷分类 
   */
  @Post()
  async create(
    @Body() createExamPaperClassifyDto: CreateExamPaperClassifyDto,
    @TokenData() token: any,
  ) {
    createExamPaperClassifyDto.creator = createExamPaperClassifyDto.updater =
      token.userId;
    return this.ExamPaperClassifyService.create(createExamPaperClassifyDto);
  }
  /**
   * 获取所有试卷分类
   */
  @Get()
  async findAll() {
    return this.ExamPaperClassifyService.findAll();
  }
  /* 
    更新试卷分类
  */
  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Body() updateExamPaperClassifyDto: UpdateExamPaperClassifyDto,
  ) {
    return this.ExamPaperClassifyService.update(
      +id,
      updateExamPaperClassifyDto,
    );
  }
  /* 
    删除试卷分类
  */
  @Delete(':id')
  async remove(@Param('id') id: string) {
    return this.ExamPaperClassifyService.remove(+id);
  }
}
