Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#eq()
The following examples show how to use
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#eq() .
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: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public IPage<Blog> getSameBlogByTagUid(String tagUid) { QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); Page<Blog> page = new Page<>(); page.setCurrent(1); page.setSize(10); queryWrapper.like(SQLConf.TAG_UID, tagUid); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.eq(SQLConf.IS_PUBLISH, EPublish.PUBLISH); IPage<Blog> pageList = blogService.page(page, queryWrapper); List<Blog> list = pageList.getRecords(); list = blogService.setTagAndSortByBlogList(list); pageList.setRecords(list); return pageList; }
Example 2
Source File: PermissionServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@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 3
Source File: CommentServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@Override public Page<Comment> pagingCommentsByPostAndCommentStatus(Long postId, Integer status, Page<Comment> page) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("post_id", postId); queryWrapper.eq("comment_status", status); return (Page<Comment>) commentMapper.selectPage(page, queryWrapper); }
Example 4
Source File: CommentServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@Override public List<Comment> findByAcceptUserAndStatus(Long userId, Integer status) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("accept_user_id", userId); queryWrapper.eq("comment_status", status); return commentMapper.selectList(queryWrapper); }
Example 5
Source File: UserServiceImpl.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
/** * 分页查询用户信息(含有角色信息) * * @param pm 分页对象 * @return */ @Override @Transactional(readOnly = true, rollbackFor = Exception.class) public IPage<UserVo> findPage(PageModel pm, UserQueryCriteria userQueryCriteria, DataScope dataScope) { // pm.addOrder(OrderItem.desc("a.created_date")); QueryWrapper wrapper = QueryWrapperUtil.getWrapper(pm, userQueryCriteria); wrapper.eq("a.del_flag", User.FLAG_NORMAL); IPage<UserVo> userVosPage = repository.findUserVoPage(pm, wrapper, dataScope); return userVosPage; }
Example 6
Source File: BlogSortServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public String blogSortByCite() { // 定义Map key:tagUid, value: 引用量 Map<String, Integer> map = new HashMap<>(); QueryWrapper<BlogSort> blogSortQueryWrapper = new QueryWrapper<>(); blogSortQueryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); List<BlogSort> blogSortList = blogSortService.list(blogSortQueryWrapper); // 初始化所有标签的引用量 blogSortList.forEach(item -> { map.put(item.getUid(), 0); }); QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.eq(SQLConf.IS_PUBLISH, EPublish.PUBLISH); // 过滤content字段 queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SQLConf.CONTENT)); List<Blog> blogList = blogService.list(queryWrapper); blogList.forEach(item -> { String blogSortUid = item.getBlogSortUid(); if (map.get(blogSortUid) != null) { Integer count = map.get(blogSortUid) + 1; map.put(blogSortUid, count); } else { map.put(blogSortUid, 0); } }); blogSortList.forEach(item -> { item.setSort(map.get(item.getUid())); item.setUpdateTime(new Date()); }); blogSortService.updateBatchById(blogSortList); return ResultUtil.result(SysConf.SUCCESS, MessageConf.OPERATION_SUCCESS); }
Example 7
Source File: CategoryMenuServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@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: PostServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@Override public List<Post> findByPostTypeAndStatus(String postType, Integer status) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("post_type", postType); queryWrapper.eq("post_status", status); return postMapper.selectList(queryWrapper); }
Example 9
Source File: GoodsServiceImpl.java From supplierShop with MIT License | 5 votes |
@Override public Map<String,StoreSpecGoodsPrice> goodsSpecPrice(int goodsId) { QueryWrapper<StoreSpecGoodsPrice> wrapper = new QueryWrapper<>(); wrapper.eq("goods_id",goodsId); List<StoreSpecGoodsPrice> specGoodsPriceList = storeSpecGoodsPriceMapper .selectList(wrapper); if(ObjectUtil.isNull(specGoodsPriceList)){ System.out.println("2222"); throw new EntityExistException(specGoodsPriceList.getClass()); } Map<String, StoreSpecGoodsPrice> listMap = specGoodsPriceList.stream().collect( Collectors.toMap(StoreSpecGoodsPrice::getKey,o->o)); return listMap; }
Example 10
Source File: PermissionController.java From Taroco with Apache License 2.0 | 5 votes |
/** * 分页查询 * * @param params 分页对象 * @return 分页对象 */ @GetMapping("/page") @RequireRole(RoleConst.ADMIN) public Response page(@RequestParam Map<String, Object> params) { final QueryWrapper<SysPermission> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); final String codeKey = "code"; if (params.containsKey(codeKey) && !ObjectUtils.isEmpty(params.get(codeKey))) { queryWrapper.like(codeKey, params.get(codeKey)); } return Response.success(permissionService.page(new PageQuery<>(params), queryWrapper)); }
Example 11
Source File: PostServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@Override public Page<Post> pagingByPostTypeAndStatus(String postType, Integer status, Page<Post> page) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("post_type", postType); queryWrapper.eq("post_status", status); return (Page<Post>) postMapper.selectPage(page, queryWrapper); }
Example 12
Source File: WidgetServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@Override public QueryWrapper<Widget> getQueryWrapper(Widget widget) { //对指定字段查询 QueryWrapper<Widget> queryWrapper = new QueryWrapper<>(); if (widget != null) { if (StrUtil.isNotBlank(widget.getWidgetTitle())) { queryWrapper.eq("widget_title", widget.getWidgetTitle()); } if (widget.getWidgetType() != null) { queryWrapper.like("widget_type", widget.getWidgetType()); } } return queryWrapper; }
Example 13
Source File: LinkServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public List<Link> getListByPageSize(Integer pageSize) { QueryWrapper<Link> queryWrapper = new QueryWrapper<>(); Page<Link> page = new Page<>(); page.setCurrent(1); page.setSize(pageSize); queryWrapper.eq(BaseSQLConf.LINK_STATUS, ELinkStatus.PUBLISH); queryWrapper.eq(BaseSQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(BaseSQLConf.SORT); IPage<Link> pageList = linkMapper.selectPage(page, queryWrapper); return pageList.getRecords(); }
Example 14
Source File: ThirdAppBindServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
@Override public ThirdAppBind findByAppTypeAndOpenId(String appType, String openId) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("app_type", appType); queryWrapper.eq("open_id", openId); return thirdAppBindMapper.selectOne(queryWrapper); }
Example 15
Source File: TagServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public String tagSortByCite() { // 定义Map key:tagUid, value: 引用量 Map<String, Integer> map = new HashMap<>(); QueryWrapper<Tag> tagQueryWrapper = new QueryWrapper<>(); tagQueryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); List<Tag> tagList = tagService.list(tagQueryWrapper); // 初始化所有标签的引用量 tagList.forEach(item -> { map.put(item.getUid(), 0); }); QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.eq(SQLConf.IS_PUBLISH, EPublish.PUBLISH); // 过滤content字段 queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SQLConf.CONTENT)); List<Blog> blogList = blogService.list(queryWrapper); blogList.forEach(item -> { String tagUids = item.getTagUid(); List<String> tagUidList = StringUtils.changeStringToString(tagUids, SysConf.FILE_SEGMENTATION); for (String tagUid : tagUidList) { if (map.get(tagUid) != null) { Integer count = map.get(tagUid) + 1; map.put(tagUid, count); } else { map.put(tagUid, 0); } } }); tagList.forEach(item -> { item.setSort(map.get(item.getUid())); item.setUpdateTime(new Date()); }); tagService.updateBatchById(tagList); return ResultUtil.result(SysConf.SUCCESS, MessageConf.OPERATION_SUCCESS); }
Example 16
Source File: CategoryMenuServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> getPageList(CategoryMenuVO categoryMenuVO) { Map<String, Object> resultMap = new HashMap<>(); QueryWrapper<CategoryMenu> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(categoryMenuVO.getKeyword()) && !StringUtils.isEmpty(categoryMenuVO.getKeyword().trim())) { queryWrapper.like(SQLConf.NAME, categoryMenuVO.getKeyword().trim()); } if (categoryMenuVO.getMenuLevel() != 0) { queryWrapper.eq(SQLConf.MENU_LEVEL, categoryMenuVO.getMenuLevel()); } Page<CategoryMenu> page = new Page<>(); page.setCurrent(categoryMenuVO.getCurrentPage()); page.setSize(categoryMenuVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.SORT); IPage<CategoryMenu> pageList = categoryMenuService.page(page, queryWrapper); List<CategoryMenu> list = pageList.getRecords(); List<String> ids = new ArrayList<>(); list.forEach(item -> { if (StringUtils.isNotEmpty(item.getParentUid())) { ids.add(item.getParentUid()); } }); if (ids.size() > 0) { Collection<CategoryMenu> parentList = categoryMenuService.listByIds(ids); Map<String, CategoryMenu> map = new HashMap<>(); parentList.forEach(item -> { map.put(item.getUid(), item); }); list.forEach(item -> { if (StringUtils.isNotEmpty(item.getParentUid())) { item.setParentCategoryMenu(map.get(item.getParentUid())); } }); resultMap.put(SysConf.OTHER_DATA, parentList); } pageList.setRecords(list); resultMap.put(SysConf.DATA, pageList); return resultMap; }
Example 17
Source File: CommentRestApi.java From mogu_blog_v2 with Apache License 2.0 | 4 votes |
/** * 获取用户点赞信息 * * @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); }
Example 18
Source File: TagServiceImpl.java From SENS with GNU General Public License v3.0 | 4 votes |
@Override public List<Tag> findByUserId(Long userId) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("user_id", userId); return tagMapper.selectList(queryWrapper); }
Example 19
Source File: MenuService.java From SpringCloud with Apache License 2.0 | 4 votes |
@Override public List<Menu> query(MenuQueryParam menuQueryParam) { QueryWrapper<Menu> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(null != menuQueryParam.getName(), "name", menuQueryParam.getName()); return this.list(queryWrapper); }
Example 20
Source File: RoleServiceImpl.java From SENS with GNU General Public License v3.0 | 4 votes |
@Override public Role findByRoleName(String roleName) { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("role", roleName); return roleMapper.selectOne(queryWrapper); }