wangwei 7 年之前
父节点
当前提交
b4cb541aaf

+ 19 - 3
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/OrgCloudServiceProvider.java

@@ -31,6 +31,8 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping("${$rmp.cloud.basic}" + "org")
 public class OrgCloudServiceProvider extends ControllerSupport implements OrgCloudService {
 
+	private static final long serialVersionUID = -7858439296389761341L;
+
 	@Autowired
 	private OrgService orgService;
 
@@ -95,12 +97,26 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
 	@Override
 	public GetOrgResp getOrg(@RequestBody GetOrgReq req) {
 		Long orgId = req.getOrgId();
+		String orgCode = req.getOrgCode();
+		Long rootOrgId = req.getRootOrgId();
+
+		if (null == orgId && StringUtils.isBlank(orgCode)) {
+			throw new StatusException("B-150000", "orgId,orgCode不能都为空");
+		}
 
-		if (null == orgId) {
-			throw new StatusException("B-150000", "orgId is null");
+		if (null != orgId && StringUtils.isNotBlank(orgCode)) {
+			throw new StatusException("B-150001", "orgId,orgCode不能都不为空");
 		}
 
-		Org org = orgRepo.findOne(orgId);
+		Org org = null;
+		if (null != orgId) {
+			org = orgRepo.findOne(orgId);
+		} else if (StringUtils.isNotBlank(orgCode)) {
+			if (null == rootOrgId) {
+				throw new StatusException("B-150001", "rootOrgId is null");
+			}
+			org = orgRepo.findByRootIdAndCode(rootOrgId, orgCode);
+		}
 
 		if (null == org) {
 			throw new StatusException("B-150001", "机构不存在");

+ 20 - 0
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/request/GetOrgReq.java

@@ -8,6 +8,10 @@ public class GetOrgReq extends BaseRequest {
 
 	private Long orgId;
 
+	private String orgCode;
+
+	private Long rootOrgId;
+
 	public Long getOrgId() {
 		return orgId;
 	}
@@ -16,4 +20,20 @@ public class GetOrgReq extends BaseRequest {
 		this.orgId = orgId;
 	}
 
+	public String getOrgCode() {
+		return orgCode;
+	}
+
+	public void setOrgCode(String orgCode) {
+		this.orgCode = orgCode;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
 }