fix:修改iFrame字段为iframe,iFrame偶尔导致@setting注解读取失败问题
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package org.nl.common.domain.constant;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/26 9:29 上午
|
||||
*/
|
||||
public class DictConstantPool {
|
||||
|
||||
public static final String DICT_SYS_CODE = "system_type";
|
||||
public static final String DICT_SYS_NAME = "所属系统";
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
menuDto.setIcon(json.getString("icon"));
|
||||
|
||||
menuDto.setSubCount(json.getInteger("sub_count"));
|
||||
menuDto.setIFrame("1".equals(json.getString("i_frame")));
|
||||
menuDto.setIframe("1".equals(json.getString("i_frame")));
|
||||
menuDto.setCache("1".equals(json.getString("cache")));
|
||||
menuDto.setHidden("1".equals(json.getString("hidden")));
|
||||
menuDto.setComponentName(json.getString("component_name"));
|
||||
@@ -197,7 +197,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
throw new BadRequestException("上级不能为自己");
|
||||
}
|
||||
|
||||
if (newMenu.getIFrame()) {
|
||||
if (newMenu.getIframe()) {
|
||||
String http = "http://", https = "https://";
|
||||
if (!(newMenu.getPath().toLowerCase().startsWith(http) || newMenu.getPath().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链必须以http://或者https://开头");
|
||||
@@ -326,7 +326,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
menuVo.setPath(ObjectUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (!menuDTO.getIframe()) {
|
||||
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||
@@ -346,7 +346,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (!menuDTO.getIframe()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
|
||||
@@ -97,7 +97,7 @@ public class SysMenuController {
|
||||
@ApiOperation("新增菜单")
|
||||
@PostMapping
|
||||
@SaCheckPermission("menu:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysMenu form) {
|
||||
public ResponseEntity<Object> create(@RequestBody SysMenu form) {
|
||||
iSysMenuService.create(form);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class SysMenu implements Serializable {
|
||||
/**
|
||||
* 是否外链
|
||||
*/
|
||||
private Boolean iFrame;
|
||||
private Boolean iframe;
|
||||
|
||||
/**
|
||||
* 是否缓存
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MenuDto extends BaseDTO implements Serializable {
|
||||
|
||||
private Integer subCount;
|
||||
|
||||
private Boolean iFrame;
|
||||
private Boolean iframe;
|
||||
|
||||
|
||||
private Boolean cache;
|
||||
|
||||
@@ -6,9 +6,11 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.constant.DictConstantPool;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
@@ -21,7 +23,6 @@ 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.dao.SysMenu;
|
||||
import org.nl.system.service.menu.dto.MenuQuery;
|
||||
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -41,6 +42,7 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
|
||||
|
||||
private final SysMenuMapper baseMapper;
|
||||
private final SysDictMapper sysDictMapper;
|
||||
|
||||
@@ -107,16 +109,19 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void create(SysMenu resources) {
|
||||
if (resources.getPid().equals("0")) {
|
||||
resources.setPid(null);
|
||||
}
|
||||
if (resources.getIFrame()) {
|
||||
|
||||
if (resources.getIframe()) {
|
||||
String http = "http://", https = "https://";
|
||||
if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链必须以http://或者https://开头");
|
||||
}
|
||||
}
|
||||
resources.setMenuId(IdUtil.getStringId());
|
||||
if (resources.getPid().equals("0")) {
|
||||
resources.setPid(null);
|
||||
addSystemTypeDict(resources);
|
||||
}
|
||||
updateRootSystemType(resources);
|
||||
baseMapper.insert(resources);
|
||||
// 计算子节点数目
|
||||
resources.setSubCount(0);
|
||||
@@ -124,15 +129,52 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
updateSubCnt(resources.getPid());
|
||||
}
|
||||
|
||||
private void addSystemTypeDict(SysMenu resources) {
|
||||
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;
|
||||
Dict currentSysType = new Dict();
|
||||
currentSysType.setDictId(IdUtil.getStringId());
|
||||
currentSysType.setCode(DictConstantPool.DICT_SYS_CODE);
|
||||
currentSysType.setName(DictConstantPool.DICT_SYS_NAME);
|
||||
currentSysType.setLabel(resources.getTitle());
|
||||
currentSysType.setValue(String.valueOf(currentType));
|
||||
currentSysType.setPara1(resources.getMenuId());
|
||||
sysDictMapper.insert(currentSysType);
|
||||
resources.setSystemType(String.valueOf(currentType));
|
||||
}
|
||||
private void updateRootSystemType(SysMenu sysMenu) {
|
||||
String rootMenuId = this.findRootMenuId(sysMenu.getMenuId());
|
||||
if (sysMenu.getMenuId().equals(rootMenuId)){
|
||||
return;
|
||||
}
|
||||
SysMenu rootMenu = this.findById(rootMenuId);
|
||||
sysMenu.setSystemType(rootMenu.getSystemType());
|
||||
}
|
||||
private String findRootMenuId(String menuId) {
|
||||
SysMenu sysMenu = this.findById(menuId);
|
||||
String pid = sysMenu.getPid();
|
||||
if (StrUtil.isEmpty(pid)) {
|
||||
return menuId;
|
||||
} else {
|
||||
return findRootMenuId(pid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<SysMenu> menuSet) {
|
||||
List<String> pids = Lists.newArrayList();
|
||||
for (SysMenu menu : menuSet) {
|
||||
//解绑菜单
|
||||
baseMapper.untiedMenu(menu.getMenuId());
|
||||
baseMapper.deleteById(menu.getMenuId());
|
||||
updateSubCnt(menu.getPid());
|
||||
String pid = menu.getPid();
|
||||
if (StringUtils.isNotEmpty(pid)){
|
||||
pids.add(pid);
|
||||
}
|
||||
updateSubCnt(pid);
|
||||
}
|
||||
sysDictMapper.delete(new QueryWrapper<Dict>().in("para1", pids).eq("code", DictConstantPool.DICT_SYS_CODE));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -142,7 +184,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
throw new BadRequestException("上级不能为自己");
|
||||
}
|
||||
SysMenu menu = baseMapper.selectById(resources.getMenuId());
|
||||
if (resources.getIFrame()) {
|
||||
if (resources.getIframe()) {
|
||||
String http = "http://", https = "https://";
|
||||
if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链必须以http://或者https://开头");
|
||||
@@ -150,6 +192,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
}
|
||||
if (resources.getPid().equals("0")) {
|
||||
resources.setPid(null);
|
||||
addSystemTypeDict(resources);
|
||||
}
|
||||
|
||||
// 记录的父节点ID
|
||||
@@ -159,7 +202,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
menu.setComponent(resources.getComponent());
|
||||
menu.setPath(resources.getPath());
|
||||
menu.setIcon(resources.getIcon());
|
||||
menu.setIFrame(resources.getIFrame());
|
||||
menu.setIframe(resources.getIframe());
|
||||
menu.setPid(resources.getPid());
|
||||
menu.setMenuSort(resources.getMenuSort());
|
||||
menu.setCache(resources.getCache());
|
||||
@@ -205,7 +248,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
menuVo.setPath(ObjectUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (!menuDTO.getIframe()) {
|
||||
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||
@@ -225,7 +268,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (!menuDTO.getIframe()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
@@ -297,7 +340,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
menuDto.setComponent(entity.getComponent());
|
||||
menuDto.setPid(entity.getPid());
|
||||
menuDto.setSubCount(entity.getSubCount());
|
||||
menuDto.setIFrame(entity.getIFrame());
|
||||
menuDto.setIframe(entity.getIframe());
|
||||
menuDto.setCache(entity.getCache());
|
||||
menuDto.setHidden(entity.getHidden());
|
||||
menuDto.setComponentName(entity.getComponentName());
|
||||
@@ -317,7 +360,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
@Override
|
||||
public List<MenuVo> buildMenus(String systemType) {
|
||||
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", "system_type").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())){
|
||||
throw new BadRequestException("获取对应的系统菜单不存在");
|
||||
}
|
||||
@@ -342,7 +385,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (!menuDTO.getIframe()) {
|
||||
if (pid.equals(menuDTO.getPid())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||
} else if (!pid.equals(menuDTO.getPid()) && "0".equals(menuDTO.getType())) {
|
||||
@@ -362,7 +405,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (!menuDTO.getIframe()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
@keyup.enter.native="queryBlurry"
|
||||
/>
|
||||
<el-select
|
||||
v-model="query.system_type"
|
||||
v-model="query.systemType"
|
||||
style="width: 100px; height: 35px;top: -5px;"
|
||||
placeholder="切换系统"
|
||||
@change="changetype"
|
||||
@@ -67,10 +67,10 @@
|
||||
</el-input>
|
||||
</el-popover>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1'" label="外链菜单" prop="i_frame">
|
||||
<el-radio-group v-model="form.i_frame" size="mini">
|
||||
<el-radio-button label="1">是</el-radio-button>
|
||||
<el-radio-button label="0">否</el-radio-button>
|
||||
<el-form-item v-show="form.type.toString() !== '2' && form.type.toString() !== '1'" label="外链菜单" prop="iframe">
|
||||
<el-radio-group v-model="form.iframe" size="mini">
|
||||
<el-radio-button label="true">是</el-radio-button>
|
||||
<el-radio-button label="false">否</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="form.type.toString() === '2'" label="菜单缓存" prop="cache">
|
||||
@@ -96,7 +96,7 @@
|
||||
<el-input v-model="form.title" placeholder="按钮名称" style="width: 190px;" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="form.type.toString() !== '1' " label="权限标识" prop="permission">
|
||||
<el-input v-model="form.permission" :disabled="form.i_frame=='1'" placeholder="权限标识" style="width: 190px;" />
|
||||
<el-input v-model="form.permission" :disabled="form.iframe" placeholder="权限标识" style="width: 190px;" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type.toString() !== '1' && form.type.toString() !== '2'" label="路由地址" prop="path">
|
||||
<el-input v-model="form.path" placeholder="路由地址" style="width: 190px;" />
|
||||
@@ -110,10 +110,10 @@
|
||||
style="width: 190px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="!form.i_frame && form.type.toString() === '3' " label="组件名称" prop="componentName">
|
||||
<el-form-item v-show="!form.iframe && form.type.toString() === '3' " label="组件名称" prop="componentName">
|
||||
<el-input v-model="form.componentName" style="width: 190px;" placeholder="匹配组件内Name字段" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="!form.i_frame && (form.type.toString() === '2' ||form.type.toString() === '3' ) " label="组件路径" prop="component">
|
||||
<el-form-item v-show="!form.iframe && (form.type.toString() === '2' ||form.type.toString() === '3' ) " label="组件路径" prop="component">
|
||||
<el-input v-model="form.component" style="width: 190px;" placeholder="组件路径" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级类目" prop="pid">
|
||||
@@ -150,9 +150,9 @@
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="菜单标题" prop="title" :min-width="100" />
|
||||
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')">
|
||||
<el-table-column label="子系统" prop="systemType" :min-width="flexWidth('systemType',crud.data,'子系统')">
|
||||
<template slot-scope="scope">
|
||||
{{ dict.label.system_type[scope.row.system_type] }}
|
||||
{{ dict.label.system_type[scope.row.systemType] }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
|
||||
@@ -167,9 +167,9 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="permission" label="权限标识" :min-width="flexWidth('permission',crud.data,'权限标识')" />
|
||||
<el-table-column prop="component" label="组件路径" min-width="120" />
|
||||
<el-table-column prop="i_frame" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('i_frame',crud.data,'外链')">
|
||||
<el-table-column prop="iframe" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('iframe',crud.data,'外链')">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.i_frame">是</span>
|
||||
<span v-if="scope.row.iframe">是</span>
|
||||
<span v-else>否</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -220,15 +220,15 @@ import Dict from '../../../components/Dict/Dict'
|
||||
|
||||
// crud交由presenter持有
|
||||
const defaultForm = {
|
||||
menu_id: null,
|
||||
menuId: null,
|
||||
title: null,
|
||||
menuSort: 999,
|
||||
path: null,
|
||||
system_type: null,
|
||||
systemType: null,
|
||||
category: null,
|
||||
component: null,
|
||||
componentName: null,
|
||||
i_frame: 0,
|
||||
iframe: false,
|
||||
roles: [],
|
||||
pid: 0,
|
||||
icon: null,
|
||||
@@ -280,7 +280,7 @@ export default {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
changetype() {
|
||||
const sysType = this.dict.dict.system_type[this.query.system_type]
|
||||
const sysType = this.dict.dict.system_type[this.query.systemType]
|
||||
this.query.pid = sysType.para1
|
||||
this.crud.toQuery()
|
||||
},
|
||||
@@ -329,8 +329,8 @@ export default {
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
getSupMenus(menu_id) {
|
||||
crudMenu.getMenuSuperior(menu_id).then(res => {
|
||||
getSupMenus(menuId) {
|
||||
crudMenu.getMenuSuperior(menuId).then(res => {
|
||||
const children = res.map(function(obj) {
|
||||
if (!obj.leaf && !obj.children) {
|
||||
obj.children = null
|
||||
|
||||
Reference in New Issue
Block a user