xiaoyong931011
2022-06-07 7fa0a141a3c88ca90c67c966260bf26f03f255da
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java
@@ -13,10 +13,12 @@
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.UserEntity;
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;
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 lombok.extern.slf4j.Slf4j;
@@ -41,8 +43,10 @@
    @Override
    public Result getMenuInPage(AdminMenuDto adminMenuDto) {
        Page<AdminMenuVo> page = new Page<>(adminMenuDto.getPageNum(), adminMenuDto.getPageSize());
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        MenuEntity menuEntity = new MenuEntity();
        menuEntity.setParentId(MenuEntity.PARENTID_DEFAULT);
        menuEntity.setBelongId(userlogin.getBelongId()==null?0L:userlogin.getBelongId());
        IPage<AdminMenuVo> list = this.baseMapper.selectAdminMenuVoInPage(page,menuEntity);
        List<AdminMenuVo> records = list.getRecords();
        if(CollUtil.isNotEmpty(records)){
@@ -73,6 +77,8 @@
    @Override
    @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("请输入菜单名称");
@@ -98,6 +104,7 @@
        if(StrUtil.isNotEmpty(routeUrl)){
            menuEntity.setRouteUrl(routeUrl);
        }
        menuEntity.setBelongId(belongId);
        this.baseMapper.insert(menuEntity);
        return Result.ok("新增成功");
    }
@@ -194,12 +201,15 @@
    @Override
    public Result getMenuInList() {
        List<AdminMenuVo> records = this.baseMapper.selectAdminMenuVoInListByParentId(MenuEntity.PARENTID_DEFAULT);
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        long belongId = userlogin.getBelongId() == null ? 0L : userlogin.getBelongId();
        List<AdminMenuVo> records = this.baseMapper.selectAdminMenuVoInListByParentId(MenuEntity.PARENTID_DEFAULT,belongId);
        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)){