Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#orderByDesc()

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#orderByDesc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinkServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@Override
public String stickLink(LinkVO linkVO) {
    Link link = linkService.getById(linkVO.getUid());

    //查找出最大的那一个
    QueryWrapper<Link> queryWrapper = new QueryWrapper<>();
    queryWrapper.orderByDesc(SQLConf.SORT);
    Page<Link> page = new Page<>();
    page.setCurrent(0);
    page.setSize(1);
    IPage<Link> pageList = linkService.page(page, queryWrapper);
    List<Link> list = pageList.getRecords();
    Link maxSort = list.get(0);
    if (StringUtils.isEmpty(maxSort.getUid())) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.PARAM_INCORRECT);
    }
    if (maxSort.getUid().equals(link.getUid())) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.OPERATION_FAIL);
    }
    Integer sortCount = maxSort.getSort() + 1;
    link.setSort(sortCount);
    link.setUpdateTime(new Date());
    link.updateById();
    return ResultUtil.result(SysConf.SUCCESS, MessageConf.OPERATION_SUCCESS);
}
 
Example 2
Source File: LinkServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@Override
public IPage<Link> getPageList(LinkVO linkVO) {
    QueryWrapper<Link> queryWrapper = new QueryWrapper<>();
    if (StringUtils.isNotEmpty(linkVO.getKeyword()) && !StringUtils.isEmpty(linkVO.getKeyword().trim())) {
        queryWrapper.like(SQLConf.TITLE, linkVO.getKeyword().trim());
    }

    if (linkVO.getLinkStatus() != null) {
        queryWrapper.eq(SQLConf.LINK_STATUS, linkVO.getLinkStatus());
    }

    Page<Link> page = new Page<>();
    page.setCurrent(linkVO.getCurrentPage());
    page.setSize(linkVO.getPageSize());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT);
    IPage<Link> pageList = linkService.page(page, queryWrapper);
    return pageList;
}
 
Example 3
Source File: SysDictTypeServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@Override
public IPage<SysDictType> getPageList(SysDictTypeVO sysDictTypeVO) {
    QueryWrapper<SysDictType> queryWrapper = new QueryWrapper<>();

    // 字典名称
    if (StringUtils.isNotEmpty(sysDictTypeVO.getDictName()) && !StringUtils.isEmpty(sysDictTypeVO.getDictName().trim())) {
        queryWrapper.like(SQLConf.DICT_NAME, sysDictTypeVO.getDictName().trim());
    }

    // 字典类型
    if (StringUtils.isNotEmpty(sysDictTypeVO.getDictType()) && !StringUtils.isEmpty(sysDictTypeVO.getDictType().trim())) {
        queryWrapper.like(SQLConf.DICT_TYPE, sysDictTypeVO.getDictType().trim());
    }

    Page<SysDictType> page = new Page<>();
    page.setCurrent(sysDictTypeVO.getCurrentPage());
    page.setSize(sysDictTypeVO.getPageSize());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT, SQLConf.CREATE_TIME);
    IPage<SysDictType> pageList = sysDictTypeService.page(page, queryWrapper);
    return pageList;
}
 
Example 4
Source File: AuthRestApi.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "获取用户反馈", notes = "获取用户反馈")
@GetMapping("/getFeedbackList")
public String getFeedbackList(HttpServletRequest request) {
    if (request.getAttribute(SysConf.USER_UID) == null) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.INVALID_TOKEN);
    }
    String userUid = request.getAttribute(SysConf.USER_UID).toString();

    QueryWrapper<Feedback> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SQLConf.USER_UID, userUid);
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.CREATE_TIME);
    Page<Feedback> page = new Page<>();
    page.setSize(20);
    page.setCurrent(1);
    IPage<Feedback> pageList = feedbackService.page(page, queryWrapper);
    return ResultUtil.result(SysConf.SUCCESS, pageList);
}
 
Example 5
Source File: TagServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<Tag> getPageList(TagVO tagVO) {
    QueryWrapper<Tag> queryWrapper = new QueryWrapper<>();
    if (StringUtils.isNotEmpty(tagVO.getKeyword()) && !StringUtils.isEmpty(tagVO.getKeyword())) {
        queryWrapper.like(SQLConf.CONTENT, tagVO.getKeyword().trim());
    }

    Page<Tag> page = new Page<>();
    page.setCurrent(tagVO.getCurrentPage());
    page.setSize(tagVO.getPageSize());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT);
    IPage<Tag> pageList = tagService.page(page, queryWrapper);
    return pageList;
}
 
Example 6
Source File: SysAnnouncementController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
  * 分页列表查询
 * @param sysAnnouncement
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysAnnouncement>> queryPageList(SysAnnouncement sysAnnouncement,
								  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								  HttpServletRequest req) {
	Result<IPage<SysAnnouncement>> result = new Result<IPage<SysAnnouncement>>();
	sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
	QueryWrapper<SysAnnouncement> queryWrapper = new QueryWrapper<SysAnnouncement>(sysAnnouncement);
	Page<SysAnnouncement> page = new Page<SysAnnouncement>(pageNo,pageSize);
	//排序逻辑 处理
	String column = req.getParameter("column");
	String order = req.getParameter("order");
	if(oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
		if("asc".equals(order)) {
			queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column));
		}else {
			queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column));
		}
	}
	IPage<SysAnnouncement> pageList = sysAnnouncementService.page(page, queryWrapper);
	log.info("查询当前页:"+pageList.getCurrent());
	log.info("查询当前页数量:"+pageList.getSize());
	log.info("查询结果数量:"+pageList.getRecords().size());
	log.info("数据总数:"+pageList.getTotal());
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example 7
Source File: CategoryMenuServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public String stickCategoryMenu(CategoryMenuVO categoryMenuVO) {
    CategoryMenu categoryMenu = categoryMenuService.getById(categoryMenuVO.getUid());

    //查找出最大的那一个
    QueryWrapper<CategoryMenu> queryWrapper = new QueryWrapper<>();

    //如果是二级菜单 或者 按钮,就在当前的兄弟中,找出最大的一个
    if (categoryMenu.getMenuLevel() == 2 || categoryMenu.getMenuType() == EMenuType.BUTTON) {
        queryWrapper.eq(SQLConf.PARENT_UID, categoryMenu.getParentUid());
    }

    queryWrapper.eq(SQLConf.MENU_LEVEL, categoryMenu.getMenuLevel());

    queryWrapper.orderByDesc(SQLConf.SORT);

    queryWrapper.last("limit 1");

    CategoryMenu maxSort = categoryMenuService.getOne(queryWrapper);

    if (StringUtils.isEmpty(maxSort.getUid())) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.OPERATION_FAIL);
    }

    Integer sortCount = maxSort.getSort() + 1;

    categoryMenu.setSort(sortCount);
    categoryMenu.setUpdateTime(new Date());
    categoryMenu.updateById();
    return ResultUtil.result(SysConf.SUCCESS, MessageConf.OPERATION_SUCCESS);
}
 
Example 8
Source File: TagServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<Tag> getHotTag(Integer hotTagCount) {
    QueryWrapper<Tag> queryWrapper = new QueryWrapper<>();
    Page<Tag> page = new Page<>();
    page.setCurrent(1);
    page.setSize(hotTagCount);
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT);
    queryWrapper.orderByDesc(SQLConf.CLICK_COUNT);
    IPage<Tag> pageList = tagService.page(page, queryWrapper);
    return pageList;
}
 
Example 9
Source File: GatewayAccessLogsServiceImpl.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 分页查询
 *
 * @param pageParams
 * @return
 */
@Override
public IPage<GatewayAccessLogs> findListPage(PageParams pageParams) {
    GatewayAccessLogs query =  pageParams.mapToObject(GatewayAccessLogs.class);
    QueryWrapper<GatewayAccessLogs> queryWrapper = new QueryWrapper();
    queryWrapper.lambda()
            .likeRight(ObjectUtils.isNotEmpty(query.getPath()),GatewayAccessLogs::getPath, query.getPath())
            .eq(ObjectUtils.isNotEmpty(query.getIp()),GatewayAccessLogs::getIp, query.getIp())
            .eq(ObjectUtils.isNotEmpty(query.getServiceId()),GatewayAccessLogs::getServiceId, query.getServiceId());
    queryWrapper.orderByDesc("request_time");
    return gatewayLogsMapper.selectPage(pageParams,queryWrapper);
}
 
Example 10
Source File: SysAnnouncementSendController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
  * 分页列表查询
 * @param sysAnnouncementSend
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@GetMapping(value = "/list")
public Result<IPage<SysAnnouncementSend>> queryPageList(SysAnnouncementSend sysAnnouncementSend,
								  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								  HttpServletRequest req) {
	Result<IPage<SysAnnouncementSend>> result = new Result<IPage<SysAnnouncementSend>>();
	QueryWrapper<SysAnnouncementSend> queryWrapper = new QueryWrapper<SysAnnouncementSend>(sysAnnouncementSend);
	Page<SysAnnouncementSend> page = new Page<SysAnnouncementSend>(pageNo,pageSize);
	//排序逻辑 处理
	String column = req.getParameter("column");
	String order = req.getParameter("order");
	if(oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
		if("asc".equals(order)) {
			queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column));
		}else {
			queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column));
		}
	}
	IPage<SysAnnouncementSend> pageList = sysAnnouncementSendService.page(page, queryWrapper);
	//log.info("查询当前页:"+pageList.getCurrent());
	//log.info("查询当前页数量:"+pageList.getSize());
	//log.info("查询结果数量:"+pageList.getRecords().size());
	//log.info("数据总数:"+pageList.getTotal());
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example 11
Source File: BaseUserServiceImpl.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 分页查询
 *
 * @param pageParams
 * @return
 */
@Override
public IPage<BaseUser> findListPage(PageParams pageParams) {
    BaseUser query = pageParams.mapToObject(BaseUser.class);
    QueryWrapper<BaseUser> queryWrapper = new QueryWrapper();
    queryWrapper.lambda()
            .eq(ObjectUtils.isNotEmpty(query.getUserId()), BaseUser::getUserId, query.getUserId())
            .eq(ObjectUtils.isNotEmpty(query.getUserType()), BaseUser::getUserType, query.getUserType())
            .eq(ObjectUtils.isNotEmpty(query.getUserName()), BaseUser::getUserName, query.getUserName())
            .eq(ObjectUtils.isNotEmpty(query.getMobile()), BaseUser::getMobile, query.getMobile());
    queryWrapper.orderByDesc("create_time");
    return baseUserMapper.selectPage(pageParams, queryWrapper);
}
 
Example 12
Source File: BlogSortServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public List<BlogSort> getList() {
    QueryWrapper<BlogSort> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SysConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT);
    List<BlogSort> blogSortList = blogSortService.list(queryWrapper);
    return blogSortList;
}
 
Example 13
Source File: SysSmsServiceImpl.java    From hdw-dubbo with Apache License 2.0 5 votes vote down vote up
public PageVo selectSmsPageList(SmsDTO smsDTO) {
    QueryWrapper<SysSms> queryWrapper = new QueryWrapper<>();
    queryWrapper.lambda()
            .like(ObjectUtils.isNotEmpty(smsDTO.getTitle()), SysSms::getTitle, smsDTO.getTitle())
            .eq(ObjectUtils.isNotEmpty(smsDTO.getSmsTypeId()), SysSms::getSmsTypeId, smsDTO.getSmsTypeId());
    queryWrapper.like(ObjectUtils.isNotEmpty(smsDTO.getTypeName()), "t2.type_name", smsDTO.getTypeName());
    queryWrapper.orderByDesc("create_time");
    Page page = new Page();
    // 设置当前页码
    page.setCurrent(smsDTO.getPage());
    // 设置页大小
    page.setSize(smsDTO.getLimit());
    IPage ipage = this.baseMapper.selectSmsPageList(page, queryWrapper);
    return new PageVo(ipage);
}
 
Example 14
Source File: SysLogServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<SysLog> getPageList(SysLogVO sysLogVO) {

    QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>();

    if (StringUtils.isNotEmpty(sysLogVO.getUserName()) && !StringUtils.isEmpty(sysLogVO.getUserName().trim())) {
        queryWrapper.like(SQLConf.USER_NAME, sysLogVO.getUserName().trim());
    }

    if (!StringUtils.isEmpty(sysLogVO.getOperation())) {
        queryWrapper.like(SQLConf.OPERATION, sysLogVO.getOperation());
    }

    if (!StringUtils.isEmpty(sysLogVO.getStartTime())) {
        String[] time = sysLogVO.getStartTime().split(SysConf.FILE_SEGMENTATION);
        if (time.length == 2) {
            queryWrapper.between(SQLConf.CREATE_TIME, DateUtils.str2Date(time[0]), DateUtils.str2Date(time[1]));
        }
    }

    Page<SysLog> page = new Page<>();
    page.setCurrent(sysLogVO.getCurrentPage());
    page.setSize(sysLogVO.getPageSize());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.CREATE_TIME);
    IPage<SysLog> pageList = sysLogService.page(page, queryWrapper);
    return pageList;
}
 
Example 15
Source File: GatewayIpLimitServiceImpl.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 分页查询
 *
 * @param pageParams
 * @return
 */
@Override
public IPage<GatewayIpLimit> findListPage(PageParams pageParams) {
    GatewayIpLimit query = pageParams.mapToObject(GatewayIpLimit.class);
    QueryWrapper<GatewayIpLimit> queryWrapper = new QueryWrapper();
    queryWrapper.lambda()
            .likeRight(ObjectUtils.isNotEmpty(query.getPolicyName()),GatewayIpLimit::getPolicyName, query.getPolicyName())
            .eq(ObjectUtils.isNotEmpty(query.getPolicyType()),GatewayIpLimit::getPolicyType, query.getPolicyType());
    queryWrapper.orderByDesc("create_time");
    return gatewayIpLimitMapper.selectPage(pageParams,queryWrapper);
}
 
Example 16
Source File: BaseApiServiceImpl.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 分页查询
 *
 * @param pageParams
 * @return
 */
@Override
public IPage<BaseApi> findListPage(PageParams pageParams) {
    BaseApi query = pageParams.mapToObject(BaseApi.class);
    QueryWrapper<BaseApi> queryWrapper = new QueryWrapper();
    queryWrapper.lambda()
            .likeRight(ObjectUtils.isNotEmpty(query.getPath()), BaseApi::getPath, query.getPath())
            .likeRight(ObjectUtils.isNotEmpty(query.getApiName()), BaseApi::getApiName, query.getApiName())
            .likeRight(ObjectUtils.isNotEmpty(query.getApiCode()), BaseApi::getApiCode, query.getApiCode())
            .eq(ObjectUtils.isNotEmpty(query.getServiceId()), BaseApi::getServiceId, query.getServiceId())
            .eq(ObjectUtils.isNotEmpty(query.getStatus()), BaseApi::getStatus, query.getStatus())
            .eq(ObjectUtils.isNotEmpty(query.getIsAuth()), BaseApi::getIsAuth, query.getIsAuth());
    queryWrapper.orderByDesc("create_time");
    return baseApiMapper.selectPage(pageParams, queryWrapper);
}
 
Example 17
Source File: PermissionServiceImpl.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<Permission> findPermissionListWithLevel(Integer resourceType) {
    QueryWrapper queryWrapper = new QueryWrapper();
    if (resourceType != null) {
        queryWrapper.eq("resource_type", resourceType);
        queryWrapper.orderByDesc("sort");
    }
    List<Permission> permissionList = permissionMapper.selectList(queryWrapper);
    return PermissionUtil.getPermissionList(permissionList);

}
 
Example 18
Source File: NewsServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 新闻列表
 * @param page
 * @param limit
 * @return
 */
@Override
public List<NewsDTO> getList(int page, int limit) {
    QueryWrapper<WechatNewsArticle> wrapper = new QueryWrapper<>();
    wrapper.orderByDesc("id");
    Page<WechatNewsArticle> pageModel = new Page<>(page, limit);
    IPage<WechatNewsArticle> pageList = baseMapper.selectPage(pageModel,wrapper);

    return newsMapper.toDto(pageList.getRecords());
}
 
Example 19
Source File: FeedbackServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<Feedback> getPageList(FeedbackVO feedbackVO) {
    QueryWrapper<Feedback> queryWrapper = new QueryWrapper<>();
    if (StringUtils.isNotEmpty(feedbackVO.getTitle())) {
        queryWrapper.like(SQLConf.TITLE, feedbackVO.getTitle());
    }

    if (feedbackVO.getFeedbackStatus() != null) {
        queryWrapper.eq(SQLConf.FEEDBACK_STATUS, feedbackVO.getFeedbackStatus());
    }

    Page<Feedback> page = new Page<>();
    page.setCurrent(feedbackVO.getCurrentPage());
    page.setSize(feedbackVO.getPageSize());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.CREATE_TIME);
    IPage<Feedback> pageList = feedbackService.page(page, queryWrapper);

    List<Feedback> feedbackList = pageList.getRecords();
    List<String> userUids = new ArrayList<>();
    feedbackList.forEach(item -> {
        if (StringUtils.isNotEmpty(item.getUserUid())) {
            userUids.add(item.getUserUid());
        }
    });
    List<User> userList = userService.getUserListByIds(userUids);
    Map<String, User> map = new HashMap<>();
    userList.forEach(item -> {
        item.setPassWord("");
        map.put(item.getUid(), item);
    });

    feedbackList.forEach(item -> {
        if (StringUtils.isNotEmpty(item.getUserUid())) {
            item.setUser(map.get(item.getUserUid()));
        }
    });

    pageList.setRecords(feedbackList);
    return pageList;
}
 
Example 20
Source File: CommentRestApi.java    From mogu_blog_v2 with Apache License 2.0 4 votes vote down vote up
/**
 * 获取用户点赞信息
 *
 * @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);
}