package com.zhongzheng.controller.user;

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.user.bo.UserBankQuestionRecordQueryBo;
import com.zhongzheng.modules.user.entity.ClientLoginUser;
import com.zhongzheng.modules.user.service.IUserBankQuestionRecordService;
import com.zhongzheng.modules.user.vo.UserBankQuestionRecordVo;
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-28
 */
@Api(value = "用户做的历史题库题目记录控制器", tags = {"用户做的历史题库题目记录管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/bank/question/record")
public class UserBankQuestionRecordController extends BaseController {

    private final IUserBankQuestionRecordService iUserBankQuestionRecordService;

    private final WxTokenService wxTokenService;

    /**
     * 查询用户做的历史题库题目记录列表
     */
    @ApiOperation("查询用户错题历史列表")
    @GetMapping("/list")
    public TableDataInfo<UserBankQuestionRecordVo> list(UserBankQuestionRecordQueryBo bo) {
        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
        bo.setUserId(loginUser.getUser().getUserId());
        startPage();
        List<UserBankQuestionRecordVo> list = iUserBankQuestionRecordService.queryWrongList(bo);
        return getDataTable(list);
    }

    /**
     * 查询用户做的历史题库题目记录列表
     */
    @ApiOperation("查询用户做历史列表")
    @GetMapping("/doneList")
    public TableDataInfo<UserBankQuestionRecordVo> doneList(UserBankQuestionRecordQueryBo bo) {
        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
        bo.setUserId(loginUser.getUser().getUserId());
        startPage();
        List<UserBankQuestionRecordVo> list = iUserBankQuestionRecordService.queryDoneList(bo);
        return getDataTable(list);
    }

}
