Pārlūkot izejas kodu

公告回复查看

phoenix 1 gadu atpakaļ
vecāks
revīzija
c5a10611d4

+ 31 - 9
src/main/java/com/xjrsoft/module/oa/controller/NewsController.java

@@ -5,6 +5,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -14,14 +15,6 @@ import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.oa.dto.*;
-import com.xjrsoft.module.oa.dto.AddNewsDto;
-import com.xjrsoft.module.oa.dto.ChangeNewsDto;
-import com.xjrsoft.module.oa.dto.DeleteNewsRelationDto;
-import com.xjrsoft.module.oa.dto.NewsPageDto;
-import com.xjrsoft.module.oa.dto.NewsRelationPageDto;
-import com.xjrsoft.module.oa.dto.NewsReplyDto;
-import com.xjrsoft.module.oa.dto.UpdateNewsDto;
-import com.xjrsoft.module.oa.dto.UpdateNewsRelationDto;
 import com.xjrsoft.module.oa.entity.News;
 import com.xjrsoft.module.oa.entity.NewsAppendix;
 import com.xjrsoft.module.oa.entity.NewsRelation;
@@ -106,6 +99,35 @@ public class NewsController {
         if (news == null) {
             RT.error("找不到此新闻!");
         }
+
+        LambdaQueryWrapper<NewsRelation> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper
+                .eq(NewsRelation::getNewsId , id)
+                .select(NewsRelation.class, x -> VoToColumnUtil.fieldsToColumns(NewsRelation.class).contains(x.getProperty()));
+
+        List<NewsRelationVo> newsRelationVoList = new ArrayList<>();
+
+        if(ObjectUtil.isNotNull(news.getCreateUserId()) && StpUtil.getLoginIdAsLong() == news.getCreateUserId()){
+
+            List<NewsRelation> newsRelationList = newsRelationService.list(queryWrapper);
+
+            newsRelationList.stream().forEach(element -> {
+                // 对元素进行操作
+                NewsRelationVo newsRelationVo = BeanUtil.toBean(element, NewsRelationVo.class);
+                newsRelationVoList.add(newsRelationVo);
+            });
+
+
+        }else{
+            queryWrapper.eq(NewsRelation::getUserId , StpUtil.getLoginIdAsLong());
+            NewsRelation newsRelation = newsRelationService.getOne(queryWrapper);
+            NewsRelationVo newsRelationVo = BeanUtil.toBean(newsRelation, NewsRelationVo.class);
+            newsRelationVoList.add(newsRelationVo);
+        }
+
+        NewsVo newsVo = BeanUtil.toBean(news, NewsVo.class);
+        newsVo.setRelationList(newsRelationVoList);
+
         if (BooleanUtils.isTrue(isRead)) {
 //            NewsRelation newsRelation = new NewsRelation();
 //            newsRelation.setNewsId(id);
@@ -116,7 +138,7 @@ public class NewsController {
 //            newsRelationService.save(newsRelation);
         }
 
-        NewsVo newsVo = BeanUtil.toBean(news, NewsVo.class);
+
 
 //        List<NewsRelationVo> newsRelationVoList = newsRelationService.selectJoinList(NewsRelationVo.class,
 //                new MPJLambdaWrapper<NewsRelation>()

+ 0 - 6
src/main/java/com/xjrsoft/module/oa/vo/NewsPageVo.java

@@ -178,10 +178,4 @@ public class NewsPageVo {
      */
     @ApiModelProperty("状态 1=未发布 2=已发布 3=下架")
     private Integer status;
-
-    /**
-     * 回复条数,大于0表示有回复
-     */
-    @ApiModelProperty("回复条数,大于0表示有回复")
-    private Long replyContentNum;
 }

+ 4 - 6
src/main/resources/mapper/oa/NewsMapper.xml

@@ -7,10 +7,8 @@
             resultType="com.xjrsoft.module.oa.vo.NewsPageVo">
         select
         t.*,
-        t2.name as classIdCN,
-        (select count(*) from xjr_oa_news_relation where reply_content is not null ) as replyContentNum
+        t2.name as classIdCN
         from xjr_oa_news t
-        left join xjr_oa_news_relation t1 on t1.news_id = t.id
         left join base_class t2 on t2.id = t.class_id
         where t.delete_mark = 0
         <if test="dto.type != null and dto.type > 0">
@@ -35,13 +33,13 @@
             resultType="com.xjrsoft.module.oa.vo.NewsPageVo">
         select
         t.*,
-        t2.name as classIdCN,
-        (select count(*) from xjr_oa_news_relation where reply_content is not null ) as replyContentNum
+        t2.name as classIdCN
         from xjr_oa_news t
         left join xjr_oa_news_relation t1 on t1.news_id = t.id
         left join base_class t2 on t2.id = t.class_id
         where t.delete_mark = 0 and
         (t.send_end_date > now() or t.send_end_date is null)
+          and t.status = 2
         <if test="dto.type != null and dto.type > 0">
             and t.type_id = #{dto.type}
         </if>
@@ -55,7 +53,7 @@
             and t.keyword LIKE CONCAT('%',#{dto.keyword},'%')
         </if>
         <if test="dto.type != null and dto.type == 2 and dto.loginId != null and dto.loginId > 0">
-            and t1.user_id = #{dto.loginId}
+            and (t1.user_id = #{dto.loginId} or t.send_range = 1)
         </if>
         order by
         t.send_start_date desc