mongo查询
导入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency>
注入对象
@Resource
private MongoTemplate mongoTemplate;
private MongoTemplate mongoTemplate;
构造查询
String startDate = requestVO.getStartDate();
String endDate = requestVO.getEndDate();
Criteria criteria = Criteria.where("recordDate").gte(startDate).lte(endDate);
Query query = new Query(criteria);
String endDate = requestVO.getEndDate();
Criteria criteria = Criteria.where("recordDate").gte(startDate).lte(endDate);
Query query = new Query(criteria);
List<OperationTenantAppointmentBO> operationTenantAppointmentList = mongoTemplate.find(query, OperationTenantAppointmentBO.class);
实体类表
@Document(collection = "operation_tenant_appointment_sms") public class OperationTenantAppointmentBO { @Field("_id") private String id; /** * 租户id */ private Long tenantId; public String getId() { return id; } public void setId(String id) { this.id = id; } public Long getTenantId() { return tenantId; } public void setTenantId(Long tenantId) { this.tenantId = tenantId; } }