|
@@ -335,6 +335,7 @@ public class UserController extends ControllerSupport {
|
|
|
private Map<String, Object> saveUser(UserFormDomain userForm) {
|
|
|
|
|
|
Long rootOrgId = userForm.getRootOrgId();
|
|
|
+ Long orgId = userForm.getOrgId();
|
|
|
|
|
|
if (null == rootOrgId) {
|
|
|
throw new StatusException("B-150002", "rootOrgId is null");
|
|
@@ -349,13 +350,26 @@ public class UserController extends ControllerSupport {
|
|
|
|
|
|
validateRootOrgIsolation(rootOrgId);
|
|
|
|
|
|
+ if (null != orgId) {
|
|
|
+ OrgEntity org = orgRepo.findOne(orgId);
|
|
|
+ if (null == org) {
|
|
|
+ throw new StatusException("B-150101", "子机构不存在");
|
|
|
+ }
|
|
|
+ if (null == org.getParentId()) {
|
|
|
+ throw new StatusException("B-150102", "子机构错误");
|
|
|
+ }
|
|
|
+ if (!org.getRootId().equals(rootOrgId)) {
|
|
|
+ throw new StatusException("B-150103", "子机构错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
UserEntity userEntity = new UserEntity();
|
|
|
userEntity.setId(userForm.getId());
|
|
|
userEntity.setEnable(userForm.getEnable());
|
|
|
userEntity.setLoginName(userForm.getLoginName());
|
|
|
userEntity.setPhoneNumber(userForm.getMobile());
|
|
|
userEntity.setName(userForm.getName());
|
|
|
- userEntity.setOrgId(userForm.getOrgId());
|
|
|
+ userEntity.setOrgId(orgId);
|
|
|
userEntity.setRootOrgId(rootOrgId);
|
|
|
userEntity.setPassword(userForm.getPassword());
|
|
|
userEntity.setUpdateTime(new Date());
|
|
@@ -379,6 +393,12 @@ public class UserController extends ControllerSupport {
|
|
|
throw new StatusException("B-150007", "不允许新增或修改超级管理员");
|
|
|
}
|
|
|
|
|
|
+ if (curRoleEntity.getCode().equals(RoleMeta.LC_USER.name())) {
|
|
|
+ if (null == saved.getOrgId()) {
|
|
|
+ throw new StatusException("B-150008", "学习中心角色必须指定学习中心");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(),
|
|
|
curRoleEntity.getId());
|
|
|
userRoles.add(relation);
|