|
|
@@ -183,17 +183,18 @@ public class NewsController {
|
|
|
@PutMapping("/read")
|
|
|
@ApiOperation(value = "读新闻")
|
|
|
public R read(@RequestBody List<Long> ids) {
|
|
|
- List<NewsRelation> toSaveList = new ArrayList<>();
|
|
|
- for (Long id : ids) {
|
|
|
- NewsRelation newsRelation = new NewsRelation();
|
|
|
- newsRelation.setUserId(StpUtil.getLoginIdAsLong());
|
|
|
- newsRelation.setNewsId(id);
|
|
|
- toSaveList.add(newsRelation);
|
|
|
+ List<NewsRelation> toSaveList = newsRelationService.list(
|
|
|
+ Wrappers.<NewsRelation>query().lambda()
|
|
|
+ .in(NewsRelation::getNewsId, ids)
|
|
|
+ .eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong()));
|
|
|
+ for (NewsRelation newsRelation : toSaveList) {
|
|
|
+ newsRelation.setReadMark(1);
|
|
|
+ newsRelation.setReadDate(LocalDateTime.now());
|
|
|
}
|
|
|
- newsRelationService.remove(Wrappers.<NewsRelation>query().lambda()
|
|
|
- .in(NewsRelation::getNewsId, ids)
|
|
|
- .eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong()));
|
|
|
- return R.ok(newsRelationService.saveBatch(toSaveList));
|
|
|
+// newsRelationService.remove(Wrappers.<NewsRelation>query().lambda()
|
|
|
+// .in(NewsRelation::getNewsId, ids)
|
|
|
+// .eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong()));
|
|
|
+ return R.ok(newsRelationService.updateBatchById(toSaveList));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/reply")
|