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 { CreateQuestionTypeDto } from 'src/assessment-evaluation/dto/dtos-question-manager/question-type/create-question-type.dto';
import { UpdateQuestionTypeDto } from 'src/assessment-evaluation/dto/dtos-question-manager/question-type/update-question-type.dto';
import { QuestionTypeService } from 'src/assessment-evaluation/service/service-question-manager/question-type.service';

@ApiTags('试题管理 - 试题类型')
@ApiBearerAuth()
// @NoAuthToken()
@Controller('assessmentEvaluation/questionType')
export class QuestionTypeController {
  constructor(private readonly QuestionTypeService: QuestionTypeService) {}

  /* 
    创建试题类型
  */
  @Post()
  async create(
    @Body() createQuestionTypeDto: CreateQuestionTypeDto,
    @TokenData() token: any,
  ) {
    createQuestionTypeDto.creator = createQuestionTypeDto.updater =
      token.userId;
    return this.QuestionTypeService.create(createQuestionTypeDto);
  }
  /* 
    查找所有试题类型
  */
  @Get()
  async findAll() {
    return this.QuestionTypeService.findAll();
  }

  /* 
    更新试题类型
  */
  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Body() updateQuestionTypeDto: UpdateQuestionTypeDto,
  ) {
    return this.QuestionTypeService.update(+id, updateQuestionTypeDto);
  }

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