MenuService.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package com.zhcs.dt.service.system.menu.impl;
  2. import java.util.List;
  3. import javax.annotation.Resource;
  4. import org.springframework.stereotype.Service;
  5. import com.zhcs.dt.dao.DaoSupport;
  6. import com.zhcs.dt.entity.system.Menu;
  7. import com.zhcs.dt.service.system.menu.MenuManager;
  8. import com.zhcs.dt.util.PageData;
  9. /**
  10. * 类名称:MenuService 菜单处理
  11. * 创建人:FH qq 3 1 3 5 9 6 7 9 0[青苔]
  12. * 修改时间:2015年10月27日
  13. * @version v2
  14. */
  15. @Service("menuService")
  16. public class MenuService implements MenuManager{
  17. @Resource(name = "daoSupport")
  18. private DaoSupport dao;
  19. /**
  20. * 通过ID获取其子一级菜单
  21. * @param parentId
  22. * @return
  23. * @throws Exception
  24. */
  25. @SuppressWarnings("unchecked")
  26. public List<Menu> listSubMenuByParentId(String parentId) throws Exception {
  27. return (List<Menu>) dao.findForList("MenuMapper.listSubMenuByParentId", parentId);
  28. }
  29. /**
  30. * 通过菜单ID获取数据
  31. * @param pd
  32. * @return
  33. * @throws Exception
  34. */
  35. public PageData getMenuById(PageData pd) throws Exception {
  36. return (PageData) dao.findForObject("MenuMapper.getMenuById", pd);
  37. }
  38. /**
  39. * 新增菜单
  40. * @param menu
  41. * @throws Exception
  42. */
  43. public void saveMenu(Menu menu) throws Exception {
  44. dao.save("MenuMapper.insertMenu", menu);
  45. }
  46. /**
  47. * 取最大ID
  48. * @param pd
  49. * @return
  50. * @throws Exception
  51. */
  52. public PageData findMaxId(PageData pd) throws Exception {
  53. return (PageData) dao.findForObject("MenuMapper.findMaxId", pd);
  54. }
  55. /**
  56. * 删除菜单
  57. * @param MENU_ID
  58. * @throws Exception
  59. */
  60. public void deleteMenuById(String MENU_ID) throws Exception {
  61. dao.save("MenuMapper.deleteMenuById", MENU_ID);
  62. }
  63. /**
  64. * 编辑
  65. * @param menu
  66. * @return
  67. * @throws Exception
  68. */
  69. public void edit(Menu menu) throws Exception {
  70. dao.update("MenuMapper.updateMenu", menu);
  71. }
  72. /**
  73. * 保存菜单图标
  74. * @param pd
  75. * @return
  76. * @throws Exception
  77. */
  78. public PageData editicon(PageData pd) throws Exception {
  79. return (PageData)dao.findForObject("MenuMapper.editicon", pd);
  80. }
  81. /**
  82. * 获取所有菜单并填充每个菜单的子菜单列表(菜单管理)(递归处理)
  83. * @param MENU_ID
  84. * @return
  85. * @throws Exception
  86. */
  87. public List<Menu> listAllMenu(String MENU_ID) throws Exception {
  88. List<Menu> menuList = this.listSubMenuByParentId(MENU_ID);
  89. for(Menu menu : menuList){
  90. menu.setMENU_URL("menu/toEdit.do?MENU_ID="+menu.getMENU_ID());
  91. menu.setSubMenu(this.listAllMenu(menu.getMENU_ID()));
  92. menu.setTarget("treeFrame");
  93. }
  94. return menuList;
  95. }
  96. /**
  97. * 获取所有菜单并填充每个菜单的子菜单列表(系统菜单列表)(递归处理)
  98. * @param MENU_ID
  99. * @return
  100. * @throws Exception
  101. */
  102. public List<Menu> listAllMenuQx(String MENU_ID) throws Exception {
  103. List<Menu> menuList = this.listSubMenuByParentId(MENU_ID);
  104. for(Menu menu : menuList){
  105. menu.setSubMenu(this.listAllMenuQx(menu.getMENU_ID()));
  106. menu.setTarget("treeFrame");
  107. }
  108. return menuList;
  109. }
  110. }