| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.data.mongodb.core.MongoTemplate;
|
| | | import org.springframework.data.mongodb.core.mapping.Document;
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.data.mongodb.core.query.Update;
|
| | |
| | | public List<T> findList(Query query) {
|
| | | return mongoTemplate.find(query, this.getEntityClass());
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 统计数量
|
| | | * |
| | | * @param query
|
| | | * @return
|
| | | */
|
| | | public long count(Query query) {
|
| | | return mongoTemplate.count(query, this.getEntityClass());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 主键查询
|
| | |
| | | Query query = Query.query(Criteria.where("id").is(id));
|
| | | mongoTemplate.remove(query, getEntityClass());
|
| | | }
|
| | | |
| | | public void delete(Query query) {
|
| | | mongoTemplate.remove(query, getEntityClass());
|
| | | }
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | protected Class<T> getEntityClass() {
|