wangwei 7 tahun lalu
induk
melakukan
61aea1ddf1

+ 19 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/PrivilegeController.java

@@ -5,17 +5,22 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Sort;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.google.common.collect.Lists;
 
+import cn.com.qmth.examcloud.commons.web.helpers.tree.EleTreeNode;
+import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeUtil;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeGroupBean;
 import cn.com.qmth.examcloud.core.basic.dao.AppRepo;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.PrivilegeGroupRepo;
+import cn.com.qmth.examcloud.core.basic.dao.PrivilegeRepo;
 import cn.com.qmth.examcloud.core.basic.dao.entity.App;
+import cn.com.qmth.examcloud.core.basic.dao.entity.Privilege;
 import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeGroup;
 import io.swagger.annotations.ApiOperation;
 
@@ -36,6 +41,9 @@ public class PrivilegeController extends ControllerSupport {
 	@Autowired
 	PrivilegeGroupRepo privilegeGroupRepo;
 
+	@Autowired
+	PrivilegeRepo privilegeRepo;
+
 	@Autowired
 	OrgRepo orgRepo;
 
@@ -63,4 +71,15 @@ public class PrivilegeController extends ControllerSupport {
 
 		return ret;
 	}
+
+	@ApiOperation(value = "查询权限树")
+	@GetMapping("getPrivilegeTree/{groupId}")
+	public EleTreeNode getPrivilegeTree(@PathVariable Long groupId) {
+		PrivilegeGroup group = privilegeGroupRepo.findOne(groupId);
+		List<Privilege> privilegeList = privilegeRepo.findAllByGroupId(groupId);
+		EleTreeNode rootNode = new EleTreeNode(-1L, group.getName());
+		TreeUtil.convert2OneEleTreeNode(rootNode, privilegeList);
+
+		return rootNode;
+	}
 }

+ 7 - 0
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/PrivilegeRepo.java

@@ -8,6 +8,13 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 import cn.com.qmth.examcloud.core.basic.dao.entity.Privilege;
 
+/**
+ * 类注释
+ *
+ * @author WANGWEI
+ * @date 2018年6月13日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
 public interface PrivilegeRepo
 		extends
 			JpaRepository<Privilege, Long>,