Search in sources :

Example 1 with OIRankVo

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

the class GroupRankManager method getGroupRankList.

public IPage<OIRankVo> getGroupRankList(Integer limit, Integer currentPage, String searchUser, Integer type, Long gid) throws StatusFailException {
    // 页数,每页题数若为空,设置默认值
    if (currentPage == null || currentPage < 1)
        currentPage = 1;
    if (limit == null || limit < 1)
        limit = 30;
    // 根据type查询不同 进行不同排序方式
    String rankType;
    if (type.intValue() == Constants.Contest.TYPE_ACM.getCode()) {
        rankType = Constants.Contest.TYPE_ACM.getName();
    } else if (type.intValue() == Constants.Contest.TYPE_OI.getCode()) {
        rankType = Constants.Contest.TYPE_OI.getName();
    } else {
        throw new StatusFailException("排行榜类型代码不正确,请使用0(ACM),1(OI)!");
    }
    QueryWrapper<GroupMember> groupMemberQueryWrapper = new QueryWrapper<>();
    groupMemberQueryWrapper.select("uid").eq("gid", gid).in("auth", 3, 4, 5);
    List<String> groupMemberUidList = groupMemberEntityService.list(groupMemberQueryWrapper).stream().map(GroupMember::getUid).collect(Collectors.toList());
    if (CollectionUtils.isEmpty(groupMemberUidList)) {
        return new Page<>(currentPage, limit);
    }
    if (!StringUtils.isEmpty(searchUser)) {
        QueryWrapper<UserInfo> userInfoQueryWrapper = new QueryWrapper<>();
        userInfoQueryWrapper.select("uuid").eq("status", 0).in("uuid", groupMemberUidList).and(wrapper -> wrapper.like("username", searchUser).or().like("nickname", searchUser).or().like("realname", searchUser));
        List<String> uidList = userInfoEntityService.list(userInfoQueryWrapper).stream().map(UserInfo::getUuid).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(uidList)) {
            return new Page<>(currentPage, limit);
        }
        Page<OIRankVo> page = new Page<>(currentPage, limit);
        return userRecordEntityService.getGroupRankList(page, gid, uidList, rankType, false);
    } else {
        Page<OIRankVo> page = new Page<>(currentPage, limit);
        return userRecordEntityService.getGroupRankList(page, gid, groupMemberUidList, rankType, true);
    }
}
Also used : GroupMember(top.hcode.hoj.pojo.entity.group.GroupMember) OIRankVo(top.hcode.hoj.pojo.vo.OIRankVo) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) StatusFailException(top.hcode.hoj.common.exception.StatusFailException) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) UserInfo(top.hcode.hoj.pojo.entity.user.UserInfo)

Aggregations

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 StatusFailException (top.hcode.hoj.common.exception.StatusFailException)1 GroupMember (top.hcode.hoj.pojo.entity.group.GroupMember)1 UserInfo (top.hcode.hoj.pojo.entity.user.UserInfo)1 OIRankVo (top.hcode.hoj.pojo.vo.OIRankVo)1