Browse Source

默认菜单权限

yuandeguo 3 years ago
parent
commit
5f9c933da8

+ 23 - 13
saas-account/src/main/java/com/persagy/account/controller/SaasFunctionController.java

@@ -1,19 +1,11 @@
 package com.persagy.account.controller;
 
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.druid.util.StringUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.collect.Lists;
+import com.persagy.account.config.ApplicationProperties;
 import com.persagy.account.manage.SaasAuthHandler;
 import com.persagy.account.manage.SaasProductHandler;
 import com.persagy.account.manage.SaasRoleMenuHandler;
@@ -35,10 +27,18 @@ import com.persagy.common.utils.ResponseResult;
 import com.persagy.common.utils.ResponseResultUtil;
 import com.persagy.common.utils.StringUtil;
 import com.persagy.security.constant.CipherConstants;
-
-import cn.hutool.core.collection.CollectionUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 功能信息
@@ -73,6 +73,9 @@ public class SaasFunctionController {
     
 	@Autowired
 	private ISaasProductPageService saasProductPageService;
+
+	@Autowired
+	private ApplicationProperties applicationProperties;
 	
     /**
      * 账号、菜单所拥有的功能点查询,权限过滤
@@ -103,6 +106,13 @@ public class SaasFunctionController {
 		if (saasMenu == null) {
 			return ResponseResultUtil.successResult(Lists.newArrayList());
 		}
+		//默认菜单直接返回默认菜单下的功能点
+		if (StringUtils.equals(applicationProperties.getDefaultMenuId(),model.getMenuId())){
+			LambdaQueryWrapper<SaasFunction> queryWrapper = new SaasFunction.Builder().createQueryWrapper()
+					.menuIdEq(saasMenu.getMenuId()).builderQueryWrapper();
+			List<SaasFunction> defaultFunctions = this.saasFunctionService.list(queryWrapper.orderByAsc(SaasFunction::getCreateTime));
+			saasMenu.setFunctions(defaultFunctions);
+		}
     	// 获取此账号、此菜单下所对应的功能点信息集合 或者 产品页面树集合
     	this.saasProductHandler.queryMenuProductAuths(saasMenu, model.getAccountId(), accountBelong, model.getProjectId(), groupCode, isAdmin, true, model.isShowPageAuth());
         if (StringUtil.isBlank(saasMenu.getProductId())) {