|
@@ -1,14 +1,30 @@
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
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.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;
|
|
import cn.com.qmth.examcloud.core.basic.api.RolePrivilegeCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.RolePrivilegeCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.PrivilegeInfo;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetPrivilegesReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetPrivilegesReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetPrivilegesResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetPrivilegesResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.PrivilegeGroupRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.PrivilegeRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.RolePrivilegeRelationRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.Privilege;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeGroup;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -26,14 +42,66 @@ public class RolePrivilegeCloudServiceProvider extends ControllerSupport
|
|
|
|
|
|
private static final long serialVersionUID = -4360164791713797878L;
|
|
private static final long serialVersionUID = -4360164791713797878L;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ RoleRepo roleRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ RolePrivilegeRelationRepo rolePrivilegeRelationRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PrivilegeRepo privilegeRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PrivilegeGroupRepo privilegeGroupRepo;
|
|
|
|
+
|
|
@ApiOperation(value = "查询用户权限", notes = "")
|
|
@ApiOperation(value = "查询用户权限", notes = "")
|
|
@PostMapping("getPrivileges")
|
|
@PostMapping("getPrivileges")
|
|
@Override
|
|
@Override
|
|
public GetPrivilegesResp getPrivileges(GetPrivilegesReq req) {
|
|
public GetPrivilegesResp getPrivileges(GetPrivilegesReq req) {
|
|
|
|
|
|
User accessUser = getAccessUser();
|
|
User accessUser = getAccessUser();
|
|
|
|
+ String groupCode = req.getGroupCode();
|
|
|
|
+ PrivilegeGroup privilegeGroup = privilegeGroupRepo.findByCode(groupCode);
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ roleIdList.add(role.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<RolePrivilegeRelation> rolePrivRelation = rolePrivilegeRelationRepo
|
|
|
|
+ .findAllByRoleIdIn(roleIdList);
|
|
|
|
+
|
|
|
|
+ Set<String> pIdSet = Sets.newHashSet();
|
|
|
|
+ for (RolePrivilegeRelation cur : rolePrivRelation) {
|
|
|
|
+ pIdSet.add(String.valueOf(cur.getPrivilegeId()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Privilege> privilegeList = privilegeRepo.findAllByGroupId(privilegeGroup.getId());
|
|
|
|
+
|
|
|
|
+ List<PrivilegeInfo> privilegeInfoList = Lists.newArrayList();
|
|
|
|
+
|
|
|
|
+ for (Privilege cur : privilegeList) {
|
|
|
|
+ PrivilegeInfo privilegeInfo = new PrivilegeInfo();
|
|
|
|
+ privilegeInfo.setCode(cur.getCode());
|
|
|
|
+ privilegeInfo.setCreationTime(cur.getCreationTime());
|
|
|
|
+ privilegeInfo.setGroupId(cur.getGroupId());
|
|
|
|
+ privilegeInfo.setId(cur.getId());
|
|
|
|
+ privilegeInfo.setName(cur.getName());
|
|
|
|
+ privilegeInfo.setParentId(cur.getParentId());
|
|
|
|
+ privilegeInfo.setUpdateTime(cur.getUpdateTime());
|
|
|
|
+
|
|
|
|
+ privilegeInfo.setHasPrivilege(pIdSet.contains(String.valueOf(cur.getId())));
|
|
|
|
+
|
|
|
|
+ privilegeInfoList.add(privilegeInfo);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ GetPrivilegesResp resp = new GetPrivilegesResp();
|
|
|
|
+ resp.setPrivilegeInfoList(privilegeInfoList);
|
|
|
|
+ return resp;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|