Index: .idea/sonarIssues.xml
===================================================================
diff -u -r458facbd00d299a2ec09b3d7d38a55baf0e629ce -r399bdde680ce154c19752cafa8957922af5ad0fe
--- .idea/sonarIssues.xml (.../sonarIssues.xml) (revision 458facbd00d299a2ec09b3d7d38a55baf0e629ce)
+++ .idea/sonarIssues.xml (.../sonarIssues.xml) (revision 399bdde680ce154c19752cafa8957922af5ad0fe)
@@ -1088,6 +1088,11 @@
+
+
+
+
+
Index: standard/project/web/src/main/java/egovframework/api/rivalWar/compareItem/controller/AdminCompareItemController.java
===================================================================
diff -u -rb834e51051143141bd84f88e030a3a0cb920e52c -r399bdde680ce154c19752cafa8957922af5ad0fe
--- standard/project/web/src/main/java/egovframework/api/rivalWar/compareItem/controller/AdminCompareItemController.java (.../AdminCompareItemController.java) (revision b834e51051143141bd84f88e030a3a0cb920e52c)
+++ standard/project/web/src/main/java/egovframework/api/rivalWar/compareItem/controller/AdminCompareItemController.java (.../AdminCompareItemController.java) (revision 399bdde680ce154c19752cafa8957922af5ad0fe)
@@ -1,7 +1,179 @@
package egovframework.api.rivalWar.compareItem.controller;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import egovframework.api.rivalWar.compareItem.service.CompareItemService;
+import egovframework.api.rivalWar.compareItem.vo.CompareItemDTO;
+import egovframework.com.ext.jstree.springiBatis.core.util.Util_TitleChecker;
+import egovframework.com.ext.jstree.springiBatis.core.validation.group.*;
+import egovframework.com.ext.jstree.support.mvc.GenericAbstractController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+
/**
* Created by Administrator on 2017-10-08.
*/
-public class AdminCompareItemController {
+@Controller
+@RequestMapping(value = {"/api/rivalWar/ROLE_ADMIN/compareItem"})
+public class AdminCompareItemController extends GenericAbstractController {
+
+ @Autowired
+ private CompareItemService compareItemService;
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /**
+ * 노드를 추가한다.
+ *
+ * @param jsTreeHibernateDTO
+ * @param model
+ * @param bindingResult
+ * @return
+ * @throws JsonProcessingException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ @ResponseBody
+ @RequestMapping(value = "/addNode.do", method = RequestMethod.POST)
+ public ModelAndView addNode(@Validated(value = AddNode.class) CompareItemDTO jsTreeHibernateDTO,
+ BindingResult bindingResult, ModelMap model) throws Exception {
+ if (bindingResult.hasErrors())
+ throw new RuntimeException();
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", compareItemService.addNode(jsTreeHibernateDTO));
+ return modelAndView;
+ }
+
+ /**
+ * 노드를 삭제한다.
+ *
+ * @param jsTreeHibernateDTO
+ * @param model
+ * @param bindingResult
+ * @return
+ * @throws JsonProcessingException
+ */
+ @ResponseBody
+ @RequestMapping(value = "/removeNode.do", method = RequestMethod.POST)
+ public ModelAndView removeNode(@Validated(value = RemoveNode.class) CompareItemDTO jsTreeHibernateDTO,
+ BindingResult bindingResult, ModelMap model) throws Exception {
+ if (bindingResult.hasErrors())
+ throw new RuntimeException();
+
+ jsTreeHibernateDTO.setStatus(compareItemService.removeNode(jsTreeHibernateDTO));
+ setJsonDefaultSetting(jsTreeHibernateDTO);
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", jsTreeHibernateDTO);
+ return modelAndView;
+ }
+
+ private void setJsonDefaultSetting(CompareItemDTO jsTreeHibernateDTO) {
+ long defaultSettingValue = 0;
+ jsTreeHibernateDTO.setC_parentid(defaultSettingValue);
+ jsTreeHibernateDTO.setC_position(defaultSettingValue);
+ jsTreeHibernateDTO.setC_left(defaultSettingValue);
+ jsTreeHibernateDTO.setC_right(defaultSettingValue);
+ jsTreeHibernateDTO.setC_level(defaultSettingValue);
+ jsTreeHibernateDTO.setRef(defaultSettingValue);
+ }
+
+ /**
+ * 노드를 변경한다.
+ *
+ * @param jsTreeHibernateDTO
+ * @param model
+ * @param bindingResult
+ * @return
+ * @throws JsonProcessingException
+ */
+ @ResponseBody
+ @RequestMapping(value = "/alterNode.do", method = RequestMethod.POST)
+ public ModelAndView alterNode(@Validated(value = AlterNode.class) CompareItemDTO jsTreeHibernateDTO,
+ BindingResult bindingResult, ModelMap model) throws Exception {
+ if (bindingResult.hasErrors()){
+ throw new RuntimeException();
+ }
+
+ jsTreeHibernateDTO.setC_title(Util_TitleChecker.StringReplace(jsTreeHibernateDTO.getC_title()));
+
+ jsTreeHibernateDTO.setStatus(compareItemService.alterNode(jsTreeHibernateDTO));
+ setJsonDefaultSetting(jsTreeHibernateDTO);
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", jsTreeHibernateDTO);
+ return modelAndView;
+ }
+
+
+ /**
+ * 노드의 타입을 변경한다.
+ *
+ * @param jsTreeHibernateDTO
+ * @param model
+ * @param bindingResult
+ * @return
+ * @throws JsonProcessingException
+ */
+ @ResponseBody
+ @RequestMapping(value = "/alterNodeType.do", method = RequestMethod.POST)
+ public ModelAndView alterNodeType(@Validated(value = AlterNodeType.class) CompareItemDTO jsTreeHibernateDTO,
+ BindingResult bindingResult, ModelMap model) throws Exception {
+ if (bindingResult.hasErrors())
+ throw new RuntimeException();
+
+ compareItemService.alterNodeType(jsTreeHibernateDTO);
+ setJsonDefaultSetting(jsTreeHibernateDTO);
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", jsTreeHibernateDTO);
+ return modelAndView;
+ }
+
+ /**
+ * 노드를 이동한다.
+ *
+ * @param jsTreeHibernateDTO
+ * @param model
+ * @param request
+ * @return
+ * @throws JsonProcessingException
+ * @throws ReflectiveOperationException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ @ResponseBody
+ @RequestMapping(value = "/moveMenu.do", method = RequestMethod.POST)
+ public ModelAndView moveNode(@Validated(value = MoveNode.class) CompareItemDTO jsTreeHibernateDTO,
+ BindingResult bindingResult, ModelMap model, HttpServletRequest request) throws Exception {
+ if (bindingResult.hasErrors()) {
+ throw new RuntimeException();
+ }
+ compareItemService.moveNode(jsTreeHibernateDTO, request);
+ setJsonDefaultSetting(jsTreeHibernateDTO);
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", jsTreeHibernateDTO);
+ return modelAndView;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "/analyzeNode.do", method = RequestMethod.GET)
+ public ModelAndView getChildNode(ModelMap model) {
+ model.addAttribute("analyzeResult", "");
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", "true");
+ return modelAndView;
+ }
}
Index: standard/project/web/src/main/java/egovframework/api/rivalWar/compareItem/controller/AnonymousCompareItemController.java
===================================================================
diff -u -rdf7966c5af96a690dce0fa28f988c3d87d1e8638 -r399bdde680ce154c19752cafa8957922af5ad0fe
--- standard/project/web/src/main/java/egovframework/api/rivalWar/compareItem/controller/AnonymousCompareItemController.java (.../AnonymousCompareItemController.java) (revision df7966c5af96a690dce0fa28f988c3d87d1e8638)
+++ standard/project/web/src/main/java/egovframework/api/rivalWar/compareItem/controller/AnonymousCompareItemController.java (.../AnonymousCompareItemController.java) (revision 399bdde680ce154c19752cafa8957922af5ad0fe)
@@ -1,14 +1,28 @@
package egovframework.api.rivalWar.compareItem.controller;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.google.common.collect.Maps;
import egovframework.api.rivalWar.compareItem.service.CompareItemService;
+import egovframework.api.rivalWar.compareItem.vo.CompareItemDTO;
import egovframework.com.cmm.annotation.IncludedInfo;
import egovframework.com.ext.jstree.support.mvc.GenericAbstractController;
+import egovframework.com.ext.jstree.support.util.ParameterParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
/**
* Created by Administrator on 2017-10-08.
*/
@@ -26,4 +40,119 @@
public String getRivalWarCompareSpecJstreeView() {
return "egovframework/api/rivalWar/compareItem/JsTreeView";
}
+
+ /**
+ * 노드를 검색한다.
+ *
+ * @param jsTreeHibernateDTO
+ * @param model
+ * @param request
+ * @return
+ * @throws JsonProcessingException
+ */
+ @ResponseBody
+ @RequestMapping(value = "/searchNode.do", method = RequestMethod.GET)
+ public ModelAndView searchNode(CompareItemDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request)
+ throws Exception {
+
+ ParameterParser parser = new ParameterParser(request);
+
+ if (!StringUtils.hasText(request.getParameter("searchString"))) {
+ throw new RuntimeException();
+ }
+
+ jsTreeHibernateDTO.setWhereLike("c_title", parser.get("parser"));
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", compareItemService.searchNode(jsTreeHibernateDTO));
+ return modelAndView;
+ }
+
+
+ @ResponseBody
+ @RequestMapping(value = "/getPaginatedChildNode.do", method = RequestMethod.GET)
+ public ModelAndView getPaginatedChildNode(CompareItemDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request)
+ throws Exception {
+
+ if (jsTreeHibernateDTO.getC_id() <= 0 || jsTreeHibernateDTO.getPageIndex() <= 0
+ || jsTreeHibernateDTO.getPageUnit() <= 0 || jsTreeHibernateDTO.getPageSize() <= 0) {
+ throw new RuntimeException();
+ }
+
+ jsTreeHibernateDTO.setWhere("c_parentid", jsTreeHibernateDTO.getC_id());
+ List list = compareItemService.getPaginatedChildNode(jsTreeHibernateDTO);
+ jsTreeHibernateDTO.getPaginationInfo().setTotalRecordCount(list.size());
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ HashMap resultMap = Maps.newHashMap();
+ resultMap.put("paginationInfo", jsTreeHibernateDTO.getPaginationInfo());
+ resultMap.put("result", list);
+ modelAndView.addObject("result", resultMap);
+ return modelAndView;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "/getNode.do", method = {RequestMethod.GET, RequestMethod.POST})
+ public ModelAndView getNode(CompareItemDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request)
+ throws Exception {
+
+ if(request.getMethod().equals("GET")){
+ ParameterParser parser = new ParameterParser(request);
+
+ if (parser.getInt("c_id") <= 0 ) {
+ throw new RuntimeException();
+ }
+ }else{
+ if(jsTreeHibernateDTO.getC_id() <= 0){
+ throw new RuntimeException();
+ }
+ }
+
+ CompareItemDTO selectedJsTreeHibernateDTO = compareItemService.getNode(jsTreeHibernateDTO);
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", selectedJsTreeHibernateDTO);
+ return modelAndView;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "/getNodeForDatatable.do", method = {RequestMethod.GET, RequestMethod.POST})
+ public ModelAndView getNodeForDatatable(CompareItemDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request)
+ throws Exception {
+
+ if(request.getMethod().equals("GET")){
+ ParameterParser parser = new ParameterParser(request);
+
+ if (parser.getInt("c_id") <= 0 ) {
+ throw new RuntimeException();
+ }
+ }else{
+ if(jsTreeHibernateDTO.getC_id() <= 0){
+ throw new RuntimeException();
+ }
+ }
+ List list = new ArrayList();
+ list.add(compareItemService.getNode(jsTreeHibernateDTO));
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", list);
+ return modelAndView;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "/getChildNode.do", method = RequestMethod.GET)
+ public ModelAndView getChildNode(CompareItemDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request) throws Exception {
+
+ ParameterParser parser = new ParameterParser(request);
+
+ if (parser.getInt("c_id") <= 0) {
+ throw new RuntimeException();
+ }
+
+ jsTreeHibernateDTO.setWhere("c_parentid", new Long(parser.get("c_id")));
+ List list = compareItemService.getChildNode(jsTreeHibernateDTO);
+
+ ModelAndView modelAndView = new ModelAndView("jsonView");
+ modelAndView.addObject("result", list);
+ return modelAndView;
+ }
}