Commit d3cd8262 authored by 罗林杰's avatar 罗林杰

修改评论审核

parent 0db01793
...@@ -146,7 +146,7 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> { ...@@ -146,7 +146,7 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> {
*/ */
@PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:delete')") @PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:delete')")
@DeleteMapping("/deleteComment/{businessId:\\w+}") @DeleteMapping("/deleteComment/{businessId:\\w+}")
public CyResult deleteComment(@PathVariable String businessId,ArticleCommentDTO dto) { public CyResult deleteComment(@PathVariable String businessId,@RequestBody ArticleCommentDTO dto) {
dto.setBusinessId(Integer.valueOf(businessId)); dto.setBusinessId(Integer.valueOf(businessId));
CyPersistModel data = opmArticleServiceImpl.removeComment(dto,"web"); CyPersistModel data = opmArticleServiceImpl.removeComment(dto,"web");
return CyResultGenUtil.builder(data, return CyResultGenUtil.builder(data,
......
...@@ -46,6 +46,9 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> { ...@@ -46,6 +46,9 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
//app查询评论 //app查询评论
List<ArticleCommentVO> appSelectArticleComment(@Param("articleId") Integer articleId, @Param("loginUserId") String loginUserId); List<ArticleCommentVO> appSelectArticleComment(@Param("articleId") Integer articleId, @Param("loginUserId") String loginUserId);
//查询评论下的子评论
List<ArticleCommentVO> appSelectArticleChildrenComment(@Param("articleId") Integer articleId, @Param("parentId") Integer parentId, @Param("loginUserId") String loginUserId);
//查询评论下的子评论 //查询评论下的子评论
List<ArticleCommentVO> selectArticleChildrenComment(@Param("articleId") Integer articleId, @Param("parentId") Integer parentId, @Param("loginUserId") String loginUserId); List<ArticleCommentVO> selectArticleChildrenComment(@Param("articleId") Integer articleId, @Param("parentId") Integer parentId, @Param("loginUserId") String loginUserId);
......
...@@ -322,7 +322,7 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -322,7 +322,7 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
List<ArticleCommentVO> list = baseMapper.appSelectArticleComment(opmArticle.getBusinessId(),loginUserId); List<ArticleCommentVO> list = baseMapper.appSelectArticleComment(opmArticle.getBusinessId(),loginUserId);
list.forEach(item -> { list.forEach(item -> {
//查询该条评论下的子评论 //查询该条评论下的子评论
List<ArticleCommentVO> childrenCommentList = baseMapper.selectArticleChildrenComment(opmArticle.getBusinessId(),item.getBusinessId(),loginUserId); List<ArticleCommentVO> childrenCommentList = baseMapper.appSelectArticleChildrenComment(opmArticle.getBusinessId(),item.getBusinessId(),loginUserId);
item.setChildrenCommentList(childrenCommentList); item.setChildrenCommentList(childrenCommentList);
}); });
opmArticle.setArticleCommentVOList(list); opmArticle.setArticleCommentVOList(list);
...@@ -527,8 +527,31 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -527,8 +527,31 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
return new CyPersistModel(1); return new CyPersistModel(1);
} else { } else {
//web端 //web端
dto.setDelFlag("1"); ArticleCommentVO comment = baseMapper.selectCommentById(dto.getBusinessId());
//删除评论
int line = baseMapper.deleteComment(dto); int line = baseMapper.deleteComment(dto);
int childrenCommentCount = 0;
OpmArticle article = new OpmArticle();
article.setBusinessId(dto.getArticleId());
if (dto.getParentId() != null){
if (comment.getExamStatus().equals("1")){
//删除的子评论 需要减掉父评论的数量
baseMapper.reduceCommentCount(dto.getParentId());
article.setCommentCount(1);
}
} else {
if (comment.getExamStatus().equals("1")){
//删除的是父评论 要查父评论下的子评论数量
ArticleCommentVO vo = new ArticleCommentVO();
vo.setParentId(dto.getBusinessId());
Integer count = baseMapper.selectArticleChildrenCommentCount(vo);
childrenCommentCount = count;
article.setCommentCount(childrenCommentCount + 1);
}
}
if (comment.getExamStatus().equals("1")){
baseMapper.updateArticleCommentCountById(article);
}
return new CyPersistModel(1); return new CyPersistModel(1);
} }
} }
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<update id="updateCommentById"> <update id="updateCommentById">
UPDATE opm_article_comment UPDATE opm_article_comment
SET comment_count = #{entity.commentCount} SET comment_count = #{entity.commentCount}
WHERE business_id = #{entity.businessId}; WHERE business_id = #{entity.parentId};
</update> </update>
<update id="updateArticleCommentCountById"> <update id="updateArticleCommentCountById">
UPDATE opm_article UPDATE opm_article
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
WHERE 1=1 WHERE 1=1
and opa.del_flag = '0' and opa.del_flag = '0'
and opa.flag = '1' and opa.flag = '1'
and opa.exam_status = '1' and opa.exam_status in ('1', '4')
and opa.is_article = '1' and opa.is_article = '1'
and opa.create_by not in ( and opa.create_by not in (
select obl.target_id select obl.target_id
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
WHERE 1=1 WHERE 1=1
and opa.del_flag = '0' and opa.del_flag = '0'
and opa.flag = '1' and opa.flag = '1'
and opa.exam_status = '1' and opa.exam_status in ('1', '4')
and opa.create_by not in ( and opa.create_by not in (
select obl.target_id select obl.target_id
from opm_black_list obl from opm_black_list obl
...@@ -401,7 +401,7 @@ ...@@ -401,7 +401,7 @@
WHERE 1=1 WHERE 1=1
and opa.del_flag = '0' and opa.del_flag = '0'
and opa.flag = '1' and opa.flag = '1'
and opa.exam_status = '1' and opa.exam_status in ('1', '4')
and opa.is_article = '0' and opa.is_article = '0'
and opa.create_by not in ( and opa.create_by not in (
select obl.target_id select obl.target_id
...@@ -665,7 +665,7 @@ ...@@ -665,7 +665,7 @@
AND opc.create_by = #{loginUserId} AND opc.create_by = #{loginUserId}
) )
</select> </select>
<select id="selectArticleChildrenComment" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentVO"> <select id="appSelectArticleChildrenComment" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentVO">
SELECT SELECT
opc.business_id, opc.business_id,
opc.content, opc.content,
...@@ -727,6 +727,38 @@ ...@@ -727,6 +727,38 @@
and opc.create_by = #{loginUserId} and opc.create_by = #{loginUserId}
) )
</select> </select>
<select id="selectArticleChildrenComment" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentVO">
SELECT
opc.business_id,
opc.content,
opc.parent_id,
opc.create_date,
opc.like_count,
opc.comment_count,
opc.create_by AS userId,
opc.user_id AS commentedUserId,
mi.mem_code as memCode,
mi.mem_nick_name as memNickName,
mi2.mem_code as commentedMemCode,
mi2.mem_nick_name as commentedMemNickName,
mi.avatar as avatarId,
CASE
WHEN oal.business_id IS NOT NULL THEN 1 ELSE 0
END AS isLike
FROM opm_article_comment opc
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
LEFT JOIN mem_info mi2 ON mi2.user_id = opc.user_id
LEFT JOIN opm_article_like oal on oal.comment_id = opc.business_id and oal.user_id = #{loginUserId}
WHERE 1 = 1
AND opc.del_flag = '0'
AND opc.article_id = #{articleId}
and opc.parent_id = #{parentId}
AND NOT EXISTS (
SELECT 1 FROM opm_black_list obl
WHERE (obl.user_id = #{loginUserId} AND obl.target_id = opc.user_id)
OR (obl.user_id = opc.user_id AND obl.target_id = #{loginUserId})
)
</select>
<select id="findCommentById" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentDTO"> <select id="findCommentById" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentDTO">
select * select *
from opm_article_comment from opm_article_comment
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment