wangwei 6 vuotta sitten
vanhempi
commit
9406d77b0c

+ 28 - 3
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgController.java

@@ -139,6 +139,28 @@ public class OrgController extends ControllerSupport {
 		return ret;
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param rootOrgId
+	 * @return
+	 */
+	@ApiOperation(value = "按ID查询顶级机构", notes = "ID查询")
+	@GetMapping("rootOrg/{rootOrgId}")
+	public OrgEntity getRootOrg(@PathVariable Long rootOrgId) {
+		OrgEntity orgEntity = orgRepo.findOne(rootOrgId);
+		if (null == orgEntity) {
+			throw new StatusException("B-001250", "rootOrgId is wrong");
+		}
+		if (null != orgEntity.getParentId()) {
+			throw new StatusException("B-001251", "rootOrgId is wrong");
+		}
+		validateRootOrgIsolation(orgEntity.getRootId());
+
+		return orgEntity;
+	}
+
 	/**
 	 * 方法注释
 	 *
@@ -146,13 +168,16 @@ public class OrgController extends ControllerSupport {
 	 * @param orgId
 	 * @return
 	 */
-	@ApiOperation(value = "按ID查询机构", notes = "ID查询")
-	@GetMapping("{orgId}")
-	public OrgEntity getOrg(@PathVariable Long orgId) {
+	@ApiOperation(value = "按ID查询顶级机构", notes = "ID查询")
+	@GetMapping("subOrg/{orgId}")
+	public OrgEntity getSubOrg(@PathVariable Long orgId) {
 		OrgEntity orgEntity = orgRepo.findOne(orgId);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "orgId is wrong");
 		}
+		if (null == orgEntity.getParentId()) {
+			throw new StatusException("B-001251", "orgId is wrong");
+		}
 		validateRootOrgIsolation(orgEntity.getRootId());
 
 		return orgEntity;