Skip to content

Commit 50cb1a0

Browse files
committed
[BT] SP-490 #close #time 1h #comment pk 객체와 fk 객체 동시에 입력 및 자동 mapping 완료.
[RV] +review SR @admin
1 parent 6e98a15 commit 50cb1a0

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

standard/project/web/src/main/java/egovframework/api/rivalWar/menu/controller/AdminMenuController.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package egovframework.api.rivalWar.menu.controller;
22

33
import com.fasterxml.jackson.core.JsonProcessingException;
4+
import egovframework.api.rivalWar.directChat.service.DirectChatService;
5+
import egovframework.api.rivalWar.directChat.vo.DirectChatDTO;
46
import egovframework.api.rivalWar.menu.service.MenuService;
57
import egovframework.api.rivalWar.menu.vo.MenuDTO;
68
import egovframework.com.ext.jstree.springiBatis.core.util.Util_TitleChecker;
79
import egovframework.com.ext.jstree.springiBatis.core.validation.group.*;
810
import egovframework.com.ext.jstree.support.mvc.GenericAbstractController;
11+
import egovframework.com.ext.jstree.support.security.database.model.Role;
12+
import egovframework.com.ext.jstree.support.util.DateUtils;
913
import org.slf4j.Logger;
1014
import org.slf4j.LoggerFactory;
1115
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +23,7 @@
1923
import org.springframework.web.servlet.ModelAndView;
2024

2125
import javax.servlet.http.HttpServletRequest;
26+
import java.util.HashSet;
2227

2328
@Controller
2429
@RequestMapping(value = {"/api/rivalWar/ROLE_ADMIN/menu"})
@@ -27,6 +32,9 @@ public class AdminMenuController extends GenericAbstractController {
2732
@Autowired
2833
private MenuService menuService;
2934

35+
@Autowired
36+
private DirectChatService directChatService;
37+
3038
private final Logger logger = LoggerFactory.getLogger(this.getClass());
3139

3240
/**
@@ -47,8 +55,38 @@ public ModelAndView addNode(@Validated(value = AddNode.class) MenuDTO jsTreeHibe
4755
if (bindingResult.hasErrors())
4856
throw new RuntimeException();
4957

58+
//신규 메뉴가 추가됬다.
59+
DirectChatDTO searchNode = new DirectChatDTO();
60+
Long rootNodeCID =new Long(2);
61+
searchNode.setC_id(rootNodeCID); // 2번 노드 밑으로 붙일 것이다.
62+
DirectChatDTO rootDirectChatDTO = directChatService.getNode(searchNode);
63+
//DirectChat의 2번 노드 밑에 첫번째 채팅을 입력한다.
64+
Long childCount = rootDirectChatDTO.getC_right() - rootDirectChatDTO.getC_left() - 1;
65+
if(childCount < 1){
66+
throw new RuntimeException("jsTree is index broken");
67+
}else{
68+
Long nodeSize = new Long(2);
69+
childCount = childCount / nodeSize;
70+
}
71+
72+
DirectChatDTO insertFirstDirectChatNode = new DirectChatDTO();
73+
logger.error("----------------" + childCount +"," + rootNodeCID);
74+
insertFirstDirectChatNode.setC_position(childCount);
75+
//insertFirstDirectChatNode.setC_parentid(rootNodeCID);
76+
insertFirstDirectChatNode.setRef(rootNodeCID);
77+
insertFirstDirectChatNode.setC_title("first directchat contents" + DateUtils.getCurrentDay());
78+
insertFirstDirectChatNode.setC_type("default");
79+
DirectChatDTO insertedDTO = directChatService.addNode(insertFirstDirectChatNode);
80+
81+
final HashSet<DirectChatDTO> directChatDTOs = new HashSet<DirectChatDTO>();
82+
directChatDTOs.add(insertedDTO);
83+
jsTreeHibernateDTO.setDirectChatDTOs(directChatDTOs);
84+
5085
ModelAndView modelAndView = new ModelAndView("jsonView");
5186
modelAndView.addObject("result", menuService.addNode(jsTreeHibernateDTO));
87+
88+
//후처리.
89+
5290
return modelAndView;
5391
}
5492

standard/project/web/src/main/webapp/WEB-INF/jsp/egovframework/api/rivalWar/directChat/JsTreeView.jsp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,14 @@ table.dataTable.dtr-inline.collapsed tbody td:first-child:before,table.dataTable
390390
console.log(selectedNodeID);
391391
}
392392
</script>
393-
<customTags:jstree target="#demo" getChildNode="${pageContext.request.contextPath}/api/rivalWar/directChat/getChildNode.do"
394-
searchNode="${pageContext.request.contextPath}/api/rivalWar/directChat/searchNode.do"
395-
addNode="${pageContext.request.contextPath}/api/rivalWar/directChat/addNode.do"
396-
removeNode="${pageContext.request.contextPath}/api/rivalWar/directChat/removeNode.do"
397-
alterNode="${pageContext.request.contextPath}/api/rivalWar/directChat/alterNode.do"
398-
alterNodeType="${pageContext.request.contextPath}/api/rivalWar/directChat/alterNodeType.do"
399-
moveNode="${pageContext.request.contextPath}/api/rivalWar/directChat/moveNode.do"></customTags:jstree>
393+
<customTags:jstree target="#demo"
394+
getChildNode="${pageContext.request.contextPath}/api/rivalWar/directChat/getChildNode.do"
395+
searchNode="${pageContext.request.contextPath}/api/rivalWar/directChat/searchNode.do"
396+
addNode="${pageContext.request.contextPath}/api/rivalWar/ROLE_ADMIN/directChat/addNode.do"
397+
removeNode="${pageContext.request.contextPath}/api/rivalWar/ROLE_ADMIN/directChat/removeNode.do"
398+
alterNode="${pageContext.request.contextPath}/api/rivalWar/ROLE_ADMIN/directChat/alterNode.do"
399+
alterNodeType="${pageContext.request.contextPath}/api/rivalWar/ROLE_ADMIN/directChat/alterNodeType.do"
400+
moveNode="${pageContext.request.contextPath}/api/rivalWar/ROLE_ADMIN/directChat/moveNode.do"></customTags:jstree>
400401
</div>
401402
</div>
402403
</div>

0 commit comments

Comments
 (0)