导入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency>
注入对象
@Resourceprivate MongoTemplate mongoTemplate; 构造查询 String startDate = requestVO.getStartDate();
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; } }
标签:查询,String,Long,public,tenantId,id,mongo From: https://www.cnblogs.com/Sweetp/p/17439981.html