wangwei 7 年 前
コミット
063cadd70e

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

@@ -88,6 +88,14 @@ public class UserController extends ControllerSupport {
 			throw new StatusException("B-150001", "非法请求");
 		}
 
+		Org rootOrg = orgRepo.findOne(rootOrgId);
+		if (null == rootOrg) {
+			throw new StatusException("B-150003", "机构不存在");
+		}
+		if (null != rootOrg.getParentId()) {
+			throw new StatusException("B-150004", "机构错误");
+		}
+
 		RoleEntity roleEntity = roleRepo.findOne(roleId);
 		if (null == roleEntity) {
 			throw new StatusException("B-150002", "角色不存在");
@@ -114,9 +122,12 @@ public class UserController extends ControllerSupport {
 			bean.setName(next.getName());
 			bean.setRootOrgId(next.getRootOrgId());
 			bean.setOrgId(next.getOrgId());
-			Org org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
-			bean.setOrgName(org.getName());
-			Org rootOrg = orgRepo.findOne(Long.valueOf(bean.getRootOrgId()));
+			if (null != bean.getOrgId()) {
+				Org org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+				if (null != org) {
+					bean.setOrgName(org.getName());
+				}
+			}
 			bean.setRootOrgName(rootOrg.getName());
 			bean.setEnable(next.getEnable());