package com.miaxis.app.controller.h5;

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.QuestionColumn;
import com.miaxis.question.domain.QuestionInfo;
import com.miaxis.question.domain.QuestionInfoKtNew;
import com.miaxis.question.dto.QuestionInfoNewDTO;
import com.miaxis.question.dto.QuestionInfoNewTestDTO;
import com.miaxis.question.service.IQuestionColumnService;
import com.miaxis.question.service.IQuestionInfoKtNewService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【题库】Controller
 *
 * @author miaxis
 * @date 2021-10-20
 */
@RestController
@RequestMapping(Constants.STUDENT_PREFIX+"/question2/info")
@Api(tags={"【H5-新题库】"})
public class QuestionInfoNewController extends BaseController{

    @Autowired
    private IQuestionInfoKtNewService questionInfoKtNewService;
    @Autowired
    private IQuestionColumnService questionColumnService;

    /**
     * 查询题库列表
     */
    @GetMapping("/list")
    @ApiOperation("查询题库列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<QuestionInfoKtNew> list(@ModelAttribute QuestionInfoNewDTO questionInfoNewDTO){
        startPage();
        List<QuestionInfoKtNew> list = questionInfoKtNewService.selectQuestionInfoList(questionInfoNewDTO);
        return toResponsePageInfo(list);
    }



    /**
     * 获取题库详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取题库详细信息")
    public Response<QuestionInfoKtNew> getInfo(
            @ApiParam(name = "id", value = "题库参数", required = true)
            @PathVariable("id") Long id
    ){
        return Response.success(questionInfoKtNewService.getById(id));
    }

    /**
     * 获取题库详细信息多个题库
     */
    @GetMapping(value = "/getQuestionInfoByIds")
    @ApiOperation("获取题库详细信息批量取题")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids",value = "题目ids" ,dataType = "List", required = true)})
    public ResponsePageInfo<QuestionInfoKtNew> getQuestionInfoByIds(Long[] ids){
        List<QuestionInfoKtNew> list = questionInfoKtNewService.selectQuestionInfoListByIds(ids);
        return toResponsePageInfo(list);
    }



    @GetMapping(value = "/getQuestionColumn")
    @ApiOperation("获取题库分类")
    public Response<List<QuestionColumn>> getQuestionColumn(@ModelAttribute QuestionColumn questionColumn){
        List<QuestionColumn> list = questionColumnService.selectQuestionColumnList(questionColumn);
        return Response.success(list);
    }


    /**
     * 获取地方分类
     */


    /**
     * 获取分类专题分类
     */


    /**
     * 获取顺序练习分类
     */


    /**
     * 查询题库列表（非会员）
     */
    @GetMapping("/normalList")
    @ApiOperation("查询题库列表（非会员）")
    public ResponsePageInfo<QuestionInfoKtNew> normalList(@ModelAttribute QuestionInfoNewDTO questionInfoNewDTO){
        List<QuestionInfoKtNew> list = questionInfoKtNewService.selectNormalQuestionInfoList(questionInfoNewDTO);
        return toResponsePageInfo(list);
    }




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




}

