Commit b16681cd79a341946e41366499b4cf38c31fe90d
1 parent
b932e04966
Exists in
master
and in
8 other branches
修改
Showing 2 changed files with 20 additions and 3 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java
View file @
b16681c
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | return save(obj); |
| 33 | 33 | } |
| 34 | 34 | public void findAndModify(MongoQuery query,Patients obj){ |
| 35 | - findAndModify(query.convertToMongoQuery(),obj); | |
| 35 | + updateMulti(query.convertToMongoQuery(),obj); | |
| 36 | 36 | } |
| 37 | 37 | @Override |
| 38 | 38 | public void updatePatient(Patients obj, String id) { |
platform-common/src/main/java/com/lyms/platform/common/dao/BaseMongoDAOImpl.java
View file @
b16681c
| ... | ... | @@ -100,15 +100,32 @@ |
| 100 | 100 | mongoTemplate.findAllAndRemove(query, this.getEntityClass()); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - | |
| 103 | + /** | |
| 104 | + * 修改找到的第一条数据 | |
| 105 | + * | |
| 106 | + * @param query | |
| 107 | + * @param obj | |
| 108 | + */ | |
| 104 | 109 | public void findAndModify(Query query,T obj){ |
| 105 | 110 | Assert.notNull(obj, "execute findAndModify method must not null."); |
| 106 | 111 | Update update = MongoConvertHelper |
| 107 | 112 | .convertToNativeUpdate(ReflectionUtils.getUpdateField(obj)); |
| 108 | - Assert.notNull(update, "execute findAndModify method must not null.update:"+update); | |
| 113 | + Assert.notNull(update, "execute findAndModify method must not null.update:" + update); | |
| 109 | 114 | mongoTemplate.findAndModify(query,update,this.getEntityClass()); |
| 110 | 115 | } |
| 111 | 116 | |
| 117 | + /** | |
| 118 | + * 修改符合条件的所有数据 | |
| 119 | + * @param query | |
| 120 | + * @param obj | |
| 121 | + */ | |
| 122 | + public void updateMulti(Query query,T obj){ | |
| 123 | + Assert.notNull(obj, "execute findAndModify method must not null."); | |
| 124 | + Update update = MongoConvertHelper | |
| 125 | + .convertToNativeUpdate(ReflectionUtils.getUpdateField(obj)); | |
| 126 | + Assert.notNull(update, "execute findAndModify method must not null.update:" + update); | |
| 127 | + mongoTemplate.updateMulti(query,update,this.getEntityClass()); | |
| 128 | + } | |
| 112 | 129 | /** |
| 113 | 130 | * 获取需要操作的实体类class |
| 114 | 131 | * |