|
|
|
@@ -14,19 +14,19 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.nl.common.domain.constant.DictConstantPool;
|
|
|
|
import org.nl.common.domain.constant.DictConstantPool;
|
|
|
|
import org.nl.common.domain.query.PageQuery;
|
|
|
|
import org.nl.common.domain.query.PageQuery;
|
|
|
|
import org.nl.common.exception.BadRequestException;
|
|
|
|
|
|
|
|
import org.nl.common.utils.SecurityUtils;
|
|
|
|
|
|
|
|
import org.nl.common.domain.vo.MenuMetaVo;
|
|
|
|
import org.nl.common.domain.vo.MenuMetaVo;
|
|
|
|
import org.nl.common.domain.vo.MenuVo;
|
|
|
|
import org.nl.common.domain.vo.MenuVo;
|
|
|
|
|
|
|
|
import org.nl.common.exception.BadRequestException;
|
|
|
|
import org.nl.common.utils.CopyUtil;
|
|
|
|
import org.nl.common.utils.CopyUtil;
|
|
|
|
|
|
|
|
import org.nl.common.utils.SecurityUtils;
|
|
|
|
import org.nl.config.IdUtil;
|
|
|
|
import org.nl.config.IdUtil;
|
|
|
|
import org.nl.config.language.LangProcess;
|
|
|
|
import org.nl.config.language.LangProcess;
|
|
|
|
import org.nl.system.service.dict.dao.Dict;
|
|
|
|
import org.nl.system.service.dict.dao.Dict;
|
|
|
|
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
|
|
|
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
|
|
|
import org.nl.system.service.menu.dto.MenuDto;
|
|
|
|
|
|
|
|
import org.nl.system.service.menu.ISysMenuService;
|
|
|
|
import org.nl.system.service.menu.ISysMenuService;
|
|
|
|
import org.nl.system.service.menu.dao.SysMenu;
|
|
|
|
import org.nl.system.service.menu.dao.SysMenu;
|
|
|
|
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
|
|
|
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
|
|
|
|
|
|
|
import org.nl.system.service.menu.dto.MenuDto;
|
|
|
|
import org.nl.system.service.menu.dto.MenuQuery;
|
|
|
|
import org.nl.system.service.menu.dto.MenuQuery;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
@@ -66,7 +66,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List query(MenuQuery query, PageQuery page) {
|
|
|
|
public List query(MenuQuery query, PageQuery page) {
|
|
|
|
page.setSort("menu_sort DESC");
|
|
|
|
page.setSort("menu_sort DESC");
|
|
|
|
if (StringUtils.isNotEmpty(query.getBlurry())){
|
|
|
|
if (StringUtils.isNotEmpty(query.getBlurry())) {
|
|
|
|
query.setPid(null);
|
|
|
|
query.setPid(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Page<SysMenu> menuPage = this.page(page.build(), query.build());
|
|
|
|
Page<SysMenu> menuPage = this.page(page.build(), query.build());
|
|
|
|
@@ -138,7 +138,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
|
|
|
|
|
|
|
|
private void addSystemTypeDict(SysMenu resources) {
|
|
|
|
private void addSystemTypeDict(SysMenu resources) {
|
|
|
|
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).orderByDesc("value").last("limit 1"));
|
|
|
|
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).orderByDesc("value").last("limit 1"));
|
|
|
|
Integer currentType = dict!=null?Integer.valueOf(dict.getValue())+1:1;
|
|
|
|
Integer currentType = dict != null ? Integer.valueOf(dict.getValue()) + 1 : 1;
|
|
|
|
Dict currentSysType = new Dict();
|
|
|
|
Dict currentSysType = new Dict();
|
|
|
|
currentSysType.setDict_id(IdUtil.getStringId());
|
|
|
|
currentSysType.setDict_id(IdUtil.getStringId());
|
|
|
|
currentSysType.setCode(DictConstantPool.DICT_SYS_CODE);
|
|
|
|
currentSysType.setCode(DictConstantPool.DICT_SYS_CODE);
|
|
|
|
@@ -149,15 +149,17 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
sysDictMapper.insert(currentSysType);
|
|
|
|
sysDictMapper.insert(currentSysType);
|
|
|
|
resources.setSystem_type(String.valueOf(currentType));
|
|
|
|
resources.setSystem_type(String.valueOf(currentType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateRootSystemType(SysMenu sysMenu) {
|
|
|
|
private void updateRootSystemType(SysMenu sysMenu) {
|
|
|
|
String rootMenuId = this.findRootMenuId(sysMenu.getMenu_id());
|
|
|
|
String rootMenuId = this.findRootMenuId(sysMenu.getMenu_id());
|
|
|
|
if (sysMenu.getMenu_id().equals(rootMenuId)){
|
|
|
|
if (sysMenu.getMenu_id().equals(rootMenuId)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SysMenu rootMenu = this.findById(rootMenuId);
|
|
|
|
SysMenu rootMenu = this.findById(rootMenuId);
|
|
|
|
sysMenu.setSystem_type(rootMenu.getSystem_type());
|
|
|
|
sysMenu.setSystem_type(rootMenu.getSystem_type());
|
|
|
|
this.updateById(sysMenu);
|
|
|
|
this.updateById(sysMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String findRootMenuId(String menuId) {
|
|
|
|
private String findRootMenuId(String menuId) {
|
|
|
|
SysMenu sysMenu = this.findById(menuId);
|
|
|
|
SysMenu sysMenu = this.findById(menuId);
|
|
|
|
if (StrUtil.isEmpty(sysMenu.getPid())) {
|
|
|
|
if (StrUtil.isEmpty(sysMenu.getPid())) {
|
|
|
|
@@ -176,12 +178,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
baseMapper.untiedMenu(menu.getMenu_id());
|
|
|
|
baseMapper.untiedMenu(menu.getMenu_id());
|
|
|
|
baseMapper.deleteById(menu.getMenu_id());
|
|
|
|
baseMapper.deleteById(menu.getMenu_id());
|
|
|
|
String pid = menu.getPid();
|
|
|
|
String pid = menu.getPid();
|
|
|
|
if (StringUtils.isEmpty(pid)){
|
|
|
|
if (StringUtils.isEmpty(pid)) {
|
|
|
|
pids.add(pid);
|
|
|
|
pids.add(pid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateSubCnt(pid);
|
|
|
|
updateSubCnt(pid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!CollectionUtils.isEmpty(pids)){
|
|
|
|
if (!CollectionUtils.isEmpty(pids)) {
|
|
|
|
sysDictMapper.delete(new QueryWrapper<Dict>().in("para1", pids).eq("code", DictConstantPool.DICT_SYS_CODE));
|
|
|
|
sysDictMapper.delete(new QueryWrapper<Dict>().in("para1", pids).eq("code", DictConstantPool.DICT_SYS_CODE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -193,8 +195,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
SysMenu menu = baseMapper.selectById(menuId);
|
|
|
|
SysMenu menu = baseMapper.selectById(menuId);
|
|
|
|
// 获取当前菜单的所有子菜单
|
|
|
|
// 获取当前菜单的所有子菜单
|
|
|
|
String allChild = baseMapper.findAllChild(menuId);
|
|
|
|
String allChild = baseMapper.findAllChild(menuId);
|
|
|
|
List<String> allChildIds = ObjectUtil.isNotEmpty(allChild)?Arrays.asList(allChild.split(",")):null;
|
|
|
|
List<String> allChildIds = ObjectUtil.isNotEmpty(allChild) ? Arrays.asList(allChild.split(",")) : null;
|
|
|
|
if (ObjectUtil.isNotEmpty(allChildIds) && allChildIds.contains(resources.getPid())){
|
|
|
|
if (ObjectUtil.isNotEmpty(allChildIds) && allChildIds.contains(resources.getPid())) {
|
|
|
|
throw new BadRequestException(LangProcess.msg("login_childError"));
|
|
|
|
throw new BadRequestException(LangProcess.msg("login_childError"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (resources.getIframe()) {
|
|
|
|
if (resources.getIframe()) {
|
|
|
|
@@ -206,17 +208,17 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
|
|
|
|
|
|
|
|
if (resources.getPid().equals("0")) {
|
|
|
|
if (resources.getPid().equals("0")) {
|
|
|
|
resources.setPid(null);
|
|
|
|
resources.setPid(null);
|
|
|
|
if (StringUtils.isNotEmpty(menu.getPid())){
|
|
|
|
if (StringUtils.isNotEmpty(menu.getPid())) {
|
|
|
|
addSystemTypeDict(resources);
|
|
|
|
addSystemTypeDict(resources);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
resources.setSystem_type(this.findById(resources.getPid()).getSystem_type());
|
|
|
|
resources.setSystem_type(this.findById(resources.getPid()).getSystem_type());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String oldPid = menu.getPid();
|
|
|
|
String oldPid = menu.getPid();
|
|
|
|
String newPid = resources.getPid();
|
|
|
|
String newPid = resources.getPid();
|
|
|
|
// 记录的父节点ID
|
|
|
|
// 记录的父节点ID
|
|
|
|
if (oldPid == null && newPid != null){
|
|
|
|
if (oldPid == null && newPid != null) {
|
|
|
|
sysDictMapper.delete(new QueryWrapper<Dict>().eq("para1",menu.getMenu_id()));
|
|
|
|
sysDictMapper.delete(new QueryWrapper<Dict>().eq("para1", menu.getMenu_id()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu.setTitle(resources.getTitle());
|
|
|
|
menu.setTitle(resources.getTitle());
|
|
|
|
menu.setComponent(resources.getComponent());
|
|
|
|
menu.setComponent(resources.getComponent());
|
|
|
|
@@ -238,8 +240,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
updateSubCnt(oldPid);
|
|
|
|
updateSubCnt(oldPid);
|
|
|
|
updateSubCnt(newPid);
|
|
|
|
updateSubCnt(newPid);
|
|
|
|
//更新SystemType
|
|
|
|
//更新SystemType
|
|
|
|
if (!resources.getSystem_type().equals(menu.getSystem_type())){
|
|
|
|
if (!resources.getSystem_type().equals(menu.getSystem_type())) {
|
|
|
|
this.update(new UpdateWrapper<SysMenu>().set(DictConstantPool.DICT_SYS_CODE,resources.getSystem_type()).in("menu_id",allChildIds));
|
|
|
|
this.update(new UpdateWrapper<SysMenu>().set(DictConstantPool.DICT_SYS_CODE, resources.getSystem_type()).in("menu_id", allChildIds));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -357,7 +359,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
public MenuDto doToDto(SysMenu entity) {
|
|
|
|
public MenuDto doToDto(SysMenu entity) {
|
|
|
|
|
|
|
|
|
|
|
|
MenuDto menuDto = new MenuDto();
|
|
|
|
MenuDto menuDto = new MenuDto();
|
|
|
|
if (ObjectUtil.isEmpty(entity)){
|
|
|
|
if (ObjectUtil.isEmpty(entity)) {
|
|
|
|
return menuDto;
|
|
|
|
return menuDto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menuDto.setEn_title(entity.getEn_title());
|
|
|
|
menuDto.setEn_title(entity.getEn_title());
|
|
|
|
@@ -395,15 +397,15 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<MenuVo> buildMenus(String systemType) {
|
|
|
|
public List<MenuVo> buildMenus(String systemType) {
|
|
|
|
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType));
|
|
|
|
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType));
|
|
|
|
if (dict == null || StringUtils.isEmpty(dict.getPara1())){
|
|
|
|
if (dict == null || StringUtils.isEmpty(dict.getPara1())) {
|
|
|
|
throw new BadRequestException(LangProcess.msg("error_isNull",DictConstantPool.DICT_SYS_CODE));
|
|
|
|
throw new BadRequestException(LangProcess.msg("error_isNull", DictConstantPool.DICT_SYS_CODE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String pid = dict.getPara1();
|
|
|
|
String pid = dict.getPara1();
|
|
|
|
List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(),systemType);
|
|
|
|
List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(), systemType);
|
|
|
|
//移除系统级菜单
|
|
|
|
//移除系统级菜单
|
|
|
|
menuDtoList.removeIf(a->a.getMenu_id().equals(pid));
|
|
|
|
menuDtoList.removeIf(a -> a.getMenu_id().equals(pid));
|
|
|
|
List<MenuDto> menuDtos = this.buildTree(CopyUtil.copyList(menuDtoList, MenuDto.class));
|
|
|
|
List<MenuDto> menuDtos = this.buildTree(CopyUtil.copyList(menuDtoList, MenuDto.class));
|
|
|
|
return this.buildMenus(menuDtos,pid);
|
|
|
|
return this.buildMenus(menuDtos, pid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@@ -417,7 +419,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
MenuVo menuVo = new MenuVo();
|
|
|
|
MenuVo menuVo = new MenuVo();
|
|
|
|
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getLocalTitle(lang));
|
|
|
|
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getLocalTitle(lang));
|
|
|
|
// 一级目录需要加斜杠,不然会报警告
|
|
|
|
// 一级目录需要加斜杠,不然会报警告
|
|
|
|
menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath());
|
|
|
|
menuVo.setPath(pid.equals(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
|
|
|
menuVo.setHidden(menuDTO.getHidden());
|
|
|
|
menuVo.setHidden(menuDTO.getHidden());
|
|
|
|
// 如果不是外链
|
|
|
|
// 如果不是外链
|
|
|
|
if (!menuDTO.getIframe()) {
|
|
|
|
if (!menuDTO.getIframe()) {
|
|
|
|
@@ -434,7 +436,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
if (menuDtoList != null && menuDtoList.size() != 0) {
|
|
|
|
if (menuDtoList != null && menuDtoList.size() != 0) {
|
|
|
|
menuVo.setAlwaysShow(true);
|
|
|
|
menuVo.setAlwaysShow(true);
|
|
|
|
menuVo.setRedirect("noredirect");
|
|
|
|
menuVo.setRedirect("noredirect");
|
|
|
|
menuVo.setChildren(buildMenus(menuDtoList,pid));
|
|
|
|
menuVo.setChildren(buildMenus(menuDtoList, pid));
|
|
|
|
// 处理是一级菜单并且没有子菜单的情况
|
|
|
|
// 处理是一级菜单并且没有子菜单的情况
|
|
|
|
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
|
|
|
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
|
|
|
MenuVo menuVo1 = new MenuVo();
|
|
|
|
MenuVo menuVo1 = new MenuVo();
|
|
|
|
@@ -463,7 +465,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Map> getMenusByRole(String roleId, String systemType, String category) {
|
|
|
|
public List<Map> getMenusByRole(String roleId, String systemType, String category) {
|
|
|
|
baseMapper.getMenusByRole(systemType,category);
|
|
|
|
baseMapper.getMenusByRole(systemType, category);
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -478,7 +480,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//查询一级
|
|
|
|
//查询一级
|
|
|
|
JSONArray pa = baseMapper.queryPdaAuthority(accountId, "0", null);
|
|
|
|
JSONArray pa = baseMapper.queryPdaAuthority(accountId, "0", null);
|
|
|
|
if(ObjectUtil.isEmpty(pa)){
|
|
|
|
if (ObjectUtil.isEmpty(pa)) {
|
|
|
|
throw new BadRequestException("当前用户无菜单权限!");
|
|
|
|
throw new BadRequestException("当前用户无菜单权限!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
@@ -496,7 +498,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|
|
|
roleTree.add(row);
|
|
|
|
roleTree.add(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res.put("sonTree", roleTree);
|
|
|
|
res.put("sonTree", roleTree);
|
|
|
|
result.put("rf_menu" + ("188".equals(res.getString("menu_id"))?1:0), res);
|
|
|
|
result.put("rf_menu" + ("188".equals(res.getString("menu_id")) ? 1 : 0), res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
returnjo.put("code", "1");
|
|
|
|
returnjo.put("code", "1");
|
|
|
|
|