Commit c8191dd4e0e8bcc4ccf5de7d20e9b80e2300846b
1 parent
f8f949c3ff
Exists in
dev
#fix:优化通知公告阅读量逻辑
Showing 3 changed files with 23 additions and 2 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseEvalService.java
View file @
c8191dd
| ... | ... | @@ -8,6 +8,8 @@ |
| 8 | 8 | import com.lyms.platform.common.dao.operator.MongoOper; |
| 9 | 9 | import com.lyms.platform.common.dao.operator.MongoQuery; |
| 10 | 10 | import com.lyms.platform.common.enums.YnEnums; |
| 11 | +import com.lyms.platform.common.utils.MongoConvertHelper; | |
| 12 | +import com.lyms.platform.common.utils.ReflectionUtils; | |
| 11 | 13 | import com.lyms.platform.pojo.CourseEvaluateModel; |
| 12 | 14 | import com.lyms.platform.pojo.MsgModel; |
| 13 | 15 | import com.lyms.platform.pojo.MsgModelRecord; |
| ... | ... | @@ -92,7 +94,7 @@ |
| 92 | 94 | msgQuery.mysqlBuild((int)mongoTemplate.count(query.convertToMongoQuery(),MsgModelRecord.class)); |
| 93 | 95 | query.start(msgQuery.getOffset()).end(msgQuery.getLimit()); |
| 94 | 96 | } |
| 95 | - System.out.println(query.convertToMongoQuery()); | |
| 97 | + query.addOrder(Sort.Direction.DESC, "created"); | |
| 96 | 98 | return mongoTemplate.find(query.convertToMongoQuery(),MsgModelRecord.class); |
| 97 | 99 | } |
| 98 | 100 | |
| ... | ... | @@ -100,6 +102,12 @@ |
| 100 | 102 | public void addMsg(MsgModel model) { |
| 101 | 103 | msgDao.addMsg(model); |
| 102 | 104 | } |
| 105 | + | |
| 106 | + public void updateRecordMsg(MsgModelRecord model) { | |
| 107 | + mongoTemplate.upsert(new MongoQuery(new MongoCondition("id", model.getId(), MongoOper.IS)).convertToMongoQuery(),MongoConvertHelper | |
| 108 | + .convertToNativeUpdate(ReflectionUtils.getUpdateField(model)),MsgModelRecord.class); | |
| 109 | + } | |
| 110 | + | |
| 103 | 111 | |
| 104 | 112 | public void updateMsg(MsgModel model) { |
| 105 | 113 | msgDao.updateMsg(new MongoQuery(new MongoCondition("id", model.getId(), MongoOper.IS)), model); |
platform-dal/src/main/java/com/lyms/platform/pojo/MsgModelRecord.java
View file @
c8191dd
| ... | ... | @@ -27,7 +27,8 @@ |
| 27 | 27 | private Integer state; |
| 28 | 28 | //标题0.医生停诊通知 1.检查停诊通知 2.医院放假通知 3.排课表 |
| 29 | 29 | private Integer title; |
| 30 | - | |
| 30 | + //阅读量 | |
| 31 | + private Integer readNum; | |
| 31 | 32 | private String hospitalId; |
| 32 | 33 | |
| 33 | 34 | private String img; |
| ... | ... | @@ -159,6 +160,14 @@ |
| 159 | 160 | |
| 160 | 161 | public void setTitle(Integer title) { |
| 161 | 162 | this.title = title; |
| 163 | + } | |
| 164 | + | |
| 165 | + public Integer getReadNum() { | |
| 166 | + return readNum; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public void setReadNum(Integer readNum) { | |
| 170 | + this.readNum = readNum; | |
| 162 | 171 | } |
| 163 | 172 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
View file @
c8191dd
| ... | ... | @@ -1177,6 +1177,7 @@ |
| 1177 | 1177 | final MsgModel model= msgModels.get(0); |
| 1178 | 1178 | model.setModified(format); |
| 1179 | 1179 | model.setStatus(1); |
| 1180 | + model.setReadNum(0); | |
| 1180 | 1181 | //操作人为当前用户id |
| 1181 | 1182 | model.setPublishId(userId); |
| 1182 | 1183 | courseEvalService.updateMsg(model); |
| ... | ... | @@ -1340,6 +1341,7 @@ |
| 1340 | 1341 | msgModelRecord.setTitle(msgModel.getTitle()); |
| 1341 | 1342 | msgModelRecord.setType(msgModel.getType()); |
| 1342 | 1343 | msgModelRecord.setYn(1); |
| 1344 | + msgModelRecord.setReadNum(0); | |
| 1343 | 1345 | return msgModelRecord; |
| 1344 | 1346 | } |
| 1345 | 1347 | |
| ... | ... | @@ -1457,6 +1459,8 @@ |
| 1457 | 1459 | MsgModel msgModel= msgModels.get(0); |
| 1458 | 1460 | msgModel.setReadNum(msgModel.getReadNum()!=null?msgModel.getReadNum()+1:1); |
| 1459 | 1461 | courseEvalService.updateMsg(msgModel); |
| 1462 | + msgModelRecord.setReadNum(msgModel.getReadNum()); | |
| 1463 | + courseEvalService.updateRecordMsg(msgModelRecord); | |
| 1460 | 1464 | } |
| 1461 | 1465 | objectResponse.setObject(msgModelRecord); |
| 1462 | 1466 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |