Explorar el Código

公告接口回显

phoenix hace 1 año
padre
commit
0c21fb0eb6

+ 2 - 2
src/main/java/com/xjrsoft/module/oa/dto/AddNewsRelationDto.java

@@ -12,6 +12,6 @@ public class AddNewsRelationDto {
     @ApiModelProperty("关系ID")
     private Long relationId;
 
-//    @ApiModelProperty("新闻主键")
-//    private Long newsId;
+    @ApiModelProperty("父节点主键")
+    private Long parentId;
 }

+ 34 - 11
src/main/java/com/xjrsoft/module/oa/service/impl/NewsServiceImpl.java

@@ -21,6 +21,7 @@ import com.xjrsoft.config.CommonPropertiesConfig;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseGrade;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
+import com.xjrsoft.module.base.mapper.BaseGradeMapper;
 import com.xjrsoft.module.oa.dto.*;
 import com.xjrsoft.module.oa.entity.News;
 import com.xjrsoft.module.oa.entity.NewsAppendix;
@@ -85,6 +86,8 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
 
     private final UserMapper userMapper;
 
+    private final BaseGradeMapper baseGradeMapper;
+
     private final DepartmentMapper departmentMapper;
 
     private final BaseClassMapper baseClassMapper;
@@ -182,6 +185,11 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 }
                 if (relationDto.getRelationType() == 3)  {
                     BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
+                    BaseGrade baseGrade = null;
+                    if(baseClass == null){
+                        baseGrade = baseGradeMapper.selectById(relationDto.getRelationId());
+                    }
+                    BaseGrade finalBaseGrade = baseGrade;
                     newsRelationConfigMapper.insert(new NewsRelationConfig(){{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
@@ -189,6 +197,9 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                         if(baseClass != null){
                             setRelationName(baseClass.getName());
                         }
+                        if(finalBaseGrade != null){
+                            setRelationName(finalBaseGrade.getName());
+                        }
                     }});
                 }
             }
@@ -445,27 +456,39 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
 
             for (AddNewsRelationDto relationDto : updateProclamationDto.getRelationList()) {
                 if (relationDto.getRelationType() == 1) {
+                    Department department = departmentMapper.selectById(relationDto.getRelationId());
+
                     newsRelationConfigMapper.insert(new NewsRelationConfig(){{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        setRelationName("部门");
+                        if(department != null){
+                            setRelationName(department.getName());
+                        }
                     }});
                 }
                 if (relationDto.getRelationType() == 2)  {
+                    XjrUser xjrUser = xjrUserMapper.selectById(relationDto.getRelationId());
+
                     newsRelationConfigMapper.insert(new NewsRelationConfig(){{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        setRelationName("人员");
+                        if(xjrUser != null){
+                            setRelationName(xjrUser.getName());
+                        }
                     }});
                 }
                 if (relationDto.getRelationType() == 3)  {
+                    BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
+
                     newsRelationConfigMapper.insert(new NewsRelationConfig(){{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        setRelationName("班级");
+                        if(baseClass != null){
+                            setRelationName(baseClass.getName());
+                        }
                     }});
                 }
             }
@@ -492,19 +515,19 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
 
         //公告需要添加阅读关系,发送范围 1=全校教职工 2=全校师生 3=指定人员
         //1=全校教职工,添加全校教职工到关系表
-        if(addNewsDto.getTypeId() == 2 && addNewsDto.getSendRange() == 1){
-            MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
-            queryUser
-                    .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
-                    .leftJoin(Role.class, Role::getId, UserRoleRelation::getRoleId)
-                    .eq(Role::getId, 2);
-            List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
+//        if(addNewsDto.getTypeId() == 2 && addNewsDto.getSendRange() == 1){
+//            MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
+//            queryUser
+//                    .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
+//                    .leftJoin(Role.class, Role::getId, UserRoleRelation::getRoleId)
+//                    .eq(Role::getId, 2);
+//            List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
 //            for (XjrUser user: userList) {
 //                newsRelation.setUserId(user.getId());
 //                newsRelationMapper.insert(newsRelation);
 //            }
 
-        }
+//        }
 
         if (addNewsDto.getTypeId() == 2 && addNewsDto.getSendRange() == 1) {
             for (AddNewsRelationDto relationDto : addNewsDto.getRelationList()) {