package com.zhongzheng.controller.bank;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.bank.bo.QuestionBankAddBo;
import com.zhongzheng.modules.bank.bo.QuestionBankEditBo;
import com.zhongzheng.modules.bank.bo.QuestionBankQueryBo;
import com.zhongzheng.modules.bank.service.IQuestionBankService;
import com.zhongzheng.modules.bank.vo.QuestionBankVo;
import com.zhongzheng.modules.course.bo.CourseQueryBo;
import com.zhongzheng.modules.course.vo.CourseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 题库Controller
 *
 * @author hjl
 * @date 2021-05-20
 */
@Api(value = "题库控制器", tags = {"题库管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/common/bank")
public class QuestionBankController extends BaseController {

    private final IQuestionBankService iQuestionBankService;

    /**
     * 查询题库列表
     */
    @ApiOperation("查询题库列表")
    @GetMapping("/list")
    public TableDataInfo<QuestionBankVo> list(QuestionBankQueryBo bo) {
        List<Integer> statusList = new ArrayList<>();
        statusList.add(1);
        bo.setStatus(statusList);
        startPage();
        List<QuestionBankVo> list = iQuestionBankService.selectBankList(bo);
        return getDataTable(list);
    }


    /**
     * 获取题库详细信息
     */
    @ApiOperation("获取题库详细信息")
    @GetMapping("/{bankId}")
    public AjaxResult<QuestionBankVo> getInfo(@PathVariable("bankId" ) Long bankId) {
        return AjaxResult.success(iQuestionBankService.queryById(bankId));
    }

    @ApiOperation("题库推荐列表")
    @GetMapping("/recommendList")
    public AjaxResult<List<QuestionBankVo>> recommendList(QuestionBankQueryBo bo) {
        List<QuestionBankVo> list = iQuestionBankService.queryRecommendList(bo);
        return AjaxResult.success(list);
    }
}
