Index: web-module/src/main/java/egovframework/api/menu/controller/AdminMenuController.java =================================================================== diff -u --- web-module/src/main/java/egovframework/api/menu/controller/AdminMenuController.java (revision 0) +++ web-module/src/main/java/egovframework/api/menu/controller/AdminMenuController.java (revision 3cf13cb8bad6bf58fa47db7775158af34554527b) @@ -0,0 +1,129 @@ +package egovframework.api.menu.controller; + +import egovframework.api.menu.service.MenuService; +import egovframework.api.menu.vo.MenuDTO; +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; + +@Controller +@RequestMapping(value = {"/api/ROLE_ADMIN/menu"}) +public class AdminMenuController extends GenericAbstractController { + + @Autowired + private MenuService menuService; + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @ResponseBody + @RequestMapping(value = "/addNode.do", method = RequestMethod.POST) + public ModelAndView addNode(@Validated(value = AddNode.class) MenuDTO jsTreeHibernateDTO, + BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) + throw new RuntimeException(); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", menuService.addNode(jsTreeHibernateDTO)); + + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/removeNode.do", method = RequestMethod.POST) + public ModelAndView removeNode(@Validated(value = RemoveNode.class) MenuDTO jsTreeHibernateDTO, + BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) + throw new RuntimeException(); + + MenuDTO targetMenuNode = menuService.getNode(jsTreeHibernateDTO); + + jsTreeHibernateDTO.setStatus(menuService.removeNode(targetMenuNode)); + + setJsonDefaultSetting(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", jsTreeHibernateDTO); + return modelAndView; + } + + private void setJsonDefaultSetting(MenuDTO 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); + } + + @ResponseBody + @RequestMapping(value = "/alterNode.do", method = RequestMethod.POST) + public ModelAndView alterNode(@Validated(value = AlterNode.class) MenuDTO jsTreeHibernateDTO, + BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()){ + throw new RuntimeException(); + } + + jsTreeHibernateDTO.setC_title(Util_TitleChecker.StringReplace(jsTreeHibernateDTO.getC_title())); + + jsTreeHibernateDTO.setStatus(menuService.alterNode(jsTreeHibernateDTO)); + setJsonDefaultSetting(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", jsTreeHibernateDTO); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/alterNodeType.do", method = RequestMethod.POST) + public ModelAndView alterNodeType(@Validated(value = AlterNodeType.class) MenuDTO jsTreeHibernateDTO, + BindingResult bindingResult, ModelMap model) throws Exception { + if (bindingResult.hasErrors()) + throw new RuntimeException(); + + menuService.alterNodeType(jsTreeHibernateDTO); + setJsonDefaultSetting(jsTreeHibernateDTO); + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", jsTreeHibernateDTO); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/moveNode.do", method = RequestMethod.POST) + public ModelAndView moveNode(@Validated(value = MoveNode.class) MenuDTO jsTreeHibernateDTO, + BindingResult bindingResult, ModelMap model, HttpServletRequest request) throws Exception { + if (bindingResult.hasErrors()) + throw new RuntimeException(); + + menuService.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: web-module/src/main/java/egovframework/api/menu/controller/AnonymousMenuController.java =================================================================== diff -u --- web-module/src/main/java/egovframework/api/menu/controller/AnonymousMenuController.java (revision 0) +++ web-module/src/main/java/egovframework/api/menu/controller/AnonymousMenuController.java (revision 3cf13cb8bad6bf58fa47db7775158af34554527b) @@ -0,0 +1,155 @@ +package egovframework.api.menu.controller; + +import com.google.common.collect.Maps; +import egovframework.api.menu.service.MenuService; +import egovframework.api.menu.vo.MenuDTO; +import egovframework.com.cmm.annotation.IncludedInfo; +import egovframework.com.ext.jstree.support.mvc.GenericAbstractController; +import egovframework.com.ext.jstree.support.util.ParameterParser; +import org.hibernate.criterion.Order; +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.HashMap; +import java.util.List; + +@Controller +@RequestMapping(value = {"/api/menu"}) +public class AnonymousMenuController extends GenericAbstractController { + + @Autowired + private MenuService menuService; + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @IncludedInfo(name = "Developer Portal Web Admin Menu", listUrl = "/api/menu/getJsTreeView.do", order = 7000, gid = 7313) + @RequestMapping("/getJsTreeView.do") + public String getWebMenu() { + return "egovframework/api/menu/JsTreeView"; + } + + @ResponseBody + @RequestMapping(value = "/searchNode.do", method = RequestMethod.GET) + public ModelAndView searchNode(MenuDTO 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", menuService.searchNode(jsTreeHibernateDTO)); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/getPaginatedChildNode.do", method = RequestMethod.GET) + public ModelAndView getPaginatedChildNode(MenuDTO 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 = menuService.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) + public ModelAndView getNode(MenuDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request) + throws Exception { + + ParameterParser parser = new ParameterParser(request); + + if (parser.getInt("c_id") <= 0) { + throw new RuntimeException(); + } + + MenuDTO menuDTO = menuService.getNode(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", menuDTO); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/getChildNode.do", method = RequestMethod.GET) + public ModelAndView getChildNode(MenuDTO 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 = menuService.getChildNode(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", list); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/getMonitor.do", method = RequestMethod.GET) + public ModelAndView getMonitor(MenuDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request) + throws Exception { + + jsTreeHibernateDTO.setOrder(Order.asc("c_id")); + List list = menuService.getChildNode(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", list); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/getRootMenuCategories.do", method = RequestMethod.GET) + public ModelAndView getRootNodeCategories(MenuDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request) + throws Exception { + + jsTreeHibernateDTO.setWhere("c_parentid", new Long(2)); + List list = menuService.getChildNode(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", list); + return modelAndView; + } + + @ResponseBody + @RequestMapping(value = "/getRecentList.do", method = RequestMethod.GET) + public ModelAndView getRecentList(MenuDTO jsTreeHibernateDTO, ModelMap model, HttpServletRequest request) + throws Exception { + + jsTreeHibernateDTO.setWhere("c_parentid", new Long(3)); + List list = menuService.getChildNode(jsTreeHibernateDTO); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", list); + return modelAndView; + } + + +} Index: web-module/src/main/java/egovframework/api/menu/controller/UserMenuController.java =================================================================== diff -u --- web-module/src/main/java/egovframework/api/menu/controller/UserMenuController.java (revision 0) +++ web-module/src/main/java/egovframework/api/menu/controller/UserMenuController.java (revision 3cf13cb8bad6bf58fa47db7775158af34554527b) @@ -0,0 +1,20 @@ +package egovframework.api.menu.controller; + +import egovframework.api.menu.service.MenuService; +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; + +@Controller +@RequestMapping(value = {"/api/ROLE_USER/menu"}) +public class UserMenuController extends GenericAbstractController { + + @Autowired + private MenuService menuService; + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + +} Index: web-module/src/main/java/egovframework/api/menu/service/MenuService.java =================================================================== diff -u --- web-module/src/main/java/egovframework/api/menu/service/MenuService.java (revision 0) +++ web-module/src/main/java/egovframework/api/menu/service/MenuService.java (revision 3cf13cb8bad6bf58fa47db7775158af34554527b) @@ -0,0 +1,7 @@ +package egovframework.api.menu.service; + +import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateService; + +public interface MenuService extends JsTreeHibernateService{ + +} Index: web-module/src/main/java/egovframework/api/menu/service/MenuServiceImpl.java =================================================================== diff -u --- web-module/src/main/java/egovframework/api/menu/service/MenuServiceImpl.java (revision 0) +++ web-module/src/main/java/egovframework/api/menu/service/MenuServiceImpl.java (revision 3cf13cb8bad6bf58fa47db7775158af34554527b) @@ -0,0 +1,9 @@ +package egovframework.api.menu.service; + +import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateServiceImpl; +import org.springframework.stereotype.Service; + +@Service("MenuService") +public class MenuServiceImpl extends JsTreeHibernateServiceImpl implements MenuService { + +} \ No newline at end of file Index: web-module/src/main/java/egovframework/api/menu/vo/MenuDTO.java =================================================================== diff -u --- web-module/src/main/java/egovframework/api/menu/vo/MenuDTO.java (revision 0) +++ web-module/src/main/java/egovframework/api/menu/vo/MenuDTO.java (revision 3cf13cb8bad6bf58fa47db7775158af34554527b) @@ -0,0 +1,70 @@ +package egovframework.api.menu.vo; + +import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.*; + +import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.Table; +import java.io.Serializable; + +@Entity +@Table(name = "T_COMPREHENSIVE_MENU") +@SelectBeforeUpdate(value = true) +@DynamicInsert(value = true) +@DynamicUpdate(value = true) +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SequenceGenerator(name = "JsTreeSequence", sequenceName = "S_COMPREHENSIVE_MENU", allocationSize = 1) +public class MenuDTO extends JsTreeHibernateSearchDTO implements Serializable { + + private static final long serialVersionUID = 5641929581490357882L; + + public MenuDTO() { + super(); + } + + public MenuDTO(Boolean copyBooleanValue) { + super(); + this.copyBooleanValue = copyBooleanValue; + } + + /* + * Extend Bean Field + */ + private Boolean copyBooleanValue; + + @Transient + public Boolean getCopyBooleanValue() { + copyBooleanValue = false; + if (this.getCopy() == 0) { + copyBooleanValue = false; + } else { + copyBooleanValue = true; + } + return copyBooleanValue; + } + + public void setCopyBooleanValue(Boolean copyBooleanValue) { + this.copyBooleanValue = copyBooleanValue; + } + + private String c_link; + + @Column(name = "c_link") + public String getC_link() { + return c_link; + } + + public void setC_link(String c_link) { + this.c_link = c_link; + } + + @Override + public void setFieldFromNewInstance(T paramInstance) { + if (paramInstance instanceof MenuDTO) { + this.setC_link(((MenuDTO) paramInstance).getC_link()); + } + } + +}