Search in sources :

Example 1 with JudgeVo

use of top.hcode.hoj.pojo.vo.JudgeVo in project HOJ by HimitZH.

the class JudgeController method getJudgeList.

/**
 * @MethodName getJudgeList
 * @Params * @param null
 * @Description 通用查询判题记录列表
 * @Return CommonResult
 * @Since 2020/10/29
 */
@RequestMapping(value = "/submissions", method = RequestMethod.GET)
public CommonResult getJudgeList(@RequestParam(value = "limit", required = false) Integer limit, @RequestParam(value = "currentPage", required = false) Integer currentPage, @RequestParam(value = "onlyMine", required = false) Boolean onlyMine, @RequestParam(value = "problemID", required = false) String searchPid, @RequestParam(value = "status", required = false) Integer searchStatus, @RequestParam(value = "username", required = false) String searchUsername, @RequestParam(value = "completeProblemID", defaultValue = "false") Boolean completeProblemID, HttpServletRequest request) {
    // 页数,每页题数若为空,设置默认值
    if (currentPage == null || currentPage < 1)
        currentPage = 1;
    if (limit == null || limit < 1)
        limit = 30;
    String uid = null;
    // 只查看当前用户的提交
    if (onlyMine) {
        // 需要获取一下该token对应用户的数据(有token便能获取到)
        HttpSession session = request.getSession();
        UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
        if (userRolesVo == null) {
            return CommonResult.errorResponse("当前用户数据为空,请您重新登陆!", CommonResult.STATUS_ACCESS_DENIED);
        }
        uid = userRolesVo.getUid();
    }
    if (searchPid != null) {
        searchPid = searchPid.trim();
    }
    if (searchUsername != null) {
        searchUsername = searchUsername.trim();
    }
    IPage<JudgeVo> commonJudgeList = judgeService.getCommonJudgeList(limit, currentPage, searchPid, searchStatus, searchUsername, uid, completeProblemID);
    if (commonJudgeList.getTotal() == 0) {
        // 未查询到一条数据
        return CommonResult.successResponse(commonJudgeList, "暂无数据");
    } else {
        return CommonResult.successResponse(commonJudgeList, "获取成功");
    }
}
Also used : JudgeVo(top.hcode.hoj.pojo.vo.JudgeVo) HttpSession(javax.servlet.http.HttpSession) UserRolesVo(top.hcode.hoj.pojo.vo.UserRolesVo)

Example 2 with JudgeVo

use of top.hcode.hoj.pojo.vo.JudgeVo in project HOJ by HimitZH.

the class JudgeEntityServiceImpl method getCommonJudgeList.

@Override
public IPage<JudgeVo> getCommonJudgeList(Integer limit, Integer currentPage, String searchPid, Integer status, String username, String uid, Boolean completeProblemID, Long gid) {
    // 新建分页
    Page<JudgeVo> page = new Page<>(currentPage, limit);
    IPage<JudgeVo> commonJudgeList = judgeMapper.getCommonJudgeList(page, searchPid, status, username, uid, completeProblemID, gid);
    List<JudgeVo> records = commonJudgeList.getRecords();
    if (!CollectionUtils.isEmpty(records)) {
        List<Long> pidList = records.stream().map(JudgeVo::getPid).collect(Collectors.toList());
        QueryWrapper<Problem> problemQueryWrapper = new QueryWrapper<>();
        problemQueryWrapper.select("id", "title").in("id", pidList);
        List<Problem> problemList = problemMapper.selectList(problemQueryWrapper);
        HashMap<Long, String> storeMap = new HashMap<>(limit);
        for (JudgeVo judgeVo : records) {
            judgeVo.setTitle(getProblemTitleByPid(judgeVo.getPid(), problemList, storeMap));
        }
    }
    return commonJudgeList;
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) HashMap(java.util.HashMap) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) JudgeVo(top.hcode.hoj.pojo.vo.JudgeVo) Problem(top.hcode.hoj.pojo.entity.problem.Problem)

Aggregations

JudgeVo (top.hcode.hoj.pojo.vo.JudgeVo)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 HashMap (java.util.HashMap)1 HttpSession (javax.servlet.http.HttpSession)1 Problem (top.hcode.hoj.pojo.entity.problem.Problem)1 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)1