删除comment
This commit is contained in:
parent
1508c6d184
commit
c9f20864da
@ -43,4 +43,6 @@ public interface CommentDao {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
List<CommentNode> querySecondCommentList(Integer UrlId);
|
List<CommentNode> querySecondCommentList(Integer UrlId);
|
||||||
|
|
||||||
|
public String queryChildId(String commentId);
|
||||||
}
|
}
|
@ -26,4 +26,6 @@ public interface CommentService {
|
|||||||
List<CommentNode> queryCommentByUrlId (Integer UrlId );
|
List<CommentNode> queryCommentByUrlId (Integer UrlId );
|
||||||
|
|
||||||
CommentUser queryCommentUserById(Integer id);
|
CommentUser queryCommentUserById(Integer id);
|
||||||
|
|
||||||
|
public String SelectChildAndDelete(String commentId);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.lovenav.entity.CommentUser;
|
|||||||
import com.lovenav.entity.User;
|
import com.lovenav.entity.User;
|
||||||
import com.lovenav.service.CommentService;
|
import com.lovenav.service.CommentService;
|
||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
|
import org.checkerframework.checker.units.qual.C;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -169,5 +170,21 @@ public class CommentServiceImpl implements CommentService {
|
|||||||
}
|
}
|
||||||
return firstList;
|
return firstList;
|
||||||
}
|
}
|
||||||
|
public String SelectChildAndDelete(String commentId)
|
||||||
|
{
|
||||||
|
|
||||||
|
String child = commentDao.queryChildId(commentId);
|
||||||
|
String [] childrens = child.split(",");
|
||||||
|
int flag = 0;
|
||||||
|
for(String id : childrens)
|
||||||
|
{
|
||||||
|
flag = commentDao.deleteByPrimaryKey(Integer.valueOf(id));
|
||||||
|
if (String.valueOf(flag).equals("0")){
|
||||||
|
return "出现错误";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "处理完成";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,19 @@
|
|||||||
delete from ln_comment
|
delete from ln_comment
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="queryChildId" parameterType="java.lang.String" resultType="java.lang.String">
|
||||||
|
SELECT t3.ischild
|
||||||
|
FROM(SELECT t1.*,
|
||||||
|
IF (FIND_IN_SET(root_comment_id, @pids) > 0,@pids := CONCAT(@pids, ',', id),'0') AS ischild
|
||||||
|
FROM(SELECT t.id,t.root_comment_id
|
||||||
|
FROM ln_comment AS t
|
||||||
|
ORDER BY t.id ASC) t1,
|
||||||
|
(SELECT @pids := #{commentId,jdbcType=INTEGER}) t2) t3
|
||||||
|
WHERE ischild != '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.Comment" useGeneratedKeys="true">
|
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.Comment" useGeneratedKeys="true">
|
||||||
insert into ln_comment (url_id, user_id, content,
|
insert into ln_comment (url_id, user_id, content,
|
||||||
root_comment_id, like_count, comment_time,
|
root_comment_id, like_count, comment_time,
|
||||||
|
Loading…
Reference in New Issue
Block a user