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.domain.QuestionInfoKtNew;
import com.miaxis.question.dto.QuestionInfoFreeDTO;
import com.miaxis.question.dto.QuestionInfoNewTestDTO;
import com.miaxis.question.dto.QuestionInfoTestDTO;
import com.miaxis.question.service.IQuestionInfoKtNewService;
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+"/question2/info")
@Api(tags={"【通用-新题库】"})
public class CommonQuestionInfoNewController extends BaseController{


    @Autowired
    private IQuestionInfoKtNewService questionInfoKtNewService;

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

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

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

