wangwei 7 rokov pred
rodič
commit
8f23cf92af

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

@@ -114,10 +114,21 @@ public class UserController extends ControllerSupport {
 			bean.setEnable(next.getEnable());
 
 			List<UserRole> userRoles = next.getUserRoles();
-			List<String> roleNameList = userRoles.stream()
-					.map(userRole -> RoleMeta.valueOf(userRole.getRoleCode()).getName())
-					.collect(Collectors.toList());
+			List<String> roleNameList = Lists.newArrayList();
+			List<Long> roleIdList = Lists.newArrayList();
+			List<String> roleCodeList = Lists.newArrayList();
+			for (UserRole cur : userRoles) {
+				RoleEntity curRoleEntity = roleRepo.findByCode(cur.getRoleCode());
+				if (null == curRoleEntity) {
+					throw new StatusException("B-150002", "角色错误");
+				}
+				roleNameList.add(curRoleEntity.getName());
+				roleIdList.add(curRoleEntity.getId());
+				roleCodeList.add(curRoleEntity.getCode());
+			}
 			bean.setRoleNamesStr(StringUtils.join(roleNameList, ","));
+			bean.setRoleIds(roleIdList);
+			bean.setRoleCodes(roleCodeList);
 
 			Org org = orgRepo.findOne(Long.valueOf(bean.getRootOrgId()));
 			bean.setRootOrgName(org.getName());

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

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.core.basic.api.controller.bean;
 
+import java.util.List;
+
 import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
 
 /**
@@ -34,6 +36,10 @@ public class FullUserInfo implements JsonSerializable {
 
 	private Boolean enable;
 
+	private List<Long> roleIds;
+
+	private List<String> roleCodes;
+
 	public Long getId() {
 		return id;
 	}
@@ -42,6 +48,14 @@ public class FullUserInfo implements JsonSerializable {
 		this.id = id;
 	}
 
+	public List<String> getRoleCodes() {
+		return roleCodes;
+	}
+
+	public void setRoleCodes(List<String> roleCodes) {
+		this.roleCodes = roleCodes;
+	}
+
 	public Long getRootOrgId() {
 		return rootOrgId;
 	}
@@ -106,4 +120,12 @@ public class FullUserInfo implements JsonSerializable {
 		this.enable = enable;
 	}
 
+	public List<Long> getRoleIds() {
+		return roleIds;
+	}
+
+	public void setRoleIds(List<Long> roleIds) {
+		this.roleIds = roleIds;
+	}
+
 }