| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xcong.farmer.cms.common.response.Result; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminAddMenuDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminMenuDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminUpdateMenuDto; |
| | | import com.xcong.farmer.cms.modules.system.entity.MenuEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.RoleMenuEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.UserRoleEntity; |
| | | import com.xcong.farmer.cms.modules.system.mapper.MenuMapper; |
| | | import com.xcong.farmer.cms.modules.system.mapper.RoleMenuMapper; |
| | | import com.xcong.farmer.cms.modules.system.service.IMenuService; |
| | |
| | | menuEntity.setParentId(MenuEntity.PARENTID_DEFAULT); |
| | | IPage<AdminMenuVo> list = this.baseMapper.selectAdminMenuVoInPage(page,menuEntity); |
| | | List<AdminMenuVo> records = list.getRecords(); |
| | | list.getTotal(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(AdminMenuVo adminMenuVo : records){ |
| | | Long id = adminMenuVo.getId(); |
| | |
| | | this.baseMapper.updateById(menuEntity); |
| | | return Result.ok("更新成功"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result delObjs(AdminDeleteDto adminDeleteDto) { |
| | | String ids = adminDeleteDto.getIds(); |
| | | if(StrUtil.isNotEmpty(ids)){ |
| | | String[] menuIds = ids.split(StringPool.COMMA); |
| | | for(String menuIdStr : menuIds){ |
| | | Long menuId = Long.valueOf(menuIdStr); |
| | | QueryWrapper<MenuEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("parent_id",menuId); |
| | | this.baseMapper.delete(objectQueryWrapper); |
| | | |
| | | this.baseMapper.deleteById(menuId); |
| | | |
| | | roleMenuMapper.deleteByMenuId(menuId); |
| | | } |
| | | } |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result getMenuInList() { |
| | | 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); |
| | | List<MenuEntity> menuEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | | List<AdminMenuVo> adminMenuVoChilds = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(menuEntities)){ |
| | | for(MenuEntity menuEntityChild : menuEntities){ |
| | | AdminMenuVo child = new AdminMenuVo(); |
| | | child.setId(menuEntityChild.getId()); |
| | | child.setMenuName(menuEntityChild.getMenuName()); |
| | | child.setMenuType(menuEntityChild.getMenuType()); |
| | | child.setRouteUrl(menuEntityChild.getRouteUrl()); |
| | | child.setOrderNum(menuEntityChild.getOrderNum()); |
| | | child.setCreateTime(menuEntityChild.getCreateTime()); |
| | | adminMenuVoChilds.add(child); |
| | | } |
| | | } |
| | | adminMenuVo.setChild(adminMenuVoChilds); |
| | | } |
| | | } |
| | | return Result.ok(records); |
| | | } |
| | | } |