package com.ytpm.lemonios.controller;

import com.ytpm.annotation.ApiEncrypt;
import com.ytpm.app.param.AnswerRecordParam;
import com.ytpm.app.view.IosAnswerQuestionView;
import com.ytpm.app.view.QuestionListView;
import com.ytpm.general.Result;
import com.ytpm.general.ResultTable;
import com.ytpm.lemonios.service.QuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "题目管理模块")
@RestController
@RequestMapping("/question")
public class QuestionController {

    @Resource
    private QuestionService questionService;

    /**
     * 获取题库
     */
    @ApiEncrypt(response = true)
    @ApiOperation("获取题库")
    @GetMapping("/list")
    public ResultTable<QuestionListView> questionList() {
        return questionService.questionList();
    }

    /**
     * 回答问题
     */
    @ApiEncrypt(response = true)
    @ApiOperation("回答问题")
    @PostMapping("/answerQuestion")
    public Result<IosAnswerQuestionView> answerQuestion(@RequestBody AnswerRecordParam param) {
        return questionService.answerQuestion(param);
    }
}
