package com.miaxis.app.controller.common;

import com.miaxis.common.constant.Constants;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.page.ResponsePageInfo;
import com.miaxis.question.domain.QuestionInfo;
import com.miaxis.question.dto.QuestionInfoFreeDTO;
import com.miaxis.question.dto.QuestionInfoTestDTO;
import com.miaxis.question.service.IQuestionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 【题库】Controller
 *
 * @author miaxis
 * @date 2021-10-20
 */
@RestController
@RequestMapping(Constants.OPEN_PREFIX+"/question/info")
@Api(tags={"【通用-题库】"})
public class CommonQuestionInfoController extends BaseController{
    @Autowired
    private IQuestionInfoService questionInfoService;

    /**
     * 查询模拟考试科目1与4题库
     */
    @GetMapping("/selectTestK14QuestionInfoList")
    @ApiOperation("取模拟考试题库")
    public ResponsePageInfo<QuestionInfo> selectTestK14QuestionInfoList(@ModelAttribute QuestionInfoTestDTO questionInfoTestDTO){
        List<QuestionInfo> list = questionInfoService.selectTestK14QuestionInfoList(questionInfoTestDTO);
        return toResponsePageInfo(list);
    }

    /**
     * 查询模拟考试科目1与4题库
     */
    @GetMapping("/selectTestK14QuestionInfoListnN")
    @ApiOperation("取模拟考试题库-无分页")
    public Response<List<QuestionInfo>> selectTestK14QuestionInfoListN(@ModelAttribute QuestionInfoTestDTO questionInfoTestDTO){
        List<QuestionInfo> list = questionInfoService.selectTestK14QuestionInfoList(questionInfoTestDTO);
        return Response.success(list);
    }

    /**
     * 查询免费题库
     */
    @GetMapping("/selectFreeQuestionInfo")
    @ApiOperation("查询免费题库")
    public ResponsePageInfo<QuestionInfo> selectFreeQuestionInfo(@ModelAttribute QuestionInfoFreeDTO freeDTO){
        List<QuestionInfo> list = questionInfoService.selectFreeQuestionInfo(freeDTO);
        return toResponsePageInfo(list);
    }
}

