|
@@ -350,13 +350,14 @@ public class NewsController {
|
|
|
|
|
|
//新闻
|
|
|
if(typeId == 1){
|
|
|
- Long notReadCount = newsService.count(Wrappers.<News>query().lambda()
|
|
|
- .eq(News::getTypeId, typeId)
|
|
|
- .eq(News::getStatus, 2)
|
|
|
- .gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
- .eq(News::getWfStatus, 1)
|
|
|
- .notInSql(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong()));
|
|
|
-
|
|
|
+ Long notReadCount = newsService.count(
|
|
|
+ MPJWrappers.<News>lambdaJoin()
|
|
|
+ .leftJoin(NewsRelation.class, NewsRelation::getNewsId, News::getId)
|
|
|
+ .eq(News::getStatus, 2)
|
|
|
+ .gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
+ .eq(News::getTypeId, typeId)
|
|
|
+ .eq(NewsRelation::getReadMark, 0)
|
|
|
+ );
|
|
|
newsCountTypeVo.setTypeId(typeId);
|
|
|
newsCountTypeVo.setTotal(notReadCount);
|
|
|
|
|
@@ -373,32 +374,25 @@ public class NewsController {
|
|
|
//公告
|
|
|
if(typeId == 2){
|
|
|
//公告发给全体的
|
|
|
- Long notReadCountProclamationToAll = newsService.count(Wrappers.<News>query().lambda()
|
|
|
- .eq(News::getTypeId, 2)
|
|
|
- .eq(News::getStatus, 2)
|
|
|
- .eq(News::getSendRange, 1)
|
|
|
- .notInSql(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
|
|
|
- .and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
- .or()
|
|
|
- .isNull(News::getSendEndDate)));
|
|
|
+ Long notReadCountProclamation = newsService.count(
|
|
|
+ MPJWrappers.<News>lambdaJoin()
|
|
|
+ .leftJoin(NewsRelation.class, NewsRelation::getNewsId, News::getId)
|
|
|
+ .eq(News::getStatus, 2)
|
|
|
+ .gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
+ .eq(News::getTypeId, typeId)
|
|
|
+ .eq(NewsRelation::getReadMark, 0)
|
|
|
+ );
|
|
|
|
|
|
News newsAll = newsService.getOne(Wrappers.<News>query().lambda()
|
|
|
.eq(News::getTypeId, 2)
|
|
|
.eq(News::getStatus, 2)
|
|
|
.eq(News::getSendRange, 1)
|
|
|
- //.notInSql(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
|
|
|
.and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
.or()
|
|
|
.isNull(News::getSendEndDate))
|
|
|
.orderByDesc(News::getReleaseTime)
|
|
|
.last("limit 1"));
|
|
|
|
|
|
- //公告发给非全体的
|
|
|
- Long notReadCountProclamation = newsRelationService.count(Wrappers.<NewsRelation>query().lambda()
|
|
|
- .eq(NewsRelation::getReadMark, 0)
|
|
|
- .eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong())
|
|
|
- .inSql(NewsRelation::getNewsId, "select id from xjr_oa_news where delete_mark = 0 and type_id = 2 and (send_range = 2 or send_range = 3) AND (send_end_date > '" + LocalDateTime.now() + "' OR send_end_date IS NULL)"));
|
|
|
-
|
|
|
MPJLambdaWrapper<News> queryNews = new MPJLambdaWrapper<>();
|
|
|
queryNews
|
|
|
.leftJoin(NewsRelation.class, NewsRelation::getNewsId, News::getId)
|
|
@@ -432,7 +426,7 @@ public class NewsController {
|
|
|
}
|
|
|
|
|
|
newsCountTypeVo.setTypeId(typeId);
|
|
|
- newsCountTypeVo.setTotal(notReadCountProclamationToAll + notReadCountProclamation);
|
|
|
+ newsCountTypeVo.setTotal(notReadCountProclamation);
|
|
|
}
|
|
|
|
|
|
if (news != null) {
|
|
@@ -465,28 +459,12 @@ public class NewsController {
|
|
|
@GetMapping("/unread-count")
|
|
|
@ApiOperation(value = "获取登录人未读消息数量")
|
|
|
public RT<Long> unreadCount() {
|
|
|
- Long notReadCountNews = newsService.count(Wrappers.<News>query().lambda()
|
|
|
- .eq(News::getTypeId, 1)
|
|
|
- .eq(News::getStatus, 2)
|
|
|
- .gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
- .eq(News::getWfStatus, 1)
|
|
|
- .notInSql(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong()));
|
|
|
-
|
|
|
- //公告发给全体的
|
|
|
- Long notReadCountProclamationToAll = newsService.count(Wrappers.<News>query().lambda()
|
|
|
- .eq(News::getTypeId, 2)
|
|
|
- .eq(News::getStatus, 2)
|
|
|
- .eq(News::getSendRange, 1)
|
|
|
- .notInSql(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
|
|
|
- .and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
|
|
|
- .or()
|
|
|
- .isNull(News::getSendEndDate)));
|
|
|
-
|
|
|
- //公告发给非全体的
|
|
|
- Long notReadCountProclamation = newsRelationService.count(Wrappers.<NewsRelation>query().lambda()
|
|
|
- .eq(NewsRelation::getReadMark, 0)
|
|
|
- .eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong())
|
|
|
- .inSql(NewsRelation::getNewsId, "select id from xjr_oa_news where delete_mark = 0 and type_id = 2 and status = 2 and (send_range = 2 or send_range = 3) AND (send_end_date > '" + LocalDateTime.now() + "' OR send_end_date IS NULL)"));
|
|
|
+ Long notReadCountNews = newsService.count(
|
|
|
+ MPJWrappers.<News>lambdaJoin()
|
|
|
+ .leftJoin(NewsRelation.class, NewsRelation::getNewsId, News::getId)
|
|
|
+ .eq(News::getStatus, 2)
|
|
|
+ .eq(NewsRelation::getReadMark, 0)
|
|
|
+ );
|
|
|
|
|
|
//公告发给非全体的
|
|
|
long systemUpdateMessageCount = systemUpdateMessageService.count(
|
|
@@ -498,7 +476,7 @@ public class NewsController {
|
|
|
.eq(SystemUpdateMessageNotice::getStatus, 0)
|
|
|
);
|
|
|
|
|
|
- Long notReadCount = notReadCountNews + notReadCountProclamationToAll + notReadCountProclamation + systemUpdateMessageCount;
|
|
|
+ Long notReadCount = notReadCountNews + systemUpdateMessageCount;
|
|
|
return RT.ok(notReadCount);
|
|
|
}
|
|
|
|