Browse Source

增加查询api和dal层

caoyang 6 months ago
parent
commit
7780dae7aa

+ 7 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/AppSafeCameraController.java

@@ -73,6 +73,13 @@ public class AppSafeCameraController {
         return success(BeanUtils.toBean(pageResult, AppSafeCameraRespVO.class));
     }
 
+    @GetMapping("/cameras")
+    @Operation(summary = "获得安防后端设备所包括的多路前端设备")
+    public CommonResult<List<AppSafeCameraRespVO>> getCameras(@RequestParam("serverId") Long serverId) {
+        List<SafeCameraDO> pageResult = cameraService.getCamerasByServerId(serverId);
+        return success(BeanUtils.toBean(pageResult, AppSafeCameraRespVO.class));
+    }
+
     @GetMapping("/export-excel")
     @Operation(summary = "导出安防前端设备 Excel")
     @ApiAccessLog(operateType = EXPORT)

+ 8 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/AppSafeServerController.java

@@ -80,6 +80,14 @@ public class AppSafeServerController {
         return success(BeanUtils.toBean(list, AppSafeServerRespVO.class));
     }
 
+    @GetMapping("/servers")
+    @Operation(summary = "获得机构下所有安防后端设备")
+    @Parameter(name = "orgId", description = "机构id(部门ID)", required = true, example = "1")
+    public CommonResult<List<AppSafeServerRespVO>> getServers(@RequestParam("orgId") Long orgId) {
+        List<SafeServerDO> list = serverService.getServersByOrgId(orgId);
+        return success(BeanUtils.toBean(list, AppSafeServerRespVO.class));
+    }
+
     @GetMapping("/export-excel")
     @Operation(summary = "导出安防后端设备 Excel")
     @ApiAccessLog(operateType = EXPORT)

+ 6 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/mysql/camera/SafeCameraMapper.java

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.safe.dal.dataobject.camera.SafeCameraDO;
 import org.apache.ibatis.annotations.Mapper;
 import cn.iocoder.yudao.module.safe.controller.admin.camera.vo.*;
 
+import java.util.List;
+
 /**
  * 安防前端设备 Mapper
  *
@@ -25,4 +27,8 @@ public interface SafeCameraMapper extends BaseMapperX<SafeCameraDO> {
                 .orderByDesc(SafeCameraDO::getId));
     }
 
+    default List<SafeCameraDO> selectByServerId(Long serverId) {
+        return selectList("server_id",serverId);
+    }
+
 }

+ 6 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/mysql/server/SafeServerMapper.java

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.safe.dal.dataobject.server.SafeServerDO;
 import org.apache.ibatis.annotations.Mapper;
 import cn.iocoder.yudao.module.safe.controller.admin.server.vo.*;
 
+import java.util.List;
+
 /**
  * 安防后端设备 Mapper
  *
@@ -26,4 +28,8 @@ public interface SafeServerMapper extends BaseMapperX<SafeServerDO> {
                 .orderByDesc(SafeServerDO::getId));
     }
 
+    default List<SafeServerDO> selectByOrgId(Long orgId) {
+        return selectList("org_id",orgId);
+    }
+
 }

+ 4 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/camera/SafeCameraService.java

@@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.safe.controller.admin.camera.vo.*;
 import cn.iocoder.yudao.module.safe.dal.dataobject.camera.SafeCameraDO;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 
+import java.util.List;
+
 /**
  * 安防前端设备 Service 接口
  *
@@ -50,4 +52,6 @@ public interface SafeCameraService {
      */
     PageResult<SafeCameraDO> getCameraPage(AppSafeCameraPageReqVO pageReqVO);
 
+    List<SafeCameraDO> getCamerasByServerId(Long serverId);
+
 }

+ 6 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/camera/SafeCameraServiceImpl.java

@@ -10,6 +10,8 @@ import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
+import java.util.List;
+
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.safe.enums.ErrorCodeConstants.CAMERA_NOT_EXISTS;
 
@@ -67,4 +69,8 @@ public class SafeCameraServiceImpl implements SafeCameraService {
         return cameraMapper.selectPage(pageReqVO);
     }
 
+    @Override
+    public List<SafeCameraDO> getCamerasByServerId(Long serverId) {
+        return cameraMapper.selectByServerId(serverId);
+    }
 }

+ 2 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/server/SafeServerService.java

@@ -58,4 +58,6 @@ public interface SafeServerService {
      */
     public List<SafeServerDO> getAllServer();
 
+    public List<SafeServerDO> getServersByOrgId(Long orgId);
+
 }

+ 4 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/server/SafeServerServiceImpl.java

@@ -75,4 +75,8 @@ public class SafeServerServiceImpl implements SafeServerService {
         return serverMapper.selectList();
     }
 
+    @Override
+    public List<SafeServerDO> getServersByOrgId(Long orgId) {
+        return serverMapper.selectByOrgId(orgId);
+    }
 }