|
@@ -161,7 +161,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
|
|
|
//如果状态是2,表示立即发布的公告,需要将阅读人添加进阅读关系表
|
|
|
if(addProclamationDto.getStatus() == 2){
|
|
|
- addRelation(news);
|
|
|
+ addRelation(news, addProclamationDto, 2);
|
|
|
}
|
|
|
|
|
|
//公告需要添加阅读关系,关系类型 1=部门 2=人员 3=班级
|
|
@@ -251,7 +251,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
.eq(News::getTypeId, 2)
|
|
|
.like(dto.getFullHead() != null, News::getFullHead, dto.getFullHead())
|
|
|
.like(dto.getKeyword() != null, News::getNewsContent, dto.getKeyword())
|
|
|
- .orderByDesc(News::getReleaseTime)
|
|
|
+ .orderByDesc(News::getId)
|
|
|
.disableSubLogicDel();
|
|
|
IPage<ProclamationPageVo> page = this.selectJoinListPage(ConventPage.getPage(dto), ProclamationPageVo.class, queryNews);
|
|
|
return page;
|
|
@@ -272,7 +272,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
.eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong())
|
|
|
.or()
|
|
|
.eq(News::getSendRange, 2)
|
|
|
- .orderByDesc(News::getReleaseTime)
|
|
|
+ .orderByDesc(News::getId)
|
|
|
.disableSubLogicDel();
|
|
|
;
|
|
|
IPage<ProclamationPageVo> page = this.selectJoinListPage(ConventPage.getPage(dto), ProclamationPageVo.class, queryNews);
|
|
@@ -304,7 +304,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
xjrNews.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
xjrNews.setModifyDate(LocalDateTime.now());
|
|
|
|
|
|
- addRelation(xjrNews);
|
|
|
+ addRelation(xjrNews, null, 1);
|
|
|
}
|
|
|
|
|
|
if (xjrNews.getStatus() == 3) {
|
|
@@ -399,40 +399,56 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
* @param xjrNews
|
|
|
* @return
|
|
|
*/
|
|
|
- private Boolean addRelation(News xjrNews){
|
|
|
+ private Boolean addRelation(News xjrNews ,AddProclamationDto addProclamationDto, int flag){
|
|
|
if (xjrNews.getSendRange() == 3) {
|
|
|
- //查出当前公告的关系配置
|
|
|
- //部门
|
|
|
- LambdaQueryWrapper<NewsRelationConfig> queryDeptList = new LambdaQueryWrapper<>();
|
|
|
- queryDeptList
|
|
|
- .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
|
|
|
- .eq(NewsRelationConfig::getRelationType, 1);
|
|
|
- List<NewsRelationConfig> deptList = newsRelationConfigMapper.selectList(queryDeptList);
|
|
|
List<Long> deptIdList = new ArrayList<>();
|
|
|
- for (NewsRelationConfig newsRelationConfig : deptList) {
|
|
|
- deptIdList.add(newsRelationConfig.getRelationId());
|
|
|
- }
|
|
|
-
|
|
|
- //人员
|
|
|
- LambdaQueryWrapper<NewsRelationConfig> queryPersonalList = new LambdaQueryWrapper<>();
|
|
|
- queryPersonalList
|
|
|
- .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
|
|
|
- .eq(NewsRelationConfig::getRelationType, 2);
|
|
|
- List<NewsRelationConfig> personalList = newsRelationConfigMapper.selectList(queryPersonalList);
|
|
|
List<Long> personalIdList = new ArrayList<>();
|
|
|
- for (NewsRelationConfig newsRelationConfig : personalList) {
|
|
|
- personalIdList.add(newsRelationConfig.getRelationId());
|
|
|
+ List<Long> classIdList = new ArrayList<>();
|
|
|
+ if(flag == 1) {
|
|
|
+ //查出当前公告的关系配置
|
|
|
+ //部门
|
|
|
+ LambdaQueryWrapper<NewsRelationConfig> queryDeptList = new LambdaQueryWrapper<>();
|
|
|
+ queryDeptList
|
|
|
+ .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
|
|
|
+ .eq(NewsRelationConfig::getRelationType, 1);
|
|
|
+ List<NewsRelationConfig> deptList = newsRelationConfigMapper.selectList(queryDeptList);
|
|
|
+ for (NewsRelationConfig newsRelationConfig : deptList) {
|
|
|
+ deptIdList.add(newsRelationConfig.getRelationId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //人员
|
|
|
+ LambdaQueryWrapper<NewsRelationConfig> queryPersonalList = new LambdaQueryWrapper<>();
|
|
|
+ queryPersonalList
|
|
|
+ .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
|
|
|
+ .eq(NewsRelationConfig::getRelationType, 2);
|
|
|
+ List<NewsRelationConfig> personalList = newsRelationConfigMapper.selectList(queryPersonalList);
|
|
|
+ for (NewsRelationConfig newsRelationConfig : personalList) {
|
|
|
+ personalIdList.add(newsRelationConfig.getRelationId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //班级
|
|
|
+ LambdaQueryWrapper<NewsRelationConfig> queryClassList = new LambdaQueryWrapper<>();
|
|
|
+ queryClassList
|
|
|
+ .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
|
|
|
+ .eq(NewsRelationConfig::getRelationType, 3);
|
|
|
+ List<NewsRelationConfig> classList = newsRelationConfigMapper.selectList(queryClassList);
|
|
|
+ for (NewsRelationConfig newsRelationConfig : classList) {
|
|
|
+ classIdList.add(newsRelationConfig.getRelationId());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //班级
|
|
|
- LambdaQueryWrapper<NewsRelationConfig> queryClassList = new LambdaQueryWrapper<>();
|
|
|
- queryClassList
|
|
|
- .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
|
|
|
- .eq(NewsRelationConfig::getRelationType, 3);
|
|
|
- List<NewsRelationConfig> classList = newsRelationConfigMapper.selectList(queryClassList);
|
|
|
- List<Long> classIdList = new ArrayList<>();
|
|
|
- for (NewsRelationConfig newsRelationConfig : classList) {
|
|
|
- classIdList.add(newsRelationConfig.getRelationId());
|
|
|
+ if(flag == 2){
|
|
|
+ for (AddNewsRelationDto addNewsRelationDto : addProclamationDto.getRelationList()) {
|
|
|
+ if(addNewsRelationDto.getRelationType() == 1){
|
|
|
+ deptIdList.add(addNewsRelationDto.getRelationId());
|
|
|
+ }
|
|
|
+ if(addNewsRelationDto.getRelationType() == 2){
|
|
|
+ personalIdList.add(addNewsRelationDto.getRelationId());
|
|
|
+ }
|
|
|
+ if(addNewsRelationDto.getRelationType() == 3){
|
|
|
+ classIdList.add(addNewsRelationDto.getRelationId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//对人员进行筛选,避免重复添加
|
|
@@ -452,7 +468,6 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//添加部门人员
|
|
|
if (deptIdList != null) {
|
|
|
newsRelationMapper.insertDeptUser(xjrNews.getId(), deptIdList);
|
|
@@ -467,6 +482,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
if (userIdList != null) {
|
|
|
newsRelationMapper.insertPersonl(xjrNews.getId(), userIdList);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//遍历所有关系配置
|