Merge branch 'main' of http://121.37.111.42:3000/ThbTech/gis-bi
This commit is contained in:
commit
ebf6adbcda
@ -15,7 +15,6 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 应用_系统模块 前端控制器
|
||||
@ -36,8 +35,8 @@ public class ModuleController {
|
||||
@GetMapping("/list")
|
||||
public ResponseResult page(@RequestParam String appId) {
|
||||
QueryWrapper<Module> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("app_id",appId);
|
||||
wrapper.orderByAsc("pid","sort"); // 按编码倒序排列
|
||||
wrapper.eq("app_id", appId);
|
||||
wrapper.orderByAsc("pid", "sort"); // 按编码倒序排列
|
||||
List<Map<String, Object>> list = moduleService.listMaps(wrapper);
|
||||
return ResponseResult.successData(list);
|
||||
}
|
||||
@ -64,6 +63,7 @@ public class ModuleController {
|
||||
try {
|
||||
Module module = BeanUtil.toBean(moduleMap, Module.class);
|
||||
module.setId(null);
|
||||
module.setName(module.getName() + "(复制)");
|
||||
module.setCreateTime(LocalDateTime.now());
|
||||
module.setCreateBy(AuthUtils.getUser().getUserId().toString());
|
||||
|
||||
@ -78,7 +78,6 @@ public class ModuleController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 修改模块
|
||||
@PostMapping("/update")
|
||||
public ResponseResult update(@RequestBody Module module) {
|
||||
@ -94,7 +93,7 @@ public class ModuleController {
|
||||
// 获取模块详情
|
||||
@GetMapping("/{id}")
|
||||
public ResponseResult getById(@PathVariable String id) {
|
||||
Map<String, Object> moduleMap=null;
|
||||
Map<String, Object> moduleMap = null;
|
||||
try {
|
||||
LambdaQueryWrapper<Module> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Module::getId, id);
|
||||
@ -107,8 +106,8 @@ public class ModuleController {
|
||||
|
||||
// 新增:根据pid判断是否有子节点
|
||||
@GetMapping("/checkHasChildren")
|
||||
public boolean checkHasChildren(@RequestParam String appId,@RequestParam String pid) {
|
||||
boolean hasChildren = moduleService.existsChildrenByPid(appId,pid);
|
||||
public boolean checkHasChildren(@RequestParam String appId, @RequestParam String pid) {
|
||||
boolean hasChildren = moduleService.existsChildrenByPid(appId, pid);
|
||||
return hasChildren;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,19 @@ public class MenuController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上移/下移菜单
|
||||
*/
|
||||
@PostMapping("/changeOrder")
|
||||
public ResponseResult changeOrder(@RequestParam String menuId, @RequestParam String direction) {
|
||||
boolean result = menuService.changeOrder(menuId, direction);
|
||||
if (result) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:修改菜单及按钮根据ID
|
||||
* 参数说明
|
||||
|
@ -49,4 +49,7 @@ public interface IMenuService extends IService<Menu> {
|
||||
* 返回值说明: 菜单结构树集合
|
||||
***********************************/
|
||||
List<Map<String, Object>> permissionAssignment(String appId ,String roleId);
|
||||
|
||||
boolean changeOrder(String menuId, String direction);
|
||||
|
||||
}
|
||||
|
@ -214,6 +214,56 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
||||
return listTree;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeOrder(String menuId, String direction) {
|
||||
Menu currentMenu = menuMapper.selectById(menuId);
|
||||
if (currentMenu == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String parentId = currentMenu.getParentid();
|
||||
|
||||
QueryWrapper<Menu> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("parentid", parentId);
|
||||
wrapper.orderByAsc("orderno");
|
||||
|
||||
List<Menu> siblings = menuMapper.selectList(wrapper);
|
||||
|
||||
int index = -1;
|
||||
for (int i = 0; i < siblings.size(); i++) {
|
||||
if (siblings.get(i).getId().equals(menuId)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ("up".equals(direction)) {
|
||||
if (index > 0) {
|
||||
swapOrder(siblings.get(index), siblings.get(index - 1));
|
||||
} else {
|
||||
return false; // 已是第一个,无法上移
|
||||
}
|
||||
} else if ("down".equals(direction)) {
|
||||
if (index < siblings.size() - 1) {
|
||||
swapOrder(siblings.get(index), siblings.get(index + 1));
|
||||
} else {
|
||||
return false; // 已是最后一个,无法下移
|
||||
}
|
||||
} else {
|
||||
return false; // 方向错误
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void swapOrder(Menu m1, Menu m2) {
|
||||
Integer temp = m1.getOrderno();
|
||||
m1.setOrderno(m2.getOrderno());
|
||||
m2.setOrderno(temp);
|
||||
|
||||
menuMapper.updateById(m1);
|
||||
menuMapper.updateById(m2);
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 生成权菜单权限树
|
||||
* 参数说明 sysMenus
|
||||
|
Loading…
Reference in New Issue
Block a user