|
|
@@ -94,6 +94,8 @@ public class HikvisionController {
|
|
|
private static final String RESOURCE_TYPE_CAMERA = "camera";
|
|
|
/** 海康接口单页允许查询的最大数量。 */
|
|
|
private static final int MAX_PAGE_SIZE = 1000;
|
|
|
+ /** 科瑞石油技术集团部门,可查看全部海康监控资源。 */
|
|
|
+ private static final long KERUI_GROUP_DEPT_ID = 156L;
|
|
|
|
|
|
/** 包含 host、appKey、appSecret 的海康 SDK 单例配置。 */
|
|
|
private final ArtemisConfig artemisConfig;
|
|
|
@@ -107,13 +109,14 @@ public class HikvisionController {
|
|
|
*
|
|
|
* <p>
|
|
|
* 当 {@code regionIndexCode=-1} 时,先调用根区域接口获得真实的根区域 {@code indexCode},
|
|
|
- * 管理员返回带有 {@code children} 的根节点;普通用户仅返回名称匹配的公司节点及其下一层,
|
|
|
+ * 超级管理员和科瑞石油技术集团部门账号返回带有 {@code children} 的根节点;
|
|
|
+ * 其他用户仅返回名称匹配的公司节点及其下一层,
|
|
|
* 未匹配到授权公司时返回空列表。
|
|
|
* </p>
|
|
|
*
|
|
|
* <p>
|
|
|
* 当传入真实区域编号时,先校验该区域位于授权公司子树内,再返回下一层节点。
|
|
|
- * 超级管理员不受公司范围限制。
|
|
|
+ * 超级管理员和科瑞石油技术集团部门账号不受公司范围限制。
|
|
|
* </p>
|
|
|
*
|
|
|
* @param regionIndexCode 当前展开区域的唯一标识;传 {@code -1} 表示加载根区域
|
|
|
@@ -124,7 +127,7 @@ public class HikvisionController {
|
|
|
public CommonResult<List<HikvisionTreeNodeRespVO>> treeChildren(
|
|
|
@Parameter(description = "区域唯一标识;传 -1 加载根节点及其下一层", required = true) @RequestParam("regionIndexCode") @NotBlank(message = "区域编号不能为空") String regionIndexCode) {
|
|
|
try {
|
|
|
- if (!isSuperAdmin()) {
|
|
|
+ if (!canAccessAllCameras()) {
|
|
|
HikvisionTreeNodeRespVO company = queryAllowedCompany();
|
|
|
if (company == null) {
|
|
|
return "-1".equals(regionIndexCode) ? success(Collections.emptyList())
|
|
|
@@ -167,7 +170,7 @@ public class HikvisionController {
|
|
|
return error(400, "监控点名称不能超过32个UTF-8字节");
|
|
|
}
|
|
|
try {
|
|
|
- HikvisionTreeNodeRespVO root = isSuperAdmin() ? queryRoot() : queryAllowedCompany();
|
|
|
+ HikvisionTreeNodeRespVO root = canAccessAllCameras() ? queryRoot() : queryAllowedCompany();
|
|
|
if (root == null) {
|
|
|
return success(Collections.emptyList());
|
|
|
}
|
|
|
@@ -383,10 +386,14 @@ public class HikvisionController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /** 超级管理员以系统角色判断,不能通过组织名称获得管理员权限。 */
|
|
|
- private boolean isSuperAdmin() {
|
|
|
+ /** 超级管理员或科瑞石油技术集团部门账号可访问全部海康监控资源。 */
|
|
|
+ private boolean canAccessAllCameras() {
|
|
|
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- return userId != null && permissionApi.hasAnyRoles(userId, RoleCodeEnum.SUPER_ADMIN.getCode());
|
|
|
+ if (userId == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return Long.valueOf(KERUI_GROUP_DEPT_ID).equals(SecurityFrameworkUtils.getLoginUserDeptId())
|
|
|
+ || permissionApi.hasAnyRoles(userId, RoleCodeEnum.SUPER_ADMIN.getCode());
|
|
|
}
|
|
|
|
|
|
/** 从登录组织向上找到最近的公司;不匹配、组织缺失或组织成环时拒绝授权。 */
|
|
|
@@ -429,7 +436,7 @@ public class HikvisionController {
|
|
|
}
|
|
|
|
|
|
private boolean canAccessCamera(String cameraIndexCode) throws Exception {
|
|
|
- if (isSuperAdmin()) {
|
|
|
+ if (canAccessAllCameras()) {
|
|
|
return true;
|
|
|
}
|
|
|
HikvisionTreeNodeRespVO company = queryAllowedCompany();
|