use of com.ibeiliao.deployment.admin.service.project.ProjectAccountRelationService in project Corgi by kevinYin.
the class LogMessageProcessor method hasPermission.
private boolean hasPermission(WebSocketSession webSocketSession, ShellLogRequestMessage message) {
List<Integer> ids = message.getServerDeployIdList();
if (CollectionUtils.isEmpty(ids)) {
return false;
}
DeployHistoryService deployHistoryService = SpringContextUtil.getBean(DeployHistoryService.class);
List<Project> projects = deployHistoryService.getProjectByServerDeployIds(ids);
if (CollectionUtils.isEmpty(projects)) {
logger.error("要读取的数据不属于任何project");
}
if (projects.size() != 1) {
logger.error("不能同时读取多个项目的日志, size: " + projects.size());
}
logger.info("读取log, ids=" + JSON.toJSONString(ids));
AdminLoginUser adminLoginUser = UserIdentitySessionHolder.getInstance().getSessionValue(webSocketSession);
if (adminLoginUser == null) {
logger.error("找不到登录用户的信息, session: " + webSocketSession.getId());
return false;
}
long accountId = adminLoginUser.getAccountId();
ProjectAccountRelationService projectAccountRelationService = SpringContextUtil.getBean(ProjectAccountRelationService.class);
for (Project p : projects) {
if (!projectAccountRelationService.hasRelation(accountId, p.getProjectId())) {
logger.error("用户:{} 没有项目:{} 的权限", accountId, p.getProjectId());
// return false;
}
}
return true;
}
Aggregations