diff --git a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java index ed58299..e94ba40 100644 --- a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java +++ b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java @@ -183,6 +183,11 @@ public class CommentServiceImpl implements CommentService { { String child = commentDao.queryChildId(commentId); + if(child == null) + { + commentDao.deleteByPrimaryKey(commentId); + return "处理完成"; + } String [] childrens = child.split(","); int flag = 0; for(String id : childrens) diff --git a/src/main/resources/mybatis/CommentDao.xml b/src/main/resources/mybatis/CommentDao.xml index 427894a..fdc80df 100644 --- a/src/main/resources/mybatis/CommentDao.xml +++ b/src/main/resources/mybatis/CommentDao.xml @@ -64,7 +64,7 @@ FROM ln_comment AS t ORDER BY t.id ASC) t1, (SELECT @pids := #{commentId,jdbcType=INTEGER}) t2) t3 - WHERE ischild != '0' and id = #{commentId,jdbcType=INTEGER} + WHERE ischild != '0' order by id desc limit 1