Commit 91d84a499c83a4b5175263e4dc75c55a1233a1c0
1 parent
91cfba263c
Exists in
master
and in
6 other branches
update
Showing 1 changed file with 14 additions and 0 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PostkfFaccade.java
View file @
91d84a4
| ... | ... | @@ -3,13 +3,18 @@ |
| 3 | 3 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 4 | 4 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 5 | 5 | import com.lyms.platform.common.result.BaseResponse; |
| 6 | +import com.lyms.platform.common.utils.MongoConvertHelper; | |
| 7 | +import com.lyms.platform.common.utils.ReflectionUtils; | |
| 8 | +import com.lyms.platform.common.utils.StringUtils; | |
| 6 | 9 | import com.lyms.platform.pojo.PatientWeight; |
| 7 | 10 | import com.lyms.platform.pojo.PostkfModel; |
| 11 | +import com.lyms.platform.pojo.PreEugenicsBaseModel; | |
| 8 | 12 | import org.apache.commons.collections.CollectionUtils; |
| 9 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 14 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 11 | 15 | import org.springframework.data.mongodb.core.query.Criteria; |
| 12 | 16 | import org.springframework.data.mongodb.core.query.Query; |
| 17 | +import org.springframework.data.mongodb.core.query.Update; | |
| 13 | 18 | import org.springframework.stereotype.Component; |
| 14 | 19 | |
| 15 | 20 | import java.util.Date; |
| ... | ... | @@ -25,6 +30,15 @@ |
| 25 | 30 | private MongoTemplate mongoTemplate; |
| 26 | 31 | |
| 27 | 32 | public BaseResponse addPostKf(PostkfModel postkfModel, Integer userId) { |
| 33 | + if (StringUtils.isNotEmpty(postkfModel.getId())) | |
| 34 | + { | |
| 35 | + postkfModel.setModified(new Date()); | |
| 36 | + Query query = Query.query(Criteria.where("_id").is(postkfModel.getId())); | |
| 37 | + Update update = MongoConvertHelper | |
| 38 | + .convertToNativeUpdate(ReflectionUtils.getUpdateField(postkfModel)); | |
| 39 | + mongoTemplate.updateFirst(query, update, PostkfModel.class); | |
| 40 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 41 | + } | |
| 28 | 42 | postkfModel.setOperaterId(String.valueOf(userId)); |
| 29 | 43 | postkfModel.setCreated(new Date()); |
| 30 | 44 | postkfModel.setModified(new Date()); |