Commit b7c0a691 authored by liwei's avatar liwei

修改了动态评论接口

parent cc6c0e71
...@@ -112,7 +112,7 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle> ...@@ -112,7 +112,7 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle>
return CyResultGenUtil.builder(new CyPersistModel(1), return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS, CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR, CyMessCons.MESSAGE_ALERT_ERROR,
opmArticleServiceImpl.findById(businessId)); opmArticleServiceImpl.findById(businessId,"app"));
} }
/** /**
......
...@@ -103,7 +103,7 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> { ...@@ -103,7 +103,7 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> {
return CyResultGenUtil.builder(new CyPersistModel(1), return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS, CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR, CyMessCons.MESSAGE_ALERT_ERROR,
opmArticleServiceImpl.findById(businessId)); opmArticleServiceImpl.findById(businessId, "web"));
} }
@PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:query')") @PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:query')")
......
...@@ -37,9 +37,12 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> { ...@@ -37,9 +37,12 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
OpmArticle selectArticleDetail(@Param("articleId") Integer articleId, @Param("loginUserId") String loginUserId); OpmArticle selectArticleDetail(@Param("articleId") Integer articleId, @Param("loginUserId") String loginUserId);
//查询评论 //web查询评论
List<ArticleCommentVO> selectArticleComment(@Param("articleId") Integer articleId, @Param("loginUserId") String loginUserId); List<ArticleCommentVO> selectArticleComment(@Param("articleId") Integer articleId, @Param("loginUserId") String loginUserId);
//app查询评论
List<ArticleCommentVO> appSelectArticleComment(@Param("articleId") Integer articleId, @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);
...@@ -75,5 +78,8 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> { ...@@ -75,5 +78,8 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
//查询某个人的动态列表 //查询某个人的动态列表
IPage<OpmArticle> queryUserArticlePaged(CyPageInfo cyPageInfo, @Param("entity") OpmArticle opmArticle); IPage<OpmArticle> queryUserArticlePaged(CyPageInfo cyPageInfo, @Param("entity") OpmArticle opmArticle);
//根据id查询评论信息
ArticleCommentDTO findCommentById(Integer businessId);
} }
...@@ -28,4 +28,6 @@ public class ArticleCommentDTO { ...@@ -28,4 +28,6 @@ public class ArticleCommentDTO {
private String examStatus; private String examStatus;
//备注 //备注
private String remarks; private String remarks;
//评论id
private Integer commentId;
} }
...@@ -48,7 +48,7 @@ public interface OpmArticleService { ...@@ -48,7 +48,7 @@ public interface OpmArticleService {
* @param id * @param id
* @return * @return
*/ */
OpmArticle findById(Integer id); OpmArticle findById(Integer id,String type);
/** /**
* 分页查询 opmArticle管理 * 分页查询 opmArticle管理
......
...@@ -247,19 +247,34 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -247,19 +247,34 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
* @return * @return
*/ */
@Override @Override
public OpmArticle findById(Integer articleId){ public OpmArticle findById(Integer articleId,String type){
String loginUserId = CyUserUtil.getAuthenBusinessId(); if (type.equals("app")){
//根据动态id 查询动态详情 String loginUserId = CyUserUtil.getAuthenBusinessId();
OpmArticle opmArticle = baseMapper.selectArticleDetail(articleId,loginUserId); //根据动态id 查询动态详情
//查询该动态的评论 OpmArticle opmArticle = baseMapper.selectArticleDetail(articleId,loginUserId);
List<ArticleCommentVO> list = baseMapper.selectArticleComment(opmArticle.getBusinessId(),loginUserId); //查询该动态的评论
list.forEach(item -> { List<ArticleCommentVO> list = baseMapper.appSelectArticleComment(opmArticle.getBusinessId(),loginUserId);
//查询该条评论下的子评论 list.forEach(item -> {
List<ArticleCommentVO> childrenCommentList = baseMapper.selectArticleChildrenComment(opmArticle.getBusinessId(),item.getBusinessId(),loginUserId); //查询该条评论下的子评论
item.setChildrenCommentList(childrenCommentList); List<ArticleCommentVO> childrenCommentList = baseMapper.selectArticleChildrenComment(opmArticle.getBusinessId(),item.getBusinessId(),loginUserId);
}); item.setChildrenCommentList(childrenCommentList);
opmArticle.setArticleCommentVOList(list); });
return opmArticle; opmArticle.setArticleCommentVOList(list);
return opmArticle;
} else {
String loginUserId = CyUserUtil.getAuthenBusinessId();
//根据动态id 查询动态详情
OpmArticle opmArticle = baseMapper.selectArticleDetail(articleId,loginUserId);
//查询该动态的评论
List<ArticleCommentVO> list = baseMapper.selectArticleComment(opmArticle.getBusinessId(),loginUserId);
list.forEach(item -> {
//查询该条评论下的子评论
List<ArticleCommentVO> childrenCommentList = baseMapper.selectArticleChildrenComment(opmArticle.getBusinessId(),item.getBusinessId(),loginUserId);
item.setChildrenCommentList(childrenCommentList);
});
opmArticle.setArticleCommentVOList(list);
return opmArticle;
}
} }
/** /**
...@@ -504,7 +519,18 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -504,7 +519,18 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
String nowDate = now.format(formatter); String nowDate = now.format(formatter);
//获取动态创建时间 //获取动态创建时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createDate = sdf.format(dto.getCreateDate()); //根据parentId查询需要回复的评论信息
ArticleCommentDTO comment = baseMapper.findCommentById(dto.getCommentId());
String createDate = "";//动态创建时间
Integer commentedUserId = null;//被评论人id
if (comment == null){
//发的是第一级评论
createDate = sdf.format(new Date());
commentedUserId = Integer.valueOf(userId);
} else {
createDate = String.valueOf(comment.getCreateDate());
commentedUserId = comment.getCreateBy();
}
try { try {
//计算当前时间和动态创建时间的秒数差 //计算当前时间和动态创建时间的秒数差
long timeSeconds = TimeUtil.getTimeSecond(createDate,nowDate); long timeSeconds = TimeUtil.getTimeSecond(createDate,nowDate);
...@@ -535,9 +561,11 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm ...@@ -535,9 +561,11 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
dto.setExamStatus("3"); dto.setExamStatus("3");
dto.setRemarks(msg.toString()); dto.setRemarks(msg.toString());
} }
} else {
dto.setExamStatus("0");
} }
//4、校验通过 进行插入评论数据 //4、校验通过 进行插入评论数据
dto.setCommentedUserId(Integer.valueOf(CyUserUtil.getAuthenBusinessId())); dto.setCommentedUserId(commentedUserId);
dto.setCreateDate(new Date()); dto.setCreateDate(new Date());
dto.setUpdateDate(new Date()); dto.setUpdateDate(new Date());
dto.setCreateBy(Integer.valueOf(CyUserUtil.getAuthenBusinessId())); dto.setCreateBy(Integer.valueOf(CyUserUtil.getAuthenBusinessId()));
......
...@@ -392,13 +392,41 @@ ...@@ -392,13 +392,41 @@
AND opc.del_flag = '0' AND opc.del_flag = '0'
AND opc.parent_id is null AND opc.parent_id is null
AND opc.article_id = #{articleId} AND opc.article_id = #{articleId}
and opc.exam_status = '1'
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM opm_black_list obl SELECT 1 FROM opm_black_list obl
WHERE (obl.user_id = #{loginUserId} AND obl.target_id = opc.user_id) WHERE (obl.user_id = #{loginUserId} AND obl.target_id = opc.user_id)
OR (obl.user_id = opc.user_id AND obl.target_id = #{loginUserId}) OR (obl.user_id = opc.user_id AND obl.target_id = #{loginUserId})
) )
</select> </select>
<select id="appSelectArticleComment" 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,
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 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.parent_id is null
AND opc.article_id = #{articleId}
and opc.exam_status = '1'
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="selectArticleChildrenComment" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentVO"> <select id="selectArticleChildrenComment" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentVO">
SELECT SELECT
opc.business_id, opc.business_id,
...@@ -431,6 +459,12 @@ ...@@ -431,6 +459,12 @@
OR (obl.user_id = opc.user_id AND obl.target_id = #{loginUserId}) OR (obl.user_id = opc.user_id AND obl.target_id = #{loginUserId})
) )
</select> </select>
<select id="findCommentById" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentDTO">
select *
from opm_article_comment
where 1=1
and business_id = #{businessId}
</select>
<delete id="deleteComment"> <delete id="deleteComment">
update opm_article_comment set del_flag = '1' where business_id = #{businessId} update opm_article_comment set del_flag = '1' where business_id = #{businessId}
and del_flag = '0' and del_flag = '0'
......
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