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

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#like() . 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: ApiLoggerServiceImpl.java    From sophia_scaffolding with Apache License 2.0 6 votes vote down vote up
@Override
public IPage<ApiLoggerVo> queryApiLoggerList(ApiLoggerSearchDto param) {
    Integer currentPage = param.getCurrentPage() == null ? 1 : param.getCurrentPage();
    Integer pageSize = param.getPageSize() == null ? 10 : param.getPageSize();
    Page<ApiLoggerVo> result = new Page<>(currentPage, pageSize);
    Page<ApiLogger> page = new Page<>(currentPage, pageSize);
    QueryWrapper<ApiLogger> queryWrapper = new QueryWrapper<>();
    queryWrapper.like(StringUtils.isNotBlank(param.getUserName()), "USER_NAME", param.getUserName());
    queryWrapper.like(StringUtils.isNotBlank(param.getMethod()), "METHOD", param.getMethod());
    queryWrapper.like(StringUtils.isNotBlank(param.getMethodName()), "METHOD_NAME", param.getMethodName());
    queryWrapper.ge(null != param.getStartTime(), "CREATE_TIME", param.getStartTime());
    queryWrapper.le(null != param.getEndTime(), "CREATE_TIME", param.getEndTime());
    queryWrapper.orderByDesc("CREATE_TIME");
    IPage<ApiLogger> iPage = baseMapper.selectPage(page, queryWrapper);
    BeanUtils.copyProperties(iPage, result);
    return result.setRecords(new ApiLoggerVo().buildVoList(iPage.getRecords()));
}
 
Example 2
Source File: BlogServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: RegisterCenterServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<RegisterCenterModel> findPageByParam(RegisterCenterPageRequest model) {
    PageResult<RegisterCenterModel> pageResult= new PageResult<RegisterCenterModel>();
    Page pageRequest = new Page(model.getPageNo(),model.getPageSize());
    QueryWrapper<RegisterCenter> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(model.getCode())){
        queryWrapper.like("code",model.getCode());
    }
    queryWrapper.eq("is_deleted",Constants.IS_DELETE_FALSE);
    IPage<RegisterCenter> page=registerCenterMapper.selectPage(pageRequest, queryWrapper);
    List<RegisterCenterModel> list= BeanMapper.mapList(page.getRecords(),RegisterCenter.class,RegisterCenterModel.class);
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 4
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 5
Source File: AppServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
/**
 * 根据查询条件查询App并分页
 * @param appPageRequest
 * @return
 */
@Override
public PageResult<AppModel> findByPageVague(AppPageRequest appPageRequest) {
    Page pageRequest = new Page(appPageRequest.getPageNo(), appPageRequest.getPageSize());
    QueryWrapper<App> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(appPageRequest.getProjectName())){
        queryWrapper.like("project_name", appPageRequest.getProjectName());
    }
    if(StringUtils.isNotEmpty(appPageRequest.getStatus())){
        queryWrapper.eq("status",Integer.valueOf(appPageRequest.getStatus()).intValue());
    }
    if(StringUtils.isNotEmpty(appPageRequest.getName())){
        queryWrapper.like("app_id", appPageRequest.getName().toLowerCase());
    }
    if(StringUtils.isNotEmpty(appPageRequest.getTakeOver())){
        queryWrapper.eq("take_over",Long.valueOf(appPageRequest.getTakeOver()).intValue());
    }
    IPage<App> page=appMapper.selectPage(pageRequest, queryWrapper);
    List<AppModel> list= BeanMapper.mapList(page.getRecords(),App.class,AppModel.class);
    PageResult<AppModel> pageResult=new PageResult<AppModel>();
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 6
Source File: SysLogController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:查询日志记录
 * @param syslog
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysLog>> queryPageList(SysLog syslog,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysLog>> result = new Result<IPage<SysLog>>();
	QueryWrapper<SysLog> queryWrapper = QueryGenerator.initQueryWrapper(syslog, req.getParameterMap());
	Page<SysLog> page = new Page<SysLog>(pageNo, pageSize);
	//日志关键词
	String keyWord = req.getParameter("keyWord");
	if(oConvertUtils.isNotEmpty(keyWord)) {
		queryWrapper.like("log_content",keyWord);
	}
	//TODO 过滤逻辑处理
	//TODO begin、end逻辑处理
	//TODO 一个强大的功能,前端传一个字段字符串,后台只返回这些字符串对应的字段
	//创建时间/创建人的赋值
	IPage<SysLog> pageList = sysLogService.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: LinkServiceImpl.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public QueryWrapper<Link> getQueryWrapper(Link link) {
    //对指定字段查询
    QueryWrapper<Link> queryWrapper = new QueryWrapper<>();
    if (link != null) {
        if (StrUtil.isNotBlank(link.getLinkName())) {
            queryWrapper.like("link_name", link.getLinkName());
        }
        if (StrUtil.isNotBlank(link.getLinkUrl())) {
            queryWrapper.like("link_url", link.getLinkUrl());
        }
    }
    return queryWrapper;
}
 
Example 8
Source File: CategoryServiceImpl.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public QueryWrapper<Category> getQueryWrapper(Category category) {
    //对指定字段查询
    QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
    if (category != null) {
        if (StrUtil.isNotBlank(category.getCateName())) {
            queryWrapper.like("cate_name", category.getCateName());
        }
        if (category.getCateLevel() != null) {
            queryWrapper.eq("cate_level", category.getCateLevel());
        }
    }
    return queryWrapper;
}
 
Example 9
Source File: DictController.java    From Taroco with Apache License 2.0 5 votes vote down vote up
/**
 * 分页查询字典信息
 *
 * @param params 分页对象
 * @return 分页对象
 */
@GetMapping("/dictPage")
@RequireRole(RoleConst.ADMIN)
public Page dictPage(@RequestParam Map<String, Object> params) {
    final QueryWrapper<SysDict> query = new QueryWrapper<>();
    query.eq(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL);
    final String typeKey = "type";
    if (params.containsKey(typeKey) && !ObjectUtils.isEmpty(params.get(typeKey))) {
        query.like(typeKey, params.get(typeKey));
    }
    return (Page) sysDictService.page(new PageQuery<>(params), query);
}
 
Example 10
Source File: BlogServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<Blog> searchBlogByTag(String tagUid, Long currentPage, Long pageSize) {
    Tag tag = tagService.getById(tagUid);
    if (tag != null) {
        HttpServletRequest request = RequestHolder.getRequest();
        String ip = IpUtils.getIpAddr(request);
        //从Redis取出数据,判断该用户24小时内,是否点击过该标签
        String jsonResult = redisUtil.get(RedisConf.TAG_CLICK + RedisConf.SEGMENTATION + ip + "#" + tagUid);
        if (StringUtils.isEmpty(jsonResult)) {

            //给标签点击数增加
            int clickCount = tag.getClickCount() + 1;
            tag.setClickCount(clickCount);
            tag.updateById();
            //将该用户点击记录存储到redis中, 24小时后过期
            redisUtil.setEx(RedisConf.TAG_CLICK + RedisConf.SEGMENTATION + ip + RedisConf.WELL_NUMBER + tagUid, clickCount + "",
                    24, TimeUnit.HOURS);
        }
    }
    QueryWrapper<Blog> queryWrapper = new QueryWrapper<>();
    Page<Blog> page = new Page<>();
    page.setCurrent(currentPage);
    page.setSize(pageSize);

    queryWrapper.like(SQLConf.TagUid, tagUid);
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.eq(BaseSQLConf.IS_PUBLISH, EPublish.PUBLISH);
    queryWrapper.orderByDesc(SQLConf.CREATE_TIME);
    queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SysConf.CONTENT));
    IPage<Blog> pageList = blogService.page(page, queryWrapper);
    List<Blog> list = pageList.getRecords();
    list = blogService.setTagAndSortAndPictureByBlogList(list);
    pageList.setRecords(list);
    return pageList;
}
 
Example 11
Source File: BlogSortServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<BlogSort> getPageList(BlogSortVO blogSortVO) {
    QueryWrapper<BlogSort> queryWrapper = new QueryWrapper<>();
    if (StringUtils.isNotEmpty(blogSortVO.getKeyword()) && !StringUtils.isEmpty(blogSortVO.getKeyword().trim())) {
        queryWrapper.like(SQLConf.SORT_NAME, blogSortVO.getKeyword().trim());
    }
    Page<BlogSort> page = new Page<>();
    page.setCurrent(blogSortVO.getCurrentPage());
    page.setSize(blogSortVO.getPageSize());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT);
    IPage<BlogSort> pageList = blogSortService.page(page, queryWrapper);
    return pageList;
}
 
Example 12
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 13
Source File: RoleServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<Role> getPageList(RoleVO roleVO) {
    QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
    if (StringUtils.isNotEmpty(roleVO.getKeyword()) && StringUtils.isNotEmpty(roleVO.getKeyword().trim())) {
        queryWrapper.like(SQLConf.ROLENAEM, roleVO.getKeyword().trim());
    }
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    Page<Role> page = new Page<>();
    page.setCurrent(roleVO.getCurrentPage());
    page.setSize(roleVO.getPageSize());
    IPage<Role> pageList = roleService.page(page, queryWrapper);
    return pageList;
}
 
Example 14
Source File: SlideServiceImpl.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public QueryWrapper<Slide> getQueryWrapper(Slide slide) {
    //对指定字段查询
    QueryWrapper<Slide> queryWrapper = new QueryWrapper<>();
    if (slide != null) {
        if (StrUtil.isNotBlank(slide.getSlideTitle())) {
            queryWrapper.like("slide_title", slide.getSlideTitle());
        }
        if (slide.getSlideType() != null) {
            queryWrapper.eq("slide_type", slide.getSlideType());
        }
    }
    return queryWrapper;
}
 
Example 15
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 16
Source File: ObjectParseUtil.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
public static void addCriteria(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		queryWrapper.in(name, (Object[]) value);
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		break;
	}
}
 
Example 17
Source File: GoodsServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 商品列表
 * @param cateId
 * @param page
 * @param limit
 * @param userId
 * @param keywords
 * @param order
 * @return
 */
@Override
public List<GoodsDTO> getList(int cateId, int page, int limit, int userId,
                              String keywords,int order) {

    QueryWrapper<StoreGoods> wrapper = new QueryWrapper<>();

    if(cateId > 0){
        wrapper.eq("cate_id",cateId);
    }
    if(StrUtil.isNotEmpty(keywords)){
        wrapper.like("goods_name",keywords);
    }

    //todo order = 1 推荐  order=2  新品
    switch (order){
        case 1:
            wrapper.eq("is_recommend",1);
            break;
        case 2:
            wrapper.eq("is_new",1);
            break;
    }
    Page<StoreGoods> pageModel = new Page<>(page, limit);

    IPage<StoreGoods> pageList = storeGoodsMapper.selectPage(pageModel,wrapper);

    List<GoodsDTO> list = goodsMapper.toDto(pageList.getRecords());

    for (GoodsDTO goodsDTO : list) {
        goodsDTO.setIsCollect(isCollect(goodsDTO.getGoodsId(),userId));
    }

    return list;
    //return null;
}
 
Example 18
Source File: QueryGenerator.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
/**
  * 根据规则走不同的查询
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null || oConvertUtils.isEmpty(value)) {
		return;
	}
	name = oConvertUtils.camelToUnderline(name);
	log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		if(value instanceof String) {
			queryWrapper.in(name, (Object[])value.toString().split(","));
		}else if(value instanceof String[]) {
			queryWrapper.in(name, (Object[]) value);
		}else {
			queryWrapper.in(name, value);
		}
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		log.info("--查询规则未匹配到---");
		break;
	}
}
 
Example 19
Source File: UserServiceImpl.java    From Moss with Apache License 2.0 4 votes vote down vote up
@Override
public List<UserModel> getUserList() {
    QueryWrapper<User> queryWrapper = new QueryWrapper<>();
    queryWrapper.like("is_deleted", Constants.IS_DELETE_FALSE);
    return BeanMapper.mapList(userMapper.selectList(queryWrapper),User.class,UserModel.class);
}
 
Example 20
Source File: QueryGenerator.java    From jeecg-boot-with-activiti with MIT License 4 votes vote down vote up
/**
  * 根据规则走不同的查询
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	name = oConvertUtils.camelToUnderline(name);
	log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		if(value instanceof String) {
			queryWrapper.in(name, (Object[])value.toString().split(","));
		}else if(value instanceof String[]) {
			queryWrapper.in(name, (Object[]) value);
		}else {
			queryWrapper.in(name, value);
		}
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		log.info("--查询规则未匹配到---");
		break;
	}
}