From 1facfdc9361d888d72c959bac4d8fb05dcad02d7 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Thu, 07 Jul 2022 18:27:06 +0800 Subject: [PATCH] Merge branch 'master' of http://120.27.238.55:7000/r/farmer-cms --- src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java | 36 ++++++++++++++++++------------------ 1 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java index 044e6da..fcc7874 100644 --- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java +++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java @@ -21,6 +21,7 @@ import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; import com.xcong.farmer.cms.modules.system.vo.AdminMenuVo; import com.xcong.farmer.cms.modules.system.vo.AdminSeeMenuInfoVo; +import com.xcong.farmer.cms.modules.system.vo.AdminUserMenuVo; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -46,7 +47,7 @@ UserEntity userlogin = LoginUserUtil.getLoginUser(); MenuEntity menuEntity = new MenuEntity(); menuEntity.setParentId(MenuEntity.PARENTID_DEFAULT); - menuEntity.setBelongId(userlogin.getBelongId()==null?0L:userlogin.getBelongId()); +// menuEntity.setBelongId(userlogin.getBelongId()==null?UserEntity.USER_BELONG_TOP:userlogin.getBelongId()); IPage<AdminMenuVo> list = this.baseMapper.selectAdminMenuVoInPage(page,menuEntity); List<AdminMenuVo> records = list.getRecords(); if(CollUtil.isNotEmpty(records)){ @@ -78,15 +79,8 @@ @Transactional public Result addMenu(AdminAddMenuDto adminAddMenuDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); - long belongId = userlogin.getBelongId() == null ? 0L : userlogin.getBelongId(); String menuName = adminAddMenuDto.getMenuName(); - if(StrUtil.isEmpty(menuName)){ - return Result.fail("请输入菜单名称"); - } Integer menuType = adminAddMenuDto.getMenuType(); - if(ObjectUtil.isEmpty(menuType)){ - return Result.fail("请输入菜单类型"); - } MenuEntity menuEntity = new MenuEntity(); menuEntity.setMenuName(menuName); menuEntity.setMenuType(menuType); @@ -104,7 +98,6 @@ if(StrUtil.isNotEmpty(routeUrl)){ menuEntity.setRouteUrl(routeUrl); } - menuEntity.setBelongId(belongId); this.baseMapper.insert(menuEntity); return Result.ok("新增成功"); } @@ -152,14 +145,8 @@ return Result.fail("菜单不存在"); } String menuName = adminUpdateMenuDto.getMenuName(); - if(StrUtil.isEmpty(menuName)){ - return Result.fail("请输入菜单名称"); - } menuEntity.setMenuName(menuName); Integer menuType = adminUpdateMenuDto.getMenuType(); - if(ObjectUtil.isEmpty(menuType)){ - return Result.fail("请输入菜单类型"); - } menuEntity.setMenuType(menuType); String routeUrl = adminUpdateMenuDto.getRouteUrl(); if(StrUtil.isNotEmpty(routeUrl)){ @@ -202,14 +189,12 @@ @Override public Result getMenuInList() { UserEntity userlogin = LoginUserUtil.getLoginUser(); - long belongId = userlogin.getBelongId() == null ? 0L : userlogin.getBelongId(); - List<AdminMenuVo> records = this.baseMapper.selectAdminMenuVoInListByParentId(MenuEntity.PARENTID_DEFAULT,belongId); + List<AdminMenuVo> records = this.baseMapper.selectAdminMenuVoInListByParentId(MenuEntity.PARENTID_DEFAULT); if(CollUtil.isNotEmpty(records)){ for(AdminMenuVo adminMenuVo : records){ Long id = adminMenuVo.getId(); QueryWrapper<MenuEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("parent_id",id); - objectQueryWrapper.eq("belong_id",belongId); List<MenuEntity> menuEntities = this.baseMapper.selectList(objectQueryWrapper); List<AdminMenuVo> adminMenuVoChilds = new ArrayList<>(); if(CollUtil.isNotEmpty(menuEntities)){ @@ -227,6 +212,21 @@ adminMenuVo.setChild(adminMenuVoChilds); } } + + if(CollUtil.isNotEmpty(records)){ + for(AdminMenuVo adminMenuVo : records){ + List<AdminMenuVo> child = adminMenuVo.getChild(); + if(CollUtil.isNotEmpty(child)){ + List<Long> menuIds = new ArrayList<>(); + for(AdminMenuVo adminMenuVoChild : child){ + Long id = adminMenuVoChild.getId(); + menuIds.add(id); + } + List<AdminMenuVo> adminMenuVoByOrderNum = this.baseMapper.selectAdminMenuVoOrderByOrderNum(menuIds); + adminMenuVo.setChild(adminMenuVoByOrderNum); + } + } + } return Result.ok(records); } } -- Gitblit v1.9.1