package com.landtool.lanbase.modules.sys.service.impl;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.landtool.lanbase.common.Constant;
|
import com.landtool.lanbase.common.Constant.MenuType;
|
import com.landtool.lanbase.modules.org.service.OrgUserService;
|
import com.landtool.lanbase.modules.sys.dao.SysMenuDao;
|
import com.landtool.lanbase.modules.sys.entity.SysMenu;
|
import com.landtool.lanbase.modules.sys.service.SysMenuService;
|
|
import java.util.*;
|
|
@Service("sysMenuService")
|
public class SysMenuServiceImpl implements SysMenuService {
|
|
@Autowired
|
private SysMenuDao sysMenuDao;
|
|
@Autowired
|
private OrgUserService orgUserService;
|
|
@Autowired
|
private SysMenuService sysMenuService;
|
|
@Override
|
public List<SysMenu> queryListByParentId(Long parentId, List<Long> menuIdList) {
|
List<SysMenu> menuList = queryListByParentId(parentId);
|
if(menuIdList == null){
|
return menuList;
|
}
|
|
List<SysMenu> userMenuList = new ArrayList<>();
|
for(SysMenu menu : menuList){
|
if(menuIdList.contains(menu.getId())){
|
userMenuList.add(menu);
|
}
|
}
|
return userMenuList;
|
}
|
|
@Override
|
public List<SysMenu> queryListByParentId(Long parentId) {
|
return sysMenuDao.queryListByParentId(parentId);
|
}
|
|
@Override
|
public List<SysMenu> queryNotButtonList() {
|
return sysMenuDao.queryNotButtonList();
|
}
|
|
@Override
|
public List<SysMenu> getUserMenuList(Long userId) {
|
//系统管理员,拥有最高权限
|
// if(userId == Constant.SUPER_ADMIN || userId<=20){
|
if(1==1){ //临时方案
|
return getAllMenuList(null);
|
}
|
|
//用户菜单列表
|
List<Long> menuIdList = orgUserService.queryAllMenuId(userId);
|
return getAllMenuList(menuIdList);
|
}
|
|
@Override
|
public SysMenu queryObject(Long id) {
|
return sysMenuDao.queryObject(id);
|
}
|
|
@Override
|
public List<SysMenu> queryList(SysMenu menu) {
|
return sysMenuDao.queryList(menu);
|
}
|
|
@Override
|
public List<SysMenu> queryChildList(SysMenu menu) {
|
return sysMenuDao.queryChildList(menu);
|
}
|
|
@Override
|
public int queryTotal(Map<String, Object> map) {
|
return sysMenuDao.queryTotal(map);
|
}
|
|
@Override
|
@Transactional
|
public void save(SysMenu menu) {
|
sysMenuDao.save(menu);
|
}
|
|
@Override
|
@Transactional
|
public void update(SysMenu menu) {
|
sysMenuDao.update(menu);
|
}
|
|
@Override
|
@Transactional
|
public void deleteBatch(Long[] ids) {
|
// 批量删除多层目录、菜单 、按钮
|
if (ids.length == 0) return;
|
for (Long id : ids) {
|
List<SysMenu> menuList = sysMenuService.queryAllListByParentId(id);
|
for (SysMenu childId : menuList) {
|
sysMenuService.deleteBatch(new Long[]{childId.getId()});
|
}
|
}
|
sysMenuDao.deleteBatch(ids);
|
}
|
|
@Override
|
public List<SysMenu> queryUserList(Long userId) {
|
return sysMenuDao.queryUserList(userId);
|
}
|
|
/**
|
* 获取所有菜单列表
|
*/
|
private List<SysMenu> getAllMenuList(List<Long> menuIdList){
|
//查询根菜单列表
|
List<SysMenu> menuList = queryListByParentId(0L, menuIdList);
|
//递归获取子菜单
|
getMenuTreeList(menuList, menuIdList);
|
|
return menuList;
|
}
|
|
/**
|
* 递归
|
*/
|
private List<SysMenu> getMenuTreeList(List<SysMenu> menuList, List<Long> menuIdList){
|
List<SysMenu> subMenuList = new ArrayList<SysMenu>();
|
|
for(SysMenu entity : menuList){
|
if(entity.getType() == MenuType.CATALOG.getValue()){//目录
|
entity.setList(getMenuTreeList(queryListByParentId(entity.getId(), menuIdList), menuIdList));
|
}
|
subMenuList.add(entity);
|
}
|
|
return subMenuList;
|
}
|
|
/**
|
* 获取自增长id值
|
*/
|
@Override
|
public int queryUserWithSEQ(){
|
return sysMenuDao.queryUserWithSEQ();
|
}
|
|
@Override
|
public List<SysMenu> queryNoButtonListByParentId(Long parentId) {
|
return sysMenuDao.queryNoButtonListByParentId(parentId);
|
}
|
|
@Override
|
public void updateRorder(SysMenu menu) {
|
sysMenuDao.updateRorder(menu);
|
}
|
|
@Override
|
public int queryMaxRorder(Long parentId){
|
Map<String,Object> paramMap = new HashMap<String,Object>();
|
paramMap.put("parentId",parentId);
|
return sysMenuDao.queryMaxRorder(paramMap);
|
}
|
|
@Override
|
public List<SysMenu> queryAllListByParentId(Long parentId) {
|
return sysMenuDao.queryAllListByParentId(parentId);
|
}
|
}
|