wangwei há 7 anos atrás
pai
commit
87288006d7

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

@@ -0,0 +1,66 @@
+package cn.com.qmth.examcloud.core.basic.api.controller;
+
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.google.common.collect.Lists;
+
+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.entity.App;
+import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeGroup;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 权限
+ *
+ * @author WANGWEI
+ * @date 2018年6月12日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+@RestController
+@RequestMapping("${app.api.root}/privilege")
+public class PrivilegeController extends ControllerSupport {
+
+	@Autowired
+	AppRepo appRepo;
+
+	@Autowired
+	PrivilegeGroupRepo privilegeGroupRepo;
+
+	@Autowired
+	OrgRepo orgRepo;
+
+	@ApiOperation(value = "查询权限组")
+	@GetMapping("getPrivilegeGroupList")
+	public List<PrivilegeGroupBean> getPrivilegeGroupList() {
+		Sort sort = new Sort(Sort.Direction.ASC, "id");
+		List<PrivilegeGroup> list = privilegeGroupRepo.findAll(sort);
+
+		List<PrivilegeGroupBean> ret = Lists.newArrayList();
+
+		for (PrivilegeGroup cur : list) {
+			PrivilegeGroupBean bean = new PrivilegeGroupBean();
+			bean.setId(cur.getId());
+			bean.setAppId(cur.getAppId());
+			App app = appRepo.findOne(cur.getAppId());
+			if (null != app) {
+				bean.setAppName(app.getName());
+			}
+			bean.setCode(cur.getCode());
+			bean.setName(cur.getName());
+
+			ret.add(bean);
+		}
+
+		return ret;
+	}
+}

+ 107 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/bean/PrivilegeGroupBean.java

@@ -0,0 +1,107 @@
+package cn.com.qmth.examcloud.core.basic.api.controller.bean;
+
+import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
+
+/**
+ * 权限组
+ *
+ * @author WANGWEI
+ * @date 2018年5月23日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public class PrivilegeGroupBean implements JsonSerializable {
+
+	private static final long serialVersionUID = -3654724059677675683L;
+
+	/**
+	 * 权限组ID
+	 */
+	private Long id;
+
+	/**
+	 * 权限组名称
+	 */
+	private String name;
+
+	/**
+	 * 权限组编码
+	 */
+	private String code;
+
+	/**
+	 * 应用ID
+	 */
+	private Long appId;
+
+	/**
+	 * 应用名称
+	 */
+	private String appName;
+
+	/**
+	 * 顶级机构ID
+	 */
+	private Long rootOrgId;
+
+	/**
+	 * 顶级机构名称
+	 */
+	private String rootOrgName;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public Long getAppId() {
+		return appId;
+	}
+
+	public void setAppId(Long appId) {
+		this.appId = appId;
+	}
+
+	public String getAppName() {
+		return appName;
+	}
+
+	public void setAppName(String appName) {
+		this.appName = appName;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public String getRootOrgName() {
+		return rootOrgName;
+	}
+
+	public void setRootOrgName(String rootOrgName) {
+		this.rootOrgName = rootOrgName;
+	}
+
+}

+ 1 - 8
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/AppRepo.java

@@ -1,9 +1,6 @@
 package cn.com.qmth.examcloud.core.basic.dao;
 
-import java.util.List;
-
 import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 import cn.com.qmth.examcloud.core.basic.dao.entity.App;
@@ -15,10 +12,6 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.App;
  * @date 2018年6月11日
  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
-public interface AppRepo
-		extends
-			JpaRepository<App, Long>,
-			QueryByExampleExecutor<App>,
-			JpaSpecificationExecutor<App> {
+public interface AppRepo extends JpaRepository<App, Long>, QueryByExampleExecutor<App> {
 
 }

+ 3 - 17
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/PrivilegeGroup.java

@@ -44,13 +44,7 @@ public class PrivilegeGroup extends JpaEntity {
 	 * 应用
 	 */
 	@Column(unique = false, nullable = false)
-	private String appId;
-
-	/**
-	 * 顶级机构ID
-	 */
-	@Column(unique = false, nullable = true)
-	private Long rootOrgId;
+	private Long appId;
 
 	public Long getId() {
 		return id;
@@ -76,20 +70,12 @@ public class PrivilegeGroup extends JpaEntity {
 		this.code = code;
 	}
 
-	public String getAppId() {
+	public Long getAppId() {
 		return appId;
 	}
 
-	public void setAppId(String appId) {
+	public void setAppId(Long appId) {
 		this.appId = appId;
 	}
 
-	public Long getRootOrgId() {
-		return rootOrgId;
-	}
-
-	public void setRootOrgId(Long rootOrgId) {
-		this.rootOrgId = rootOrgId;
-	}
-
 }