package com.ruoyi.web.controller.front;

import com.google.common.collect.Maps;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ie.domain.Papers;
import com.ruoyi.ie.service.IPapersService;
import com.ruoyi.web.service.MxjbPaperExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(tags = "前端 试卷记录")
@RestController
@RequestMapping("front/customer/")
public class FrontCustomerPapersController extends BaseController {
    @Autowired
    private IPapersService papersService;
    @Autowired
    private MxjbPaperExamService mxjbPaperExamService;

    @ApiOperation("考试记录")
    @GetMapping(value = "records")
    public TableDataInfo records(@ApiParam("科目id") @RequestParam(required = false) Long subjectId
            , @ApiParam("试卷类别:know_test,历年真题,模拟试卷") @RequestParam(required = false) String paperType) {
        startPage();
        Map cond = Maps.newHashMap();
        cond.put("creatorId", SecurityUtils.getLoginUser().getUserId());
        cond.put("subjectId", subjectId);
        cond.put("paperType", paperType);
        List<Papers> list = papersService.selectMyPapersList(cond);
        return getDataTable(list);
    }

    @ApiOperation("考试记录详情")
    @GetMapping(value = "recordDetail")
    public AjaxResult recordDetail(@ApiParam("考卷标识") @RequestParam(required = false) Long examineeId) {
        return AjaxResult.success(mxjbPaperExamService.loadPaperByExamineeId(examineeId));
    }
}
