Java Code Examples for org.springframework.data.mongodb.core.query.Criteria#andOperator()
The following examples show how to use
org.springframework.data.mongodb.core.query.Criteria#andOperator() .
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: RouteLogServiceImpl.java From FEBS-Cloud with Apache License 2.0 | 7 votes |
private Query getQuery(RouteLog routeLog) { Query query = new Query(); Criteria criteria = new Criteria(); if (StringUtils.isNotBlank(routeLog.getIp())) { criteria.and("ip").is(routeLog.getIp()); } if (StringUtils.isNotBlank(routeLog.getTargetServer())) { criteria.and("targetServer").is(routeLog.getTargetServer()); } if (StringUtils.isNotBlank(routeLog.getRequestMethod())) { criteria.and("requestMethod").is(routeLog.getRequestMethod().toUpperCase()); } if (StringUtils.isNotBlank(routeLog.getCreateTimeFrom()) && StringUtils.isNotBlank(routeLog.getCreateTimeTo())) { criteria.andOperator( Criteria.where("createTime").gt(routeLog.getCreateTimeFrom()), Criteria.where("createTime").lt(routeLog.getCreateTimeTo()) ); } query.addCriteria(criteria); return query; }
Example 2
Source File: RateLimitLogServiceImpl.java From FEBS-Cloud with Apache License 2.0 | 6 votes |
private Query getQuery(RateLimitLog rateLimitLog) { Query query = new Query(); Criteria criteria = new Criteria(); if (StringUtils.isNotBlank(rateLimitLog.getIp())) { criteria.and("ip").is(rateLimitLog.getIp()); } if (StringUtils.isNotBlank(rateLimitLog.getRequestMethod())) { criteria.and("requestMethod").is(rateLimitLog.getRequestMethod()); } if (StringUtils.isNotBlank(rateLimitLog.getRequestUri())) { criteria.and("requestUri").is(rateLimitLog.getRequestUri()); } if (StringUtils.isNotBlank(rateLimitLog.getCreateTimeFrom()) && StringUtils.isNotBlank(rateLimitLog.getCreateTimeTo())) { criteria.andOperator( Criteria.where("createTime").gt(rateLimitLog.getCreateTimeFrom()), Criteria.where("createTime").lt(rateLimitLog.getCreateTimeTo()) ); } query.addCriteria(criteria); return query; }
Example 3
Source File: BlockLogServiceImpl.java From FEBS-Cloud with Apache License 2.0 | 6 votes |
private Query getQuery(BlockLog blockLog) { Query query = new Query(); Criteria criteria = new Criteria(); if (StringUtils.isNotBlank(blockLog.getRequestMethod())) { criteria.and("requestMethod").is(blockLog.getRequestMethod()); } if (StringUtils.isNotBlank(blockLog.getIp())) { criteria.and("ip").is(blockLog.getIp()); } if (StringUtils.isNotBlank(blockLog.getCreateTimeFrom()) && StringUtils.isNotBlank(blockLog.getCreateTimeTo())) { criteria.andOperator( Criteria.where("createTime").gt(blockLog.getCreateTimeFrom()), Criteria.where("createTime").lt(blockLog.getCreateTimeTo()) ); } if (StringUtils.isNotBlank(blockLog.getRequestUri())) { criteria.and("requestUri").is(blockLog.getRequestUri()); } query.addCriteria(criteria); return query; }
Example 4
Source File: ErrorLogServiceImpl.java From SuperBoot with MIT License | 5 votes |
@Override public BaseResponse getErrorLogGroupByAppName() throws BaseException { //查询条件信息 Criteria operator = new Criteria(); operator.andOperator( //查询当天的数据汇总 Criteria.where("execDate").is(DateUtil.today()) ); //查询条件 MatchOperation matchOperation = Aggregation.match(operator); //分组信息及返回count列命名 GroupOperation groupOperation = Aggregation.group("serUrl", "serPort", "appName", "appSer", "reqUrl", "execDate").count().as("count"); //排序信息 Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "count")); SortOperation sortOperation = Aggregation.sort(sort); //组合条件 Aggregation aggregation = Aggregation.newAggregation(ErrorInfo.class, matchOperation, groupOperation, sortOperation); // 执行操作 AggregationResults<Map> aggregationResults = template.aggregate(aggregation, ErrorInfo.class, Map.class); return new BaseResponse(aggregationResults.getMappedResults()); }
Example 5
Source File: LogServiceImpl.java From SuperBoot with MIT License | 5 votes |
@Override public BaseResponse getRequestCountByWeek() throws BaseException { //查询条件信息 Criteria operator = new Criteria(); operator.andOperator( //查询小于等于今天 Criteria.where("execDate").lte(DateUtil.today()), //查询大于等于7天前 Criteria.where("execDate").gte(DateUtil.formatDate(DateUtil.offsetDay(DateUtil.date(), -7))) ); //查询条件 MatchOperation matchOperation = Aggregation.match(operator); //分组信息及返回count列命名 GroupOperation groupOperation = Aggregation.group("appName", "execDate").count().as("count"); //排序信息 Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC, "execDate")); SortOperation sortOperation = Aggregation.sort(sort); //组合条件 Aggregation aggregation = Aggregation.newAggregation(DataInfo.class, matchOperation, groupOperation, sortOperation); // 执行操作 AggregationResults<Map> aggregationResults = template.aggregate(aggregation, DataInfo.class, Map.class); return new BaseResponse(aggregationResults.getMappedResults()); }