package com.zhongzheng.controller.user;

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.common.utils.ServletUtils;
import com.zhongzheng.framework.web.service.WxTokenService;
import com.zhongzheng.modules.user.bo.UserExamRecordAddBo;
import com.zhongzheng.modules.user.bo.UserExamRecordEditBo;
import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
import com.zhongzheng.modules.user.entity.ClientLoginUser;
import com.zhongzheng.modules.user.service.IUserExamRecordService;
import com.zhongzheng.modules.user.vo.UserExamRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户的题库试卷做题历史Controller
 *
 * @author hjl
 * @date 2021-12-15
 */
@Api(value = "用户的题库试卷做题历史控制器", tags = {"我的题库通-用户的题库试卷做题历史管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/exam/record")
public class UserExamRecordController extends BaseController {

    private final IUserExamRecordService iUserExamRecordService;



    /**
     * 查询用户的做题历史试卷列表
     */
    @ApiOperation("查询用户的做题历史试卷列表")
    @GetMapping("/selectExamList")
    public AjaxResult<List<UserExamRecordVo>> selectExamList(UserExamRecordQueryBo bo) {
        List<UserExamRecordVo> list = iUserExamRecordService.selectExamList(bo);
        return AjaxResult.success(list);
    }

    /**
     * 获取用户的题库试卷做题历史详细信息
     */
    @ApiOperation("获取用户的题库试卷做题历史详细信息")
    @GetMapping("/{recordId}")
    public AjaxResult<UserExamRecordVo> getInfo(@PathVariable("recordId" ) Long recordId) {
        return AjaxResult.success(iUserExamRecordService.queryById(recordId));
    }

    /**
     * 查询用户的题库试卷做题历史列表
     */
    @ApiOperation("查询用户的题库试卷做题历史列表")
    @GetMapping("/list")
    public TableDataInfo<UserExamRecordVo> list(UserExamRecordQueryBo bo) {
        startPage();
        List<UserExamRecordVo> list = iUserExamRecordService.selectList(bo);
        return getDataTable(list);
    }

    /**
     * 修改用户的题库试卷做题历史
     */
    @ApiOperation("修改用户的题库试卷做题历史")
    @Log(title = "用户的题库试卷做题历史", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody UserExamRecordEditBo bo) {
        return toAjax(iUserExamRecordService.updateByEditBo(bo) ? 1 : 0);
    }
}
