11package egovframework .api .rivalWar .menu .controller ;
22
33import com .fasterxml .jackson .core .JsonProcessingException ;
4+ import egovframework .api .rivalWar .directChat .service .DirectChatService ;
5+ import egovframework .api .rivalWar .directChat .vo .DirectChatDTO ;
46import egovframework .api .rivalWar .menu .service .MenuService ;
57import egovframework .api .rivalWar .menu .vo .MenuDTO ;
68import egovframework .com .ext .jstree .springiBatis .core .util .Util_TitleChecker ;
79import egovframework .com .ext .jstree .springiBatis .core .validation .group .*;
810import 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 ;
913import org .slf4j .Logger ;
1014import org .slf4j .LoggerFactory ;
1115import org .springframework .beans .factory .annotation .Autowired ;
1923import org .springframework .web .servlet .ModelAndView ;
2024
2125import 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
0 commit comments