|
|
@@ -1,284 +1,216 @@
|
|
|
package shop.alien.storeplatform.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import shop.alien.entity.result.R;
|
|
|
-import shop.alien.entity.store.LifeGroupBuyThali;
|
|
|
-import shop.alien.entity.store.LifeLikeRecord;
|
|
|
-import shop.alien.entity.store.StoreImg;
|
|
|
-import shop.alien.entity.store.StoreMenu;
|
|
|
-import shop.alien.entity.store.vo.StoreMenuVo;
|
|
|
-import shop.alien.mapper.LifeGroupBuyThaliMapper;
|
|
|
-import shop.alien.mapper.LifeLikeRecordMapper;
|
|
|
-import shop.alien.mapper.StoreMenuMapper;
|
|
|
-import shop.alien.storeplatform.service.StorePlatformImgService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+import shop.alien.entity.store.StorePlatformMenu;
|
|
|
+import shop.alien.mapper.StorePlatformMenuMapper;
|
|
|
import shop.alien.storeplatform.service.StorePlatformMenuService;
|
|
|
|
|
|
-import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
- * 二期-门店推荐 服务实现类
|
|
|
+ * 商家PC菜单权限表 服务实现类
|
|
|
*
|
|
|
- * @author ssk
|
|
|
- * @since 2024-12-05
|
|
|
+ * @author system
|
|
|
+ * @since 2025-01-XX
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
-public class StorePlatformMenuServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu> implements StorePlatformMenuService {
|
|
|
+@Transactional
|
|
|
+public class StorePlatformMenuServiceImpl extends ServiceImpl<StorePlatformMenuMapper, StorePlatformMenu> implements StorePlatformMenuService {
|
|
|
|
|
|
- private final StoreMenuMapper storeMenuMapper;
|
|
|
+ private final StorePlatformMenuMapper storePlatformMenuMapper;
|
|
|
|
|
|
- private final LifeLikeRecordMapper lifeLikeRecordMapper;
|
|
|
-
|
|
|
- private final StorePlatformImgService storeImgService;
|
|
|
-
|
|
|
- private final LifeGroupBuyThaliMapper lifeGroupBuyThaliMapper;
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取门店菜单
|
|
|
- *
|
|
|
- * @param storeId 门店id
|
|
|
- * @param dishType 菜品类型, 0:菜单, 1:推荐
|
|
|
- * @param phoneId 消息标识
|
|
|
- * @return list
|
|
|
- */
|
|
|
@Override
|
|
|
- public List<StoreMenuVo> getStoreMenu(Integer storeId, Integer dishType, String phoneId) {
|
|
|
-
|
|
|
- if (dishType == 0) {
|
|
|
- List<StoreMenuVo> collect = storeMenuMapper.getStoreMenuList(storeId, null);
|
|
|
- return collect.stream().sorted(Comparator.comparing(StoreMenuVo::getSort)).collect(Collectors.toList());
|
|
|
- } else {
|
|
|
- List<StoreMenuVo> collect = storeMenuMapper.getStoreMenuList(storeId, dishType);
|
|
|
- collect.forEach(item -> {
|
|
|
- if (StringUtils.isNotEmpty(phoneId)) {
|
|
|
- LambdaQueryWrapper<LifeLikeRecord> query = new LambdaQueryWrapper<>();
|
|
|
- query.eq(LifeLikeRecord::getDianzanId, phoneId).eq(LifeLikeRecord::getHuifuId, item.getId());
|
|
|
- Integer i = lifeLikeRecordMapper.selectCount(query);
|
|
|
- if (i > 0) {
|
|
|
- item.setIsLike(1);
|
|
|
- } else {
|
|
|
- item.setIsLike(0);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- return collect.stream().sorted(Comparator.comparing(StoreMenuVo::getSort)).collect(Collectors.toList());
|
|
|
+ public IPage<StorePlatformMenu> getMenuPage(int page, int size, String menuName, String menuType, String status) {
|
|
|
+ LambdaQueryWrapper<StorePlatformMenu> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ // 菜单名称模糊查询
|
|
|
+ if (StringUtils.hasText(menuName)) {
|
|
|
+ queryWrapper.like(StorePlatformMenu::getMenuName, menuName);
|
|
|
+ }
|
|
|
+ // 菜单类型查询
|
|
|
+ if (StringUtils.hasText(menuType)) {
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getMenuType, menuType);
|
|
|
+ }
|
|
|
+ // 菜单状态查询
|
|
|
+ if (StringUtils.hasText(status)) {
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getStatus, status);
|
|
|
}
|
|
|
+
|
|
|
+ // 按显示顺序和创建时间排序
|
|
|
+ queryWrapper.orderByAsc(StorePlatformMenu::getMenuSort);
|
|
|
+ queryWrapper.orderByDesc(StorePlatformMenu::getCreatedTime);
|
|
|
+
|
|
|
+ return storePlatformMenuMapper.selectPage(new Page<>(page, size), queryWrapper);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取菜品详情
|
|
|
- *
|
|
|
- * @param id 菜品id
|
|
|
- * @return StoreMenuVo
|
|
|
- */
|
|
|
@Override
|
|
|
- public StoreMenuVo getMenuInfo(Integer id) {
|
|
|
- return storeMenuMapper.getMenuInfo(id);
|
|
|
+ public StorePlatformMenu getMenuById(Long menuId) {
|
|
|
+ return storePlatformMenuMapper.selectById(menuId);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增或修改门店菜品
|
|
|
- *
|
|
|
- * @param storeMenu
|
|
|
- * @return
|
|
|
- */
|
|
|
@Override
|
|
|
- public R<String> saveOrUpdateMenu(StoreMenu storeMenu) {
|
|
|
- boolean flag = false;
|
|
|
- LambdaQueryWrapper<StoreMenu> storeMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- //修改菜品
|
|
|
- if (storeMenu.getId() != null) {
|
|
|
- flag = this.updateById(storeMenu);
|
|
|
- if (!flag) {
|
|
|
- log.error("菜单修改失败");
|
|
|
- return R.fail("菜单修改失败");
|
|
|
- }
|
|
|
- return R.success("菜单修改成功");
|
|
|
- } else {//新增菜品
|
|
|
- if (StringUtils.isEmpty(storeMenu.getDishName())) {
|
|
|
- return R.fail("请输入菜品名称");
|
|
|
- }
|
|
|
- storeMenuLambdaQueryWrapper.eq(StoreMenu::getStoreId, storeMenu.getStoreId());
|
|
|
- List<StoreMenu> menuList = this.list(storeMenuLambdaQueryWrapper);
|
|
|
- if (CollectionUtil.isNotEmpty(menuList)) {
|
|
|
- int maxSort = menuList.stream().map(StoreMenu::getSort).reduce(Integer::max).get();
|
|
|
- storeMenu.setSort(maxSort + 1);
|
|
|
- } else {
|
|
|
- storeMenu.setSort(1);
|
|
|
- }
|
|
|
- //保存菜品
|
|
|
- flag = this.save(storeMenu);
|
|
|
- if (!flag) {
|
|
|
- return R.fail("菜品新增失败");
|
|
|
- }
|
|
|
+ public boolean saveMenu(StorePlatformMenu menu) {
|
|
|
+ // 校验必填字段
|
|
|
+ if (!StringUtils.hasText(menu.getMenuName())) {
|
|
|
+ log.error("菜单名称不能为空");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(menu.getMenuType())) {
|
|
|
+ log.error("菜单类型不能为空");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 设置默认值
|
|
|
+ if (menu.getMenuSort() == null) {
|
|
|
+ menu.setMenuSort(0);
|
|
|
+ }
|
|
|
+ if (menu.getParentId() == null) {
|
|
|
+ menu.setParentId(0L);
|
|
|
+ }
|
|
|
+ // 自动计算菜单层级
|
|
|
+ if (menu.getLevel() == null) {
|
|
|
+ menu.setLevel(calculateMenuLevel(menu.getParentId()));
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(menu.getStatus())) {
|
|
|
+ menu.setStatus("0"); // 默认正常
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(menu.getDelFlag())) {
|
|
|
+ menu.setDelFlag("0"); // 默认未删除
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(menu.getVisible())) {
|
|
|
+ menu.setVisible("0"); // 默认显示
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(menu.getIsFrame())) {
|
|
|
+ menu.setIsFrame("1"); // 默认非外链
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(menu.getIsCache())) {
|
|
|
+ menu.setIsCache("0"); // 默认缓存
|
|
|
}
|
|
|
- return R.success("新增菜品成功");
|
|
|
+ int result = storePlatformMenuMapper.insert(menu);
|
|
|
+ return result > 0;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增或修改门店菜品new
|
|
|
- *
|
|
|
- * @param storeMenuVo
|
|
|
- * @return
|
|
|
- */
|
|
|
@Override
|
|
|
- public R<String> saveOrUpdateMenus(StoreMenuVo storeMenuVo) {
|
|
|
- boolean flag = false;
|
|
|
- LambdaQueryWrapper<StoreMenu> storeMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- int imgId = 0;
|
|
|
- if (storeMenuVo.getImgId() == null || storeMenuVo.getImgId() == 0) {
|
|
|
- StoreImg storeImg = new StoreImg();
|
|
|
- storeImg.setStoreId(storeMenuVo.getStoreId());
|
|
|
- storeImg.setImgType(7);
|
|
|
- storeImg.setImgUrl(storeMenuVo.getImgUrl());
|
|
|
- storeImg.setImgDescription(storeMenuVo.getDishName());
|
|
|
- storeImgService.saveOrUpdate(storeImg);
|
|
|
- imgId = storeImg.getId();
|
|
|
- } else {
|
|
|
- imgId = storeMenuVo.getImgId();
|
|
|
+ public boolean updateMenu(StorePlatformMenu menu) {
|
|
|
+ if (menu.getMenuId() == null) {
|
|
|
+ log.error("菜单ID不能为空");
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- // 封装storeMenu参数
|
|
|
- StoreMenu storeMenu = new StoreMenu();
|
|
|
- BeanUtils.copyProperties(storeMenuVo, storeMenu);
|
|
|
- storeMenu.setImgId(imgId);
|
|
|
+ int result = storePlatformMenuMapper.updateById(menu);
|
|
|
+ return result > 0;
|
|
|
+ }
|
|
|
|
|
|
- //修改菜品
|
|
|
- if (storeMenu.getId() != null) {
|
|
|
- flag = this.updateById(storeMenu);
|
|
|
- if (!flag) {
|
|
|
- log.error("菜单修改失败");
|
|
|
- return R.fail("菜单修改失败");
|
|
|
- }
|
|
|
- return R.success("菜单修改成功");
|
|
|
- } else {
|
|
|
- //新增菜品
|
|
|
- // 校验菜品参数
|
|
|
- if (StringUtils.isEmpty(storeMenu.getDishName())) {
|
|
|
- return R.fail("请输入菜品名称");
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public boolean deleteMenu(Long menuId) {
|
|
|
+ // 逻辑删除
|
|
|
+ LambdaUpdateWrapper<StorePlatformMenu> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(StorePlatformMenu::getMenuId, menuId);
|
|
|
+ updateWrapper.set(StorePlatformMenu::getDelFlag, "2"); // 2代表删除
|
|
|
+
|
|
|
+ int result = storePlatformMenuMapper.update(null, updateWrapper);
|
|
|
+ return result > 0;
|
|
|
+ }
|
|
|
|
|
|
- storeMenuLambdaQueryWrapper.eq(StoreMenu::getStoreId, storeMenu.getStoreId());
|
|
|
- List<StoreMenu> menuList = this.list(storeMenuLambdaQueryWrapper);
|
|
|
- if (CollectionUtil.isNotEmpty(menuList)) {
|
|
|
- int maxSort = menuList.stream().map(StoreMenu::getSort).reduce(Integer::max).get();
|
|
|
- storeMenu.setSort(maxSort + 1);
|
|
|
- } else {
|
|
|
- storeMenu.setSort(1);
|
|
|
- }
|
|
|
- //保存菜品
|
|
|
- flag = this.save(storeMenu);
|
|
|
- if (!flag) {
|
|
|
- return R.fail("菜品新增失败");
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public boolean updateStatus(Long menuId, String status) {
|
|
|
+ if (menuId == null) {
|
|
|
+ log.error("菜单ID不能为空");
|
|
|
+ return false;
|
|
|
}
|
|
|
- return R.success("新增菜品成功");
|
|
|
+ if (!StringUtils.hasText(status)) {
|
|
|
+ log.error("菜单状态不能为空");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<StorePlatformMenu> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(StorePlatformMenu::getMenuId, menuId);
|
|
|
+ updateWrapper.set(StorePlatformMenu::getStatus, status);
|
|
|
+
|
|
|
+ int result = storePlatformMenuMapper.update(null, updateWrapper);
|
|
|
+ return result > 0;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<StorePlatformMenu> getMenuTree() {
|
|
|
+ // 查询所有未删除的菜单
|
|
|
+ LambdaQueryWrapper<StorePlatformMenu> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getStatus, "0"); // 正常状态
|
|
|
+ queryWrapper.orderByAsc(StorePlatformMenu::getMenuSort);
|
|
|
+ List<StorePlatformMenu> allMenus = storePlatformMenuMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+
|
|
|
+ return buildMenuTree(allMenus, 0L);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 菜品排序信息
|
|
|
- *
|
|
|
- * @param storeMenuVo
|
|
|
- * @return
|
|
|
- */
|
|
|
@Override
|
|
|
- public Boolean getSortMenuInfo(StoreMenuVo storeMenuVo) {
|
|
|
- boolean flag = false;
|
|
|
- if (CollectionUtil.isNotEmpty(storeMenuVo.getSortList())) {
|
|
|
- for (int i = 0; i < storeMenuVo.getSortList().size(); i++) {
|
|
|
- LambdaQueryWrapper<StoreMenu> lambdaQueryWrapper = new LambdaQueryWrapper();
|
|
|
- lambdaQueryWrapper.eq(StoreMenu::getId, storeMenuVo.getSortList().get(i).getId());
|
|
|
- StoreMenu storeMenu = this.getOne(lambdaQueryWrapper);
|
|
|
- storeMenu.setSort(i + 1);
|
|
|
- flag = this.updateById(storeMenu);
|
|
|
- }
|
|
|
- }
|
|
|
- return flag;
|
|
|
+ public List<StorePlatformMenu> getMenusByParentId(Long parentId) {
|
|
|
+ LambdaQueryWrapper<StorePlatformMenu> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getParentId, parentId);
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getStatus, "0");
|
|
|
+ queryWrapper.orderByAsc(StorePlatformMenu::getMenuSort);
|
|
|
+
|
|
|
+ return storePlatformMenuMapper.selectList(queryWrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean saveMenuSort(List<StoreMenu> storeMenuList) {
|
|
|
- return this.updateBatchById(storeMenuList);
|
|
|
+ public List<StorePlatformMenu> getMenusByLevel(Integer level) {
|
|
|
+ LambdaQueryWrapper<StorePlatformMenu> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getLevel, level);
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(StorePlatformMenu::getStatus, "0");
|
|
|
+ queryWrapper.orderByAsc(StorePlatformMenu::getMenuSort);
|
|
|
+
|
|
|
+ return storePlatformMenuMapper.selectList(queryWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除菜品或推荐菜 根据类型区分
|
|
|
- *
|
|
|
- * @param ids
|
|
|
- * @param dishType 0:菜品 1:推荐菜
|
|
|
- * @return
|
|
|
+ * 构建菜单树
|
|
|
*/
|
|
|
- @Override
|
|
|
- public R deleteMenu(List<Integer> ids, int dishType) {
|
|
|
- QueryWrapper<StoreMenu> queryWrapperMenu = new QueryWrapper<>();
|
|
|
- boolean flag = false;
|
|
|
- if (dishType == 0) {
|
|
|
- List<LifeGroupBuyThali> lifeGroupBuyThaliList = lifeGroupBuyThaliMapper.selectList(new LambdaQueryWrapper<LifeGroupBuyThali>().in(LifeGroupBuyThali::getDetailId, ids));
|
|
|
- if (CollectionUtil.isNotEmpty(lifeGroupBuyThaliList)) {
|
|
|
- return R.fail("该菜品已被团购套餐引用,不能删除");
|
|
|
- }
|
|
|
- flag = this.removeByIds(ids);
|
|
|
- } else {
|
|
|
- queryWrapperMenu.in("id", ids);
|
|
|
- List<StoreMenu> storeMenuList = baseMapper.selectList(queryWrapperMenu);
|
|
|
- storeMenuList.forEach(item -> {
|
|
|
- item.setDishType(0);
|
|
|
- this.updateById(item);
|
|
|
- });
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- if (!flag) {
|
|
|
- return R.fail("删除失败");
|
|
|
- }
|
|
|
- return R.success("删除成功");
|
|
|
- }
|
|
|
- @Override
|
|
|
- public StoreMenuVo getMenuCountByStoreId(int storeId) {
|
|
|
- StoreMenuVo storeMenuVo = new StoreMenuVo();
|
|
|
- LambdaUpdateWrapper<StoreMenu> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.eq(StoreMenu::getStoreId, storeId);
|
|
|
- updateWrapper.eq(StoreMenu::getDeleteFlag, 0);
|
|
|
- List<StoreMenu> storeMenuList = storeMenuMapper.selectList(updateWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(storeMenuList)) {
|
|
|
- storeMenuVo.setMenuCount(storeMenuList.size());
|
|
|
- Map<Integer, List<StoreMenu>> groupByDishType = storeMenuList.stream()
|
|
|
- .collect(Collectors.groupingBy(StoreMenu::getDishType));
|
|
|
- List<StoreMenu> suggestList = groupByDishType.get(1);
|
|
|
- if (CollectionUtils.isNotEmpty(suggestList)) {
|
|
|
- storeMenuVo.setSuggestCount(suggestList.size());
|
|
|
- } else {
|
|
|
- storeMenuVo.setSuggestCount(0);
|
|
|
- }
|
|
|
- } else {
|
|
|
- storeMenuVo.setMenuCount(0);
|
|
|
- storeMenuVo.setSuggestCount(0);
|
|
|
- }
|
|
|
- return storeMenuVo;
|
|
|
+ private List<StorePlatformMenu> buildMenuTree(List<StorePlatformMenu> allMenus, Long parentId) {
|
|
|
+ return allMenus.stream()
|
|
|
+ .filter(menu -> parentId.equals(menu.getParentId()))
|
|
|
+ .map(menu -> {
|
|
|
+ menu.setChildren(buildMenuTree(allMenus, menu.getMenuId()));
|
|
|
+ return menu;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取用户对该菜品是否点赞
|
|
|
+ * 计算菜单层级
|
|
|
+ * 根据父菜单ID计算当前菜单的层级
|
|
|
*
|
|
|
- * @param userId 用户id
|
|
|
- * @param menuId 菜品id
|
|
|
- * @return boolean
|
|
|
+ * @param parentId 父菜单ID
|
|
|
+ * @return 菜单层级(1一级菜单 2二级菜单 3三级菜单)
|
|
|
*/
|
|
|
- @Override
|
|
|
- public boolean getMenuLikeStatus(String userId, Integer menuId) {
|
|
|
- return lifeLikeRecordMapper.selectCount(new QueryWrapper<LifeLikeRecord>().eq("dianzan_id", userId).eq("huifu_id", menuId).eq("delete_flag", 0)) > 0;
|
|
|
+ private Integer calculateMenuLevel(Long parentId) {
|
|
|
+ if (parentId == null || parentId == 0L) {
|
|
|
+ return 1; // 一级菜单
|
|
|
+ }
|
|
|
+ // 查询父菜单的层级
|
|
|
+ StorePlatformMenu parentMenu = storePlatformMenuMapper.selectById(parentId);
|
|
|
+ if (parentMenu == null) {
|
|
|
+ return 1; // 如果父菜单不存在,默认为一级菜单
|
|
|
+ }
|
|
|
+ // 父菜单层级 + 1
|
|
|
+ Integer parentLevel = parentMenu.getLevel();
|
|
|
+ if (parentLevel == null) {
|
|
|
+ return 2; // 如果父菜单没有层级信息,默认为二级菜单
|
|
|
+ }
|
|
|
+ return parentLevel + 1;
|
|
|
}
|
|
|
}
|