Index: .idea/sonarIssues.xml =================================================================== diff -u -r15a0036dafe83ac4910a17c4c0731607c17dbeba -rc2d0d651ee3784f7874fe480ab337c61cbc257c5 --- .idea/sonarIssues.xml (.../sonarIssues.xml) (revision 15a0036dafe83ac4910a17c4c0731607c17dbeba) +++ .idea/sonarIssues.xml (.../sonarIssues.xml) (revision c2d0d651ee3784f7874fe480ab337c61cbc257c5) @@ -1263,6 +1263,21 @@ + + + + + + + + + + + + + + + Index: standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/AdminUserSelectedItemController.java =================================================================== diff -u -r5b58dcdc464fb120bff3c7d4a19b7771ac8095d8 -rc2d0d651ee3784f7874fe480ab337c61cbc257c5 --- standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/AdminUserSelectedItemController.java (.../AdminUserSelectedItemController.java) (revision 5b58dcdc464fb120bff3c7d4a19b7771ac8095d8) +++ standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/AdminUserSelectedItemController.java (.../AdminUserSelectedItemController.java) (revision c2d0d651ee3784f7874fe480ab337c61cbc257c5) @@ -1,7 +1,174 @@ package egovframework.api.rivalWar.userSelectedItem.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import egovframework.api.rivalWar.userSelectedItem.service.UserSelectedItemService; +import egovframework.api.rivalWar.userSelectedItem.vo.UserSelectedItemDTO; +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-14. */ -public class AdminUserSelectedItemController { +@Controller +@RequestMapping(value = {"/api/rivalWar/ROLE_ADMIN/userSelectedItem"}) +public class AdminUserSelectedItemController extends GenericAbstractController { + + @Autowired + private UserSelectedItemService userSelectedItemService; + + 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) UserSelectedItemDTO jsTreeHibernateDTO, BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) + throw new RuntimeException(); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", userSelectedItemService.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) UserSelectedItemDTO jsTreeHibernateDTO, BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) { + throw new RuntimeException(); + } + jsTreeHibernateDTO.setStatus(userSelectedItemService.removeNode(jsTreeHibernateDTO)); + setJsonDefaultSetting(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", jsTreeHibernateDTO); + return modelAndView; + } + + private void setJsonDefaultSetting(UserSelectedItemDTO 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) UserSelectedItemDTO jsTreeHibernateDTO, BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) { + throw new RuntimeException(); + } + + jsTreeHibernateDTO.setC_title(Util_TitleChecker.StringReplace(jsTreeHibernateDTO.getC_title())); + + jsTreeHibernateDTO.setStatus(userSelectedItemService.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) UserSelectedItemDTO jsTreeHibernateDTO, BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) { + throw new RuntimeException(); + } + userSelectedItemService.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) UserSelectedItemDTO jsTreeHibernateDTO, BindingResult bindingResult, ModelMap model, HttpServletRequest request) throws Exception { + if (bindingResult.hasErrors()) { + throw new RuntimeException(); + } + userSelectedItemService.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/userSelectedItem/controller/AnonymousUserSelectedItemController.java =================================================================== diff -u -r5b58dcdc464fb120bff3c7d4a19b7771ac8095d8 -rc2d0d651ee3784f7874fe480ab337c61cbc257c5 --- standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/AnonymousUserSelectedItemController.java (.../AnonymousUserSelectedItemController.java) (revision 5b58dcdc464fb120bff3c7d4a19b7771ac8095d8) +++ standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/AnonymousUserSelectedItemController.java (.../AnonymousUserSelectedItemController.java) (revision c2d0d651ee3784f7874fe480ab337c61cbc257c5) @@ -1,7 +1,154 @@ package egovframework.api.rivalWar.userSelectedItem.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.collect.Maps; +import egovframework.api.rivalWar.userSelectedItem.service.UserSelectedItemService; +import egovframework.api.rivalWar.userSelectedItem.vo.UserSelectedItemDTO; +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-14. */ -public class AnonymousUserSelectedItemController { +@Controller +@RequestMapping(value = {"/api/rivalWar/userSelectedItem"}) +public class AnonymousUserSelectedItemController extends GenericAbstractController { + + @Autowired + private UserSelectedItemService userSelectedItemService; + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @IncludedInfo(name = "RivalWar Admin UserSelectedItem", listUrl = "/api/rivalWar/userSelectedItem/getJsTreeView.do", order = 7008, gid = 7313) + @RequestMapping("/getJsTreeView.do") + public String getRivalWarUserSelectedItemJstreeView() { + return "egovframework/api/rivalWar/userSelectedItem/JsTreeView"; + } + + /** + * 노드를 검색한다. + * + * @param jsTreeHibernateDTO + * @param model + * @param request + * @return + * @throws JsonProcessingException + */ + @ResponseBody + @RequestMapping(value = "/searchNode.do", method = RequestMethod.GET) + public ModelAndView searchNode(UserSelectedItemDTO 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", userSelectedItemService.searchNode(jsTreeHibernateDTO)); + return modelAndView; + } + + + @ResponseBody + @RequestMapping(value = "/getPaginatedChildNode.do", method = RequestMethod.GET) + public ModelAndView getPaginatedChildNode(UserSelectedItemDTO 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 = userSelectedItemService.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(UserSelectedItemDTO 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(); + } + } + + UserSelectedItemDTO selectedJsTreeHibernateDTO = userSelectedItemService.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(UserSelectedItemDTO 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(userSelectedItemService.getNode(jsTreeHibernateDTO)); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", list); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/getChildNode.do", method = RequestMethod.GET) + public ModelAndView getChildNode(UserSelectedItemDTO 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 = userSelectedItemService.getChildNode(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", list); + return modelAndView; + } } Index: standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/UserSelectedItemController.java =================================================================== diff -u -r5b58dcdc464fb120bff3c7d4a19b7771ac8095d8 -rc2d0d651ee3784f7874fe480ab337c61cbc257c5 --- standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/UserSelectedItemController.java (.../UserSelectedItemController.java) (revision 5b58dcdc464fb120bff3c7d4a19b7771ac8095d8) +++ standard/project/web/src/main/java/egovframework/api/rivalWar/userSelectedItem/controller/UserSelectedItemController.java (.../UserSelectedItemController.java) (revision c2d0d651ee3784f7874fe480ab337c61cbc257c5) @@ -1,7 +1,22 @@ package egovframework.api.rivalWar.userSelectedItem.controller; +import egovframework.api.rivalWar.specHashTag.service.SpecHashTagService; +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.web.bind.annotation.RequestMapping; + /** * Created by Administrator on 2017-10-14. */ -public class UserSelectedItemController { +@Controller +@RequestMapping(value = {"/api/rivalWar/ROLE_USER/userSelectedItem"}) +public class UserSelectedItemController extends GenericAbstractController { + + @Autowired + private SpecHashTagService specHashTagService; + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); }