wangwei há 7 anos atrás
pai
commit
ced922308c

+ 10 - 2
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/PrivilegeCloudServiceProvider.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.web.security.bean.Role;
 import cn.com.qmth.examcloud.commons.web.security.bean.User;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
@@ -64,19 +65,26 @@ public class PrivilegeCloudServiceProvider extends ControllerSupport
 		String groupCode = req.getGroupCode();
 		PrivilegeGroup privilegeGroup = privilegeGroupRepo.findByCode(groupCode);
 
+		if (null == privilegeGroup) {
+			throw new StatusException("B-002001", "groupCode is not existing");
+		}
+
 		List<Role> roleList = accessUser.getRoleList();
 		List<Long> roleIdList = Lists.newArrayList();
 		for (Role cur : roleList) {
 			String roleCode = cur.getRoleCode();
 			cn.com.qmth.examcloud.core.basic.dao.entity.Role role = roleRepo.findBycode(roleCode);
+			if (null == role) {
+				throw new StatusException("B-002002", "role code is wrong. roleCode=" + roleCode);
+			}
 			roleIdList.add(role.getId());
 		}
 
-		List<RolePrivilegeRelation> rolePrivRelation = rolePrivilegeRelationRepo
+		List<RolePrivilegeRelation> rolePrivRelationList = rolePrivilegeRelationRepo
 				.findAllByRoleIdIn(roleIdList);
 
 		Set<String> pIdSet = Sets.newHashSet();
-		for (RolePrivilegeRelation cur : rolePrivRelation) {
+		for (RolePrivilegeRelation cur : rolePrivRelationList) {
 			pIdSet.add(String.valueOf(cur.getPrivilegeId()));
 		}
 

+ 21 - 6
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/bean/PrivilegeInfo.java

@@ -95,32 +95,47 @@ public class PrivilegeInfo extends JpaEntity implements JsonSerializable, TreeNo
 
 	@Override
 	public String getTreeId() {
-		return null;
+		if (null == this.id) {
+			return null;
+		}
+		return String.valueOf(this.id);
 	}
 
 	@Override
 	public void setTreeId(String treeId) {
-
+		if (null == treeId) {
+			this.id = null;
+		}
+		this.id = Long.parseLong(treeId);
 	}
 
 	@Override
 	public String getTreeName() {
-		return null;
+		if (null == this.name) {
+			return null;
+		}
+		return String.valueOf(this.name);
 	}
 
 	@Override
 	public void setTreeName(String treeName) {
-
+		this.name = treeName;
 	}
 
 	@Override
 	public String getParentTreeId() {
-		return null;
+		if (null == this.parentId) {
+			return null;
+		}
+		return String.valueOf(this.parentId);
 	}
 
 	@Override
 	public void setParentTreeId(String parentTreeId) {
-
+		if (null == parentTreeId) {
+			this.parentId = null;
+		}
+		this.parentId = Long.parseLong(parentTreeId);
 	}
 
 }