| | |
| | | package com.moral.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.util.ExampleUtil; |
| | | import com.moral.entity.Menu; |
| | | import com.moral.entity.RoleMenu; |
| | | import com.moral.mapper.MenuMapper; |
| | | import com.moral.mapper.RoleMenuMapper; |
| | | import com.moral.service.MenuService; |
| | | import com.moral.util.TkMybatisUtils; |
| | | import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer; |
| | | |
| | | import javax.annotation.Resource; |
| | | import tk.mybatis.mapper.entity.Example; |
| | | |
| | | @Service |
| | |
| | | @Resource |
| | | private MenuMapper menuMapper; |
| | | |
| | | @Resource |
| | | private RoleMenuMapper roleMenuMapper; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void addOrModify(Menu menu) { |
| | | try { |
| | | if (menu.getMenuParentId() == null) { |
| | | menu.setMenuParentId(0); |
| | | } |
| | | menu.setUpdateTime(new Date()); |
| | | menu.setUpdateUser(menu.getUpdateUser()); |
| | | if (menu.getId() != null) { |
| | |
| | | menu.setId(menuResult.getId()); |
| | | menuMapper.updateByPrimaryKeySelective(menu); |
| | | } else { |
| | | System.out.println("channelId:"+menu.getChannelId()); |
| | | menu.setChannelId(menu.getChannelId()); |
| | | menu.setIsDelete(Constants.IS_DELETE_FALSE); |
| | | menu.setCreateTime(new Date()); |
| | |
| | | Example example = new Example(ENTITY_CLASS); |
| | | example.or().andIn("id", Arrays.asList(ids)); |
| | | menuMapper.updateByExampleSelective(menu, example); |
| | | Example roleMenuExample = new Example(RoleMenu.class); |
| | | roleMenuExample.or().andIn("menuId", Arrays.asList(ids)); |
| | | roleMenuMapper.deleteByExample(roleMenuExample); |
| | | } |
| | | |
| | | @Override |
| | | public List<Menu> getMenuListByName(String menuName) { |
| | | List<Menu> menuList = menuMapper.getMenuListByName(menuName); |
| | | return menuList; |
| | | public List<Menu> getZNodes() { |
| | | List<Menu> menuList = menuMapper.getMenuListInfo(); |
| | | List<Menu> zNodes = new ArrayList<>(); |
| | | for (Menu menu : menuList) { |
| | | if (menu.getMenuOrder().toString().substring(0, 1).equals("1")) { |
| | | menu.setMenuParentId(Integer.valueOf(menu.getMenuOrder().toString().substring(0, 1))); |
| | | } else { |
| | | if (menu.getMenuOrder().toString().length() == 2) { |
| | | menu.setMenuParentId(Integer.valueOf(menu.getMenuOrder().toString().substring(0, 1))); |
| | | } else if (menu.getMenuOrder().toString().length() == 3) { |
| | | menu.setMenuParentId(Integer.valueOf(menu.getMenuOrder().toString().substring(0, 2))); |
| | | } |
| | | } |
| | | zNodes.add(menu); |
| | | } |
| | | return zNodes; |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getMenuOrders(Integer roleId) { |
| | | List<Integer> menuOrders = menuMapper.getMenuOrdersByRoleId(roleId); |
| | | List<Integer> channels = roleMenuMapper.getChannels(roleId); |
| | | if (CollectionUtils.isNotEmpty(channels)) { |
| | | for (Integer channel : channels) { |
| | | menuOrders.add(channel); |
| | | } |
| | | } |
| | | return menuOrders; |
| | | } |
| | | } |