package com.zhongzheng.controller.bank;

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

import com.zhongzheng.common.utils.ServletUtils;
import com.zhongzheng.framework.web.service.WxTokenService;
import com.zhongzheng.modules.bank.bo.QuestionSimulateAddBo;
import com.zhongzheng.modules.bank.bo.QuestionSimulateEditBo;
import com.zhongzheng.modules.bank.bo.QuestionSimulateQueryBo;
import com.zhongzheng.modules.bank.service.IQuestionSimulateService;
import com.zhongzheng.modules.bank.vo.QuestionSimulateVo;
import com.zhongzheng.modules.user.entity.ClientLoginUser;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 模拟题库Controller
 *
 * @author ruoyi
 * @date 2021-06-24
 */
@Api(value = "模拟题库控制器", tags = {"模拟题库管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/bank/simulate")
public class QuestionSimulateController extends BaseController {

    private final IQuestionSimulateService iQuestionSimulateService;

    private final WxTokenService wxTokenService;

    /**
     * 查询模拟题库列表
     */
    @ApiOperation("查询模拟题库列表")
    @GetMapping("/list")
    public TableDataInfo<QuestionSimulateVo> list(QuestionSimulateQueryBo bo) {
        startPage();
        List<QuestionSimulateVo> list = iQuestionSimulateService.queryList(bo);
        return getDataTable(list);
    }



    /**
     * 获取模拟题库详细信息
     */
    @ApiOperation("获取模拟题库详细信息")
    @GetMapping("/{bankId}")
    public AjaxResult getInfo(@PathVariable("bankId" ) Long bankId) {
        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
        return AjaxResult.success(iQuestionSimulateService.queryByBankId(bankId,loginUser.getUser().getUserId()));
    }


}
