Commit 2cfc456d authored by 赵啸非's avatar 赵啸非

菜单列表添加多级展示

parent cc1a6c0d
......@@ -1147,6 +1147,9 @@ data|object|数据对象
  status|Integer|菜单状态(0.禁用,1.启用)
  authType|Integer|权限类型(0.无限制,1.无需登录查看,2.需要登录查看,3.需要角色权限查看)
  orderId|Integer|排序编号
  firstLevel|String|一级菜单
  secondLevel|String|二级菜单
  thirdLevel|String|三级菜单
  createTime|Date|创建时间
  createUserId|Long|创建用户
  createUserName|String|创建用户名称
......@@ -1162,6 +1165,124 @@ dict|object|字典对象
{
"code":1,
"data":{
"per_page":10,
"total":4,
"data":[
{
"authType":0,
"childList":[
],
"firstLevel":"数据管理",
"id":1,
"linkType":0,
"menuType":0,
"name":"数据管理",
"orderId":1,
"parentId":-1,
"secondLevel":"",
"status":1,
"thirdLevel":"",
"visible":1
},
{
"authType":3,
"buttonImgPath":"vcr5tv",
"childList":[
],
"createTime":1654150239000,
"createUserId":1,
"createUserName":"系统管理员",
"firstLevel":"测试菜单2",
"id":4,
"imgCommPath":"qnglei",
"imgPath":"7mqw6a",
"linkType":0,
"menuType":0,
"name":"测试菜单2",
"orderId":2,
"parentId":-1,
"secondLevel":"",
"status":1,
"thirdLevel":"",
"url":"",
"visible":1
},
{
"authType":1,
"childList":[
],
"firstLevel":"数据管理",
"id":2,
"linkType":0,
"menuType":0,
"name":"聚集服务",
"orderId":2,
"parentId":1,
"secondLevel":"聚集服务",
"status":1,
"thirdLevel":"",
"visible":1
},
{
"authType":1,
"childList":[
],
"firstLevel":"数据管理",
"id":3,
"linkType":1,
"menuType":2,
"name":"排号系统",
"orderId":3,
"parentId":2,
"secondLevel":"聚集服务",
"status":1,
"thirdLevel":"排号系统",
"url":"http://www.baidu.com",
"visible":1
}
],
"last_page":1,
"pageInfo":{
"beginIndex":0,
"countPage":true,
"currPage":1,
"displayPageSize":5,
"hasNextPage":false,
"hasPrePage":false,
"prePageResult":10,
"totalPage":1,
"totalResult":4
},
"current_page":1
},
"dict":{
"commMenu":{
"0":"非常用",
"1":"常用"
},
"linkType":{
"0":"内链",
"1":"外链",
"2":"脚本"
},
"menuType":{
"0":"主菜单",
"1":"非主菜单"
},
"authType":{
"0":"无限制",
"1":"无需登录查看",
"2":"需要登录查看",
"3":"需要角色权限查看"
},
"status":{
"0":"禁用",
"1":"启用"
}
}
}
```
......
......@@ -8,9 +8,9 @@ import java.util.Map;
public enum MenuLinkType implements IBaseEnum{
/** 普通 */
NORMAL(0, "普通", SysConstains.STYLE_DEFAULT),
NORMAL(0, "内链", SysConstains.STYLE_DEFAULT),
/** 弹出 */
POP(1, "弹出", SysConstains.STYLE_DEFAULT),
POP(1, "外链", SysConstains.STYLE_DEFAULT),
/** 脚本(JavaScript) */
SCRIPT(2, "脚本", SysConstains.STYLE_DEFAULT);
......
......@@ -14,5 +14,17 @@ import java.util.List;
@Data
public class MenuVo extends BaseEntityLong {
private List<MenuEntity> childList = new ArrayList<>();
/**
* 一级菜单
*/
private String firstLevel;
/**
* 二级菜单
*/
private String secondLevel;
/**
* 三级菜单
*/
private String thirdLevel;
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.mortals.framework.common.code.YesNo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.code.YesNoEnum;
......@@ -13,6 +14,7 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.menu.dao.MenuDao;
import com.mortals.xhx.module.menu.model.MenuEntity;
import com.mortals.xhx.module.menu.service.MenuService;
import org.springframework.util.ObjectUtils;
import java.util.*;
......@@ -25,6 +27,46 @@ import java.util.*;
*/
@Service("menuService")
public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity, Long> implements MenuService {
@Override
protected void findAfter(MenuEntity params, PageInfo pageInfo, Context context, List<MenuEntity> list) throws AppException {
//查询当前目录等级
list.stream().forEach(item -> {
HashMap<Integer, MenuEntity> map = new HashMap<>();
int count = 1;
buildMenuMap(context, item, map, count);
if (map.size() == 0) {
//当前菜单为顶级
item.setFirstLevel(item.getName());
item.setSecondLevel("");
item.setThirdLevel("");
} else if (map.size() == 1) {
item.setFirstLevel(map.get(1).getName());
item.setSecondLevel(item.getName());
item.setThirdLevel("");
} else if (map.size() == 2) {
item.setFirstLevel(map.get(2).getName());
item.setSecondLevel(map.get(1).getName());
item.setThirdLevel(item.getName());
} else {
}
});
super.findAfter(params, pageInfo, context, list);
}
private Map<Integer, MenuEntity> buildMenuMap(Context context, MenuEntity item, Map<Integer, MenuEntity> map, int count) {
if (!ObjectUtils.isEmpty(item.getParentId())) {
MenuEntity menuEntity = this.get(item.getParentId(), context);
if (!ObjectUtils.isEmpty(menuEntity)) {
map.put(count, menuEntity);
count++;
return buildMenuMap(context, menuEntity, map, count);
}
}
return map;
}
@Override
public List<MenuEntity> findAllEnable() throws AppException {
MenuQuery query = new MenuQuery();
......@@ -52,7 +94,6 @@ public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity
}
@Override
public void upOrDown(Long id, Integer type) {
MenuQuery query = new MenuQuery();
......
......@@ -56,8 +56,6 @@ public class MenuController extends BaseCRUDJsonBodyMappingController<MenuServic
orderColList.add(new OrderCol("parentId"));
orderColList.add(new OrderCol("orderId"));
query.setOrderColList(orderColList);
super.doListBefore(query, model, context);
}
......
......@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
*
* 角色资源权限业务
* 角色菜单权限业务
*
* @author zxfei
* @date 2022-05-25
......@@ -38,7 +38,7 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
}
/**
* 分配资源
* 分配菜单
*/
@PostMapping(value = "distributionSource")
public String distributionUser(@RequestBody RoleAuthQuery query) {
......
......@@ -16,9 +16,9 @@ Authorization: {{authToken}}
Content-Type: application/json
{
"name":"bbq6ku",
"url":"jadu3f",
"parentId":629,
"name":"测试菜单2",
"url":"",
"parentId":-1,
"linkType":0,
"imgPath":"7mqw6a",
"buttonImgPath":"vcr5tv",
......@@ -40,11 +40,6 @@ GET {{baseUrl}}/menu/info?id={{Menu_id}}
Authorization: {{authToken}}
Accept: application/json
###菜单信息业务编辑
GET {{baseUrl}}/menu/edit?id={{Menu_id}}
Authorization: {{authToken}}
Accept: application/json
###菜单信息业务删除
GET {{baseUrl}}/menu/delete?id={{Menu_id}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment