package com.miaxis.app.controller.question;

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.service.IQuestionInfoService;
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-12
 */
@RestController
@RequestMapping(Constants.STUDENT_PREFIX+"/question/info")
@Api(tags={"【app-题库】"})
public class QuestionInfoController extends BaseController{
    @Autowired
    private IQuestionInfoService questionInfoService;

    /**
     * 查询题库列表
     */
    @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<QuestionInfo> list(@ModelAttribute QuestionInfo questionInfo){
        startPage();
        List<QuestionInfo> list = questionInfoService.selectQuestionInfoList(questionInfo);
        return toResponsePageInfo(list);
    }



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



}
