| | |
| | | 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; |
| | | |
| | |
| | | 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)){ |
| | |
| | | @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); |
| | |
| | | if(StrUtil.isNotEmpty(routeUrl)){ |
| | | menuEntity.setRouteUrl(routeUrl); |
| | | } |
| | | menuEntity.setBelongId(belongId); |
| | | this.baseMapper.insert(menuEntity); |
| | | return Result.ok("新增成功"); |
| | | } |
| | |
| | | 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)){ |
| | |
| | | @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)){ |
| | |
| | | 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); |
| | | } |
| | | } |