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