Search in sources :

Example 86 with IPage

use of com.baomidou.mybatisplus.core.metadata.IPage in project mogu_blog_v2 by moxi624.

the class CommentRestApi method getPraiseListByUser.

/**
 * 获取用户点赞信息
 *
 * @return
 */
@ApiOperation(value = "获取用户点赞信息", notes = "增加评论")
@PostMapping("/getPraiseListByUser")
public String getPraiseListByUser(@ApiParam(name = "currentPage", value = "当前页数", required = false) @RequestParam(name = "currentPage", required = false, defaultValue = "1") Long currentPage, @ApiParam(name = "pageSize", value = "每页显示数目", required = false) @RequestParam(name = "pageSize", required = false, defaultValue = "10") Long pageSize) {
    HttpServletRequest request = RequestHolder.getRequest();
    if (request.getAttribute(SysConf.USER_UID) == null || request.getAttribute(SysConf.TOKEN) == null) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.INVALID_TOKEN);
    }
    String userUid = request.getAttribute(SysConf.USER_UID).toString();
    QueryWrapper<Comment> queryWrappe = new QueryWrapper<>();
    queryWrappe.eq(SQLConf.USER_UID, userUid);
    queryWrappe.eq(SQLConf.TYPE, ECommentType.PRAISE);
    queryWrappe.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrappe.orderByDesc(SQLConf.CREATE_TIME);
    Page<Comment> page = new Page<>();
    page.setCurrent(currentPage);
    page.setSize(pageSize);
    IPage<Comment> pageList = commentService.page(page, queryWrappe);
    List<Comment> praiseList = pageList.getRecords();
    List<String> blogUids = new ArrayList<>();
    praiseList.forEach(item -> {
        blogUids.add(item.getBlogUid());
    });
    Map<String, Blog> blogMap = new HashMap<>();
    if (blogUids.size() > 0) {
        Collection<Blog> blogList = blogService.listByIds(blogUids);
        blogList.forEach(blog -> {
            // 并不需要content内容
            blog.setContent("");
            blogMap.put(blog.getUid(), blog);
        });
    }
    praiseList.forEach(item -> {
        if (blogMap.get(item.getBlogUid()) != null) {
            item.setBlog(blogMap.get(item.getBlogUid()));
        }
    });
    pageList.setRecords(praiseList);
    return ResultUtil.result(SysConf.SUCCESS, pageList);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) HttpServletRequest(javax.servlet.http.HttpServletRequest) ApiOperation(io.swagger.annotations.ApiOperation)

Example 87 with IPage

use of com.baomidou.mybatisplus.core.metadata.IPage in project mogu_blog_v2 by moxi624.

the class ResourceRestApi method getBlogByUid.

@ApiOperation(value = "通过分类来获取视频", notes = "通过Uid获取博客内容")
@GetMapping("/getStudyVideoBySort")
public String getBlogByUid(HttpServletRequest request, @ApiParam(name = "resourceSortUid", value = "资源分类UID", required = false) @RequestParam(name = "resourceSortUid", required = false) String resourceSortUid, @ApiParam(name = "currentPage", value = "当前页数", required = false) @RequestParam(name = "currentPage", required = false, defaultValue = "1") Long currentPage, @ApiParam(name = "pageSize", value = "每页显示数目", required = false) @RequestParam(name = "pageSize", required = false, defaultValue = "8") Long pageSize) {
    QueryWrapper<StudyVideo> queryWrapper = new QueryWrapper<>();
    Page<StudyVideo> page = new Page<>();
    page.setCurrent(currentPage);
    page.setSize(pageSize);
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    // 按点击数降序排列
    queryWrapper.orderByDesc(SQLConf.CLICK_COUNT);
    if (!StringUtils.isEmpty(resourceSortUid)) {
        queryWrapper.eq(SQLConf.RESOURCE_SORT_UID, resourceSortUid);
    }
    IPage<StudyVideo> pageList = studyVideoService.page(page, queryWrapper);
    List<StudyVideo> list = pageList.getRecords();
    // 获取所有的分类
    Set<String> resourceSortUids = new HashSet<>();
    String fileIds = "";
    for (StudyVideo item : list) {
        if (StringUtils.isNotEmpty(item.getResourceSortUid())) {
            resourceSortUids.add(item.getResourceSortUid());
        }
        if (StringUtils.isNotEmpty(item.getFileUid())) {
            fileIds = fileIds + item.getFileUid() + ",";
        }
    }
    // PictureList
    String result = this.pictureFeignClient.getPicture(fileIds, ",");
    List<Map<String, Object>> picList = webUtil.getPictureMap(result);
    // ResourceSort
    Collection<ResourceSort> resourceSortList = resourceSortService.listByIds(resourceSortUids);
    for (StudyVideo item : list) {
        List<String> photoList = new ArrayList<>();
        for (ResourceSort item2 : resourceSortList) {
            if (item.getResourceSortUid().equals(item2.getUid())) {
                item.setResourceSort(item2);
                break;
            }
        }
        for (Map<String, Object> map : picList) {
            // 因为资源可能有多个图片
            String fileUid = item.getFileUid();
            List<String> fileUids = StringUtils.changeStringToString(fileUid, ",");
            for (String uid : fileUids) {
                if (map.get("uid").toString().equals(uid)) {
                    photoList.add(map.get("url").toString());
                }
            }
        }
        item.setPhotoList(photoList);
    }
    log.info("返回结果");
    return ResultUtil.result(SysConf.SUCCESS, pageList);
}
Also used : StudyVideo(com.moxi.mogublog.commons.entity.StudyVideo) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) ResourceSort(com.moxi.mogublog.commons.entity.ResourceSort) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 88 with IPage

use of com.baomidou.mybatisplus.core.metadata.IPage in project javaBook-src by huifer.

the class IServerUrlServiceImpl method query.

@Override
public Result query(UrlQueryReq req, PageReq pageReq) {
    IPage<TUrl> page = new Page<>(pageReq.getNum(), pageReq.getSize());
    QueryWrapper queryWrapper = new QueryWrapper();
    if (StringUtils.isNotBlank(req.getUrl())) {
        queryWrapper.like(TUrl.COL_URL, req.getUrl());
    }
    if (StringUtils.isNotBlank(req.getContext())) {
        queryWrapper.like(TUrl.COL_CONTEXT, req.getContext());
    }
    IPage iPage = this.urlMapper.selectPage(page, queryWrapper);
    return OkResult.QUERY.to(iPage);
}
Also used : IPage(com.baomidou.mybatisplus.core.metadata.IPage) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) TUrl(org.huifer.rbac.entity.db.TUrl)

Example 89 with IPage

use of com.baomidou.mybatisplus.core.metadata.IPage in project HOJ by HimitZH.

the class ContestAdminManager method getContestPrint.

public IPage<ContestPrint> getContestPrint(Long cid, Integer currentPage, Integer limit) throws StatusForbiddenException {
    Session session = SecurityUtils.getSubject().getSession();
    UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
    // 获取本场比赛的状态
    Contest contest = contestEntityService.getById(cid);
    // 超级管理员或者该比赛的创建者,则为比赛管理者
    boolean isRoot = SecurityUtils.getSubject().hasRole("root");
    if (!isRoot && !contest.getUid().equals(userRolesVo.getUid()) && !(contest.getIsGroup() && groupValidator.isGroupRoot(userRolesVo.getUid(), contest.getGid()))) {
        throw new StatusForbiddenException("对不起,您无权限操作!");
    }
    if (currentPage == null || currentPage < 1)
        currentPage = 1;
    if (limit == null || limit < 1)
        limit = 30;
    // 获取当前比赛的,未被确定的排在签名
    IPage<ContestPrint> contestPrintIPage = new Page<>(currentPage, limit);
    QueryWrapper<ContestPrint> contestPrintQueryWrapper = new QueryWrapper<>();
    contestPrintQueryWrapper.select("id", "cid", "username", "realname", "status", "gmt_create").eq("cid", cid).orderByAsc("status").orderByDesc("gmt_create");
    return contestPrintEntityService.page(contestPrintIPage, contestPrintQueryWrapper);
}
Also used : StatusForbiddenException(top.hcode.hoj.common.exception.StatusForbiddenException) ContestPrint(top.hcode.hoj.pojo.entity.contest.ContestPrint) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) UserRolesVo(top.hcode.hoj.pojo.vo.UserRolesVo) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Contest(top.hcode.hoj.pojo.entity.contest.Contest) Session(org.apache.shiro.session.Session)

Example 90 with IPage

use of com.baomidou.mybatisplus.core.metadata.IPage in project HOJ by HimitZH.

the class ContestManager method getContestRank.

public IPage getContestRank(ContestRankDto contestRankDto) throws StatusFailException, StatusForbiddenException {
    Long cid = contestRankDto.getCid();
    List<String> concernedList = contestRankDto.getConcernedList();
    Integer currentPage = contestRankDto.getCurrentPage();
    Integer limit = contestRankDto.getLimit();
    Boolean removeStar = contestRankDto.getRemoveStar();
    Boolean forceRefresh = contestRankDto.getForceRefresh();
    if (cid == null) {
        throw new StatusFailException("错误:cid不能为空");
    }
    if (removeStar == null) {
        removeStar = false;
    }
    if (forceRefresh == null) {
        forceRefresh = false;
    }
    // 页数,每页题数若为空,设置默认值
    if (currentPage == null || currentPage < 1)
        currentPage = 1;
    if (limit == null || limit < 1)
        limit = 30;
    // 获取当前登录的用户
    Session session = SecurityUtils.getSubject().getSession();
    UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
    // 获取本场比赛的状态
    Contest contest = contestEntityService.getById(contestRankDto.getCid());
    // 超级管理员或者该比赛的创建者,则为比赛管理者
    boolean isRoot = SecurityUtils.getSubject().hasRole("root");
    // 需要对该比赛做判断,是否处于开始或结束状态才可以获取题目,同时若是私有赛需要判断是否已注册(比赛管理员包括超级管理员可以直接获取)
    contestValidator.validateContestAuth(contest, userRolesVo, isRoot);
    // 校验该比赛是否开启了封榜模式,超级管理员和比赛创建者可以直接看到实际榜单
    boolean isOpenSealRank = contestValidator.isSealRank(userRolesVo.getUid(), contest, forceRefresh, isRoot);
    IPage resultList;
    if (contest.getType().intValue() == Constants.Contest.TYPE_ACM.getCode()) {
        // ACM比赛
        // 进行排行榜计算以及排名分页
        resultList = contestRankManager.getContestACMRankPage(isOpenSealRank, removeStar, userRolesVo.getUid(), concernedList, contest, currentPage, limit);
    } else {
        // OI比赛
        resultList = contestRankManager.getContestOIRankPage(isOpenSealRank, removeStar, userRolesVo.getUid(), concernedList, contest, currentPage, limit);
    }
    return resultList;
}
Also used : IPage(com.baomidou.mybatisplus.core.metadata.IPage) StatusFailException(top.hcode.hoj.common.exception.StatusFailException) Session(org.apache.shiro.session.Session)

Aggregations

IPage (com.baomidou.mybatisplus.core.metadata.IPage)197 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)152 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)73 ApiOperation (io.swagger.annotations.ApiOperation)28 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)20 PageDTO (com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO)19 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 LoginUser (org.jeecg.common.system.vo.LoginUser)16 JSONObject (com.alibaba.fastjson.JSONObject)15 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)15 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)13 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)11 Result (org.jeecg.common.api.vo.Result)10 List (java.util.List)9 User (org.apache.dolphinscheduler.dao.entity.User)9 Field (java.lang.reflect.Field)8 Date (java.util.Date)8 Collectors (java.util.stream.Collectors)7 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)7