代码提交--标签相关
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
package com.yaoyuan.jiscuss.common;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.custom.PostCustom;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -7,6 +8,7 @@ import javax.persistence.Column;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yaoyuan2.chu
|
||||
* @Title:
|
||||
@@ -77,7 +79,7 @@ public class Node {
|
||||
*/
|
||||
public static boolean addNode(List<Node> list, Node node) {
|
||||
for (Node node1 : list) { //循环添加
|
||||
if (node1.getId() .equals(node.getParentId()) ) { //判断留言的上一段是都是这条留言
|
||||
if (node1.getId().equals(node.getParentId())) { //判断留言的上一段是都是这条留言
|
||||
node1.getNextNodes().add(node); //是,添加,返回true;
|
||||
System.out.println("添加了一个");
|
||||
return true;
|
||||
|
||||
@@ -30,22 +30,34 @@ public class PostCommonUtil {
|
||||
}
|
||||
String content = "";
|
||||
if (mapObj.get("content") != null) {
|
||||
Clob clob = (Clob) mapObj.get("content");
|
||||
content = PostCommonUtil.clobToString(clob);
|
||||
if (mapObj.get("content") instanceof Clob) {
|
||||
Clob clob = (Clob) mapObj.get("content");
|
||||
content = PostCommonUtil.clobToString(clob);
|
||||
} else if (mapObj.get("content") instanceof String) {
|
||||
content = String.valueOf(mapObj.get("content"));
|
||||
}
|
||||
}
|
||||
postCustom.setContent(content);
|
||||
String avatar = "";
|
||||
if (mapObj.get("create_avatar") != null) {
|
||||
Clob clob = (Clob) mapObj.get("create_avatar");
|
||||
avatar = PostCommonUtil.clobToString(clob);
|
||||
if (mapObj.get("create_avatar") instanceof Clob) {
|
||||
Clob clob = (Clob) mapObj.get("create_avatar");
|
||||
avatar = PostCommonUtil.clobToString(clob);
|
||||
} else if (mapObj.get("create_avatar") instanceof String) {
|
||||
avatar = String.valueOf(mapObj.get("create_avatar"));
|
||||
}
|
||||
}
|
||||
postCustom.setAvatar(avatar);
|
||||
postCustom.setUsername(mapObj.get("create_username") != null ? String.valueOf(mapObj.get("create_username")) : null);
|
||||
postCustom.setRealname(mapObj.get("create_realname") != null ? String.valueOf(mapObj.get("create_realname")) : null);
|
||||
String avatarReply = "";
|
||||
if (mapObj.get("user_avatar") != null) {
|
||||
Clob clob = (Clob) mapObj.get("user_avatar");
|
||||
avatarReply = PostCommonUtil.clobToString(clob);
|
||||
if (mapObj.get("user_avatar") instanceof Clob) {
|
||||
Clob clob = (Clob) mapObj.get("user_avatar");
|
||||
avatarReply = PostCommonUtil.clobToString(clob);
|
||||
} else if (mapObj.get("user_avatar") instanceof String) {
|
||||
avatarReply = String.valueOf(mapObj.get("user_avatar"));
|
||||
}
|
||||
}
|
||||
postCustom.setAvatarReply(avatarReply);
|
||||
postCustom.setUsernameReply(mapObj.get("user_username") != null ? String.valueOf(mapObj.get("user_username")) : null);
|
||||
@@ -59,29 +71,29 @@ public class PostCommonUtil {
|
||||
public static List<PostCustom> getNewPostsObjCustom(List<PostCustom> postCustomList) {
|
||||
List<PostCustom> mainList = new ArrayList<>();
|
||||
Map<String, Object> postMap = new LinkedHashMap<>();
|
||||
for(PostCustom mapObj : postCustomList){
|
||||
if(null == mapObj.getParentId() ){
|
||||
for (PostCustom mapObj : postCustomList) {
|
||||
if (null == mapObj.getParentId()) {
|
||||
mainList.add(mapObj);
|
||||
}else{
|
||||
} else {
|
||||
List<PostCustom> tempList = new ArrayList<>();
|
||||
if(postMap.containsKey(String.valueOf(mapObj.getParentId()))){
|
||||
if (postMap.containsKey(String.valueOf(mapObj.getParentId()))) {
|
||||
tempList = (List<PostCustom>) postMap.get(String.valueOf(mapObj.getParentId()));
|
||||
tempList.add(mapObj);
|
||||
postMap.put(String.valueOf(mapObj.getParentId()),tempList);
|
||||
}else{
|
||||
postMap.put(String.valueOf(mapObj.getParentId()), tempList);
|
||||
} else {
|
||||
tempList.add(mapObj);
|
||||
postMap.put(String.valueOf(mapObj.getParentId()),tempList);
|
||||
postMap.put(String.valueOf(mapObj.getParentId()), tempList);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<PostCustom> mainListResult = new ArrayList<>();
|
||||
for(PostCustom mapObj : mainList){
|
||||
if(postMap.containsKey(String.valueOf(mapObj.getId()))){
|
||||
for (PostCustom mapObj : mainList) {
|
||||
if (postMap.containsKey(String.valueOf(mapObj.getId()))) {
|
||||
PostCustom newObj = new PostCustom();
|
||||
BeanUtils.copyProperties(mapObj , newObj);
|
||||
BeanUtils.copyProperties(mapObj, newObj);
|
||||
newObj.setChild((List<PostCustom>) postMap.get(String.valueOf(mapObj.getId())));
|
||||
mainListResult.add(newObj);
|
||||
}else{
|
||||
} else {
|
||||
mainListResult.add(mapObj);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user