Browse Source

增加安防接入模块

caoyang 6 months ago
parent
commit
e367df5895
24 changed files with 1095 additions and 0 deletions
  1. 1 0
      pom.xml
  2. 25 0
      yudao-module-safe/pom.xml
  3. 27 0
      yudao-module-safe/yudao-module-safe-api/pom.xml
  4. 16 0
      yudao-module-safe/yudao-module-safe-api/src/main/java/cn/iocoder/yudao/module/safe/enums/ErrorCodeConstants.java
  5. 51 0
      yudao-module-safe/yudao-module-safe-biz/pom.xml
  6. 88 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/AppSafeCameraController.java
  7. 28 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/vo/AppSafeCameraPageReqVO.java
  8. 57 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/vo/AppSafeCameraRespVO.java
  9. 44 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/vo/AppSafeCameraSaveReqVO.java
  10. 95 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/AppSafeServerController.java
  11. 31 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/vo/AppSafeServerPageReqVO.java
  12. 68 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/vo/AppSafeServerRespVO.java
  13. 55 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/vo/AppSafeServerSaveReqVO.java
  14. 75 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/dataobject/camera/SafeCameraDO.java
  15. 84 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/dataobject/server/SafeServerDO.java
  16. 28 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/mysql/camera/SafeCameraMapper.java
  17. 29 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/mysql/server/SafeServerMapper.java
  18. 53 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/camera/SafeCameraService.java
  19. 70 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/camera/SafeCameraServiceImpl.java
  20. 61 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/server/SafeServerService.java
  21. 78 0
      yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/service/server/SafeServerServiceImpl.java
  22. 12 0
      yudao-module-safe/yudao-module-safe-biz/src/main/resources/mapper/camera/SafeCameraMapper.xml
  23. 12 0
      yudao-module-safe/yudao-module-safe-biz/src/main/resources/mapper/server/SafeServerMapper.xml
  24. 7 0
      yudao-server/pom.xml

+ 1 - 0
pom.xml

@@ -23,6 +23,7 @@
         <module>yudao-module-mall</module>
         <module>yudao-module-crm</module>
         <module>yudao-module-erp</module>
+        <module>yudao-module-safe</module>
     </modules>
 
     <name>${project.artifactId}</name>

+ 25 - 0
yudao-module-safe/pom.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>yudao</artifactId>
+        <groupId>cn.iocoder.boot</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modules>
+        <module>yudao-module-safe-api</module>
+        <module>yudao-module-safe-biz</module>
+    </modules>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>yudao-module-safe</artifactId>
+    <packaging>pom</packaging>
+
+    <name>${project.artifactId}</name>
+    <description>
+        安防设备接入模块,入则接入安防的后端设备如视频服务器、视频磁盘网路机、摄像头等等。
+    </description>
+
+
+</project>

+ 27 - 0
yudao-module-safe/yudao-module-safe-api/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>yudao-module-safe</artifactId>
+        <groupId>cn.iocoder.boot</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>yudao-module-safe-api</artifactId>
+    <packaging>jar</packaging>
+
+    <name>${project.artifactId}</name>
+    <description>
+        安防 模块 API,暴露给其它模块调用
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-common</artifactId>
+        </dependency>
+    </dependencies>
+
+
+</project>

+ 16 - 0
yudao-module-safe/yudao-module-safe-api/src/main/java/cn/iocoder/yudao/module/safe/enums/ErrorCodeConstants.java

@@ -0,0 +1,16 @@
+package cn.iocoder.yudao.module.safe.enums;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+
+/**
+ * 安防 错误码 Core 枚举类
+ *
+ * 安防 系统,使用 1-010-000-000 段
+ */
+public interface ErrorCodeConstants {
+    // ========== 安防后端设备 1_010_01_000 ==========
+    ErrorCode SERVER_NOT_EXISTS = new ErrorCode(1_010_01_000, "安防后端设备不存在");
+
+    // ========== 安防前端设备 1_010_02_000 ==========
+    ErrorCode CAMERA_NOT_EXISTS = new ErrorCode(1_010_02_000, "安防前端设备不存在");
+}

+ 51 - 0
yudao-module-safe/yudao-module-safe-biz/pom.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>yudao-module-safe</artifactId>
+        <groupId>cn.iocoder.boot</groupId>
+        <version>${revision}</version> <!-- 1. 修改 version 为 ${revision} -->
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>jar</packaging> <!-- 2. 新增 packaging 为 jar -->
+
+    <artifactId>yudao-module-safe-biz</artifactId>
+
+    <name>${project.artifactId}</name> <!-- 3. 新增 name 为 ${project.artifactId} -->
+    <description> <!-- 4. 新增 description 为该模块的描述 -->
+        安防设备接入模块,主要实现 后端、前端的安防设备管理 等功能。
+    </description>
+
+    <dependencies>  <!-- 5. 新增依赖,这里引入的都是比较常用的业务组件、技术组件 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-module-safe-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-excel</artifactId>
+        </dependency>
+
+        <!-- Web 相关 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-security</artifactId>
+        </dependency>
+
+        <!-- DB 相关 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-mybatis</artifactId>
+        </dependency>
+
+    </dependencies>
+
+</project>

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

@@ -0,0 +1,88 @@
+package cn.iocoder.yudao.module.safe.controller.admin.camera;
+
+import org.springframework.web.bind.annotation.*;
+import jakarta.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import jakarta.validation.*;
+import jakarta.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
+
+import cn.iocoder.yudao.module.safe.controller.admin.camera.vo.*;
+import cn.iocoder.yudao.module.safe.dal.dataobject.camera.SafeCameraDO;
+import cn.iocoder.yudao.module.safe.service.camera.SafeCameraService;
+
+@Tag(name = "用户 APP - 安防前端设备")
+@RestController
+@RequestMapping("/safe/camera")
+@Validated
+public class AppSafeCameraController {
+
+    @Resource
+    private SafeCameraService cameraService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建安防前端设备")
+    public CommonResult<Long> createCamera(@Valid @RequestBody AppSafeCameraSaveReqVO createReqVO) {
+        return success(cameraService.createCamera(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新安防前端设备")
+    public CommonResult<Boolean> updateCamera(@Valid @RequestBody AppSafeCameraSaveReqVO updateReqVO) {
+        cameraService.updateCamera(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除安防前端设备")
+    @Parameter(name = "id", description = "编号", required = true)
+    public CommonResult<Boolean> deleteCamera(@RequestParam("id") Long id) {
+        cameraService.deleteCamera(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得安防前端设备")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    public CommonResult<AppSafeCameraRespVO> getCamera(@RequestParam("id") Long id) {
+        SafeCameraDO camera = cameraService.getCamera(id);
+        return success(BeanUtils.toBean(camera, AppSafeCameraRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得安防前端设备分页")
+    public CommonResult<PageResult<AppSafeCameraRespVO>> getCameraPage(@Valid AppSafeCameraPageReqVO pageReqVO) {
+        PageResult<SafeCameraDO> pageResult = cameraService.getCameraPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, AppSafeCameraRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出安防前端设备 Excel")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportCameraExcel(@Valid AppSafeCameraPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<SafeCameraDO> list = cameraService.getCameraPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "安防前端设备.xls", "数据", AppSafeCameraRespVO.class,
+                        BeanUtils.toBean(list, AppSafeCameraRespVO.class));
+    }
+
+}

+ 28 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/vo/AppSafeCameraPageReqVO.java

@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.safe.controller.admin.camera.vo;
+
+import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+
+@Schema(description = "用户 APP - 安防前端设备分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class AppSafeCameraPageReqVO extends PageParam {
+
+    @Schema(description = "名称", example = "李四")
+    private String name;
+
+    @Schema(description = "编号")
+    private String code;
+
+    @Schema(description = "类型")
+    private String type;
+
+    @Schema(description = "后端设备", example = "30230")
+    private Long serverId;
+
+    @Schema(description = "描述")
+    private String des;
+
+}

+ 57 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/vo/AppSafeCameraRespVO.java

@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.safe.controller.admin.camera.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import com.alibaba.excel.annotation.*;
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
+
+@Schema(description = "用户 APP - 安防前端设备 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class AppSafeCameraRespVO {
+
+    @Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9770")
+    @ExcelProperty("设备ID")
+    private Long id;
+
+    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @ExcelProperty("名称")
+    private String name;
+
+    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("编号")
+    private String code;
+
+    @Schema(description = "排序")
+    @ExcelProperty("排序")
+    private Integer sort;
+
+    @Schema(description = "类型")
+    @ExcelProperty(value = "类型", converter = DictConvert.class)
+    @DictFormat("safe_camera_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
+    private String type;
+
+    @Schema(description = "后端设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "30230")
+    @ExcelProperty("后端设备")
+    private Long serverId;
+
+    @Schema(description = "AI模型")
+    @ExcelProperty(value = "AI模型", converter = DictConvert.class)
+    @DictFormat("safe_ai_mode") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
+    private String aiMode;
+
+    @Schema(description = "报警状态")
+    @ExcelProperty(value = "报警状态", converter = DictConvert.class)
+    @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
+    private String warn;
+
+    @Schema(description = "报警接口")
+    @ExcelProperty("报警接口")
+    private String warnApi;
+
+    @Schema(description = "描述")
+    @ExcelProperty("描述")
+    private String des;
+
+}

+ 44 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/camera/vo/AppSafeCameraSaveReqVO.java

@@ -0,0 +1,44 @@
+package cn.iocoder.yudao.module.safe.controller.admin.camera.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import jakarta.validation.constraints.*;
+
+@Schema(description = "用户 APP - 安防前端设备新增/修改 Request VO")
+@Data
+public class AppSafeCameraSaveReqVO {
+
+    @Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9770")
+    private Long id;
+
+    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @NotEmpty(message = "名称不能为空")
+    private String name;
+
+    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "编号不能为空")
+    private String code;
+
+    @Schema(description = "排序")
+    private Integer sort;
+
+    @Schema(description = "类型")
+    private String type;
+
+    @Schema(description = "后端设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "30230")
+    @NotNull(message = "后端设备不能为空")
+    private Long serverId;
+
+    @Schema(description = "AI模型")
+    private String aiMode;
+
+    @Schema(description = "报警状态")
+    private String warn;
+
+    @Schema(description = "报警接口")
+    private String warnApi;
+
+    @Schema(description = "描述")
+    private String des;
+
+}

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

@@ -0,0 +1,95 @@
+package cn.iocoder.yudao.module.safe.controller.admin.server;
+
+import org.springframework.web.bind.annotation.*;
+import jakarta.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import jakarta.validation.*;
+import jakarta.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
+
+import cn.iocoder.yudao.module.safe.controller.admin.server.vo.*;
+import cn.iocoder.yudao.module.safe.dal.dataobject.server.SafeServerDO;
+import cn.iocoder.yudao.module.safe.service.server.SafeServerService;
+
+@Tag(name = "用户 APP - 安防后端设备")
+@RestController
+@RequestMapping("/safe/server")
+@Validated
+public class AppSafeServerController {
+
+    @Resource
+    private SafeServerService serverService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建安防后端设备")
+    public CommonResult<Long> createServer(@Valid @RequestBody AppSafeServerSaveReqVO createReqVO) {
+        return success(serverService.createServer(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新安防后端设备")
+    public CommonResult<Boolean> updateServer(@Valid @RequestBody AppSafeServerSaveReqVO updateReqVO) {
+        serverService.updateServer(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除安防后端设备")
+    @Parameter(name = "id", description = "编号", required = true)
+    public CommonResult<Boolean> deleteServer(@RequestParam("id") Long id) {
+        serverService.deleteServer(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得安防后端设备")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    public CommonResult<AppSafeServerRespVO> getServer(@RequestParam("id") Long id) {
+        SafeServerDO server = serverService.getServer(id);
+        return success(BeanUtils.toBean(server, AppSafeServerRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得安防后端设备分页")
+    public CommonResult<PageResult<AppSafeServerRespVO>> getServerPage(@Valid AppSafeServerPageReqVO pageReqVO) {
+        PageResult<SafeServerDO> pageResult = serverService.getServerPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, AppSafeServerRespVO.class));
+    }
+
+    @GetMapping("/list")
+    @Operation(summary = "获得所有安防后端设备")
+    public CommonResult<List<AppSafeServerRespVO>> getAllServer() {
+        List<SafeServerDO> list = serverService.getAllServer();
+        return success(BeanUtils.toBean(list, AppSafeServerRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出安防后端设备 Excel")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportServerExcel(@Valid AppSafeServerPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<SafeServerDO> list = serverService.getServerPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "安防后端设备.xls", "数据", AppSafeServerRespVO.class,
+                        BeanUtils.toBean(list, AppSafeServerRespVO.class));
+    }
+
+}

+ 31 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/vo/AppSafeServerPageReqVO.java

@@ -0,0 +1,31 @@
+package cn.iocoder.yudao.module.safe.controller.admin.server.vo;
+
+import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+
+@Schema(description = "用户 APP - 安防后端设备分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class AppSafeServerPageReqVO extends PageParam {
+
+    @Schema(description = "名称")
+    private String name;
+
+    @Schema(description = "类型")
+    private String type;
+
+    @Schema(description = "品牌")
+    private String brand;
+
+    @Schema(description = "型号")
+    private String model;
+
+    @Schema(description = "所属机构")
+    private Long orgId;
+
+    @Schema(description = "描述")
+    private String des;
+
+}

+ 68 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/vo/AppSafeServerRespVO.java

@@ -0,0 +1,68 @@
+package cn.iocoder.yudao.module.safe.controller.admin.server.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import com.alibaba.excel.annotation.*;
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
+
+@Schema(description = "用户 APP - 安防后端设备 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class AppSafeServerRespVO {
+
+    @Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9770")
+    @ExcelProperty("设备ID")
+    private Long id;
+
+    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("名称")
+    private String name;
+
+    @Schema(description = "类型")
+    @ExcelProperty(value = "类型", converter = DictConvert.class)
+    @DictFormat("safe_device_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
+    private String type;
+
+    @Schema(description = "品牌")
+    @ExcelProperty("品牌")
+    private String brand;
+
+    @Schema(description = "型号")
+    @ExcelProperty("型号")
+    private String model;
+
+    @Schema(description = "所属机构")
+    @ExcelProperty("所属机构")
+    private Long orgId;
+
+    @Schema(description = "接入协议", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty(value = "接入协议", converter = DictConvert.class)
+    @DictFormat("safe_device_protocol") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
+    private String protocol;
+
+    @Schema(description = "地址", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("地址")
+    private String ip;
+
+    @Schema(description = "端口", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("端口")
+    private Integer port;
+
+    @Schema(description = "服务域", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("服务域")
+    private String domain;
+
+    @Schema(description = "用户名")
+    @ExcelProperty("用户名")
+    private String username;
+
+    @Schema(description = "密码")
+    @ExcelProperty("密码")
+    private String password;
+
+    @Schema(description = "描述")
+    @ExcelProperty("描述")
+    private String desc;
+
+}

+ 55 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/controller/admin/server/vo/AppSafeServerSaveReqVO.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.safe.controller.admin.server.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import jakarta.validation.constraints.*;
+
+@Schema(description = "用户 APP - 安防后端设备新增/修改 Request VO")
+@Data
+public class AppSafeServerSaveReqVO {
+
+    @Schema(description = "服务ID", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Long id;
+
+    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "名称不能为空")
+    private String name;
+
+    @Schema(description = "类型")
+    private String type;
+
+    @Schema(description = "品牌")
+    private String brand;
+
+    @Schema(description = "型号")
+    private String model;
+
+    @Schema(description = "所属机构")
+    private Long orgId;
+
+    @Schema(description = "接入协议", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "接入协议不能为空")
+    private String protocol;
+
+    @Schema(description = "地址", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "地址不能为空")
+    private String ip;
+
+    @Schema(description = "端口", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "端口不能为空")
+    private Integer port;
+
+    @Schema(description = "服务域", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "服务域不能为空")
+    private String domain;
+
+    @Schema(description = "用户名")
+    private String username;
+
+    @Schema(description = "密码")
+    private String password;
+
+    @Schema(description = "描述")
+    private String desc;
+
+}

+ 75 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/dataobject/camera/SafeCameraDO.java

@@ -0,0 +1,75 @@
+package cn.iocoder.yudao.module.safe.dal.dataobject.camera;
+
+import lombok.*;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 安防前端设备 DO
+ *
+ * @author caoyang
+ */
+@TableName("pro_econ_safe_camera")
+@KeySequence("pro_econ_safe_camera_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SafeCameraDO extends BaseDO {
+
+    /**
+     * 设备ID
+     */
+    @TableId
+    private Long id;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 编号
+     */
+    private String code;
+    /**
+     * 排序
+     */
+    private Integer sort;
+    /**
+     * 类型
+     *
+     * 枚举 {@link TODO safe_camera_type 对应的类}
+     */
+    @TableField("type_dict")
+    private String type;
+    /**
+     * 后端设备
+     */
+    private Long serverId;
+    /**
+     * AI模型
+     *
+     * 枚举 {@link TODO safe_ai_mode 对应的类}
+     */
+    @TableField("ai_mode_dict")
+    private String aiMode;
+    /**
+     * 报警状态
+     *
+     * 枚举 {@link TODO common_status 对应的类}
+     */
+    @TableField("warn_dict")
+    private String warn;
+    /**
+     * 报警接口
+     */
+    private String warnApi;
+    /**
+     * 描述
+     */
+    @TableField("description")
+    private String des;
+
+}

+ 84 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/java/cn/iocoder/yudao/module/safe/dal/dataobject/server/SafeServerDO.java

@@ -0,0 +1,84 @@
+package cn.iocoder.yudao.module.safe.dal.dataobject.server;
+
+import lombok.*;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 安防后端设备 DO
+ *
+ * @author caoyang
+ */
+@TableName("pro_econ_safe_server")
+@KeySequence("pro_econ_safe_server_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SafeServerDO extends BaseDO {
+
+    /**
+     * 服务ID
+     */
+    @TableId
+    private Long id;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 类型
+     *
+     * 枚举 {@link TODO safe_device_type 对应的类}
+     */
+    @TableField("type_dict")
+    private String type;
+    /**
+     * 品牌
+     */
+    private String brand;
+    /**
+     * 型号
+     */
+    private String model;
+    /**
+     * 所属机构
+     */
+    private Long orgId;
+    /**
+     * 接入协议
+     *
+     * 枚举 {@link TODO safe_device_protocol 对应的类}
+     */
+    @TableField("protocol_dict")
+    private String protocol;
+    /**
+     * 地址
+     */
+    private String ip;
+    /**
+     * 端口
+     */
+    private Integer port;
+    /**
+     * 服务域
+     */
+    private String domain;
+    /**
+     * 用户名
+     */
+    private String username;
+    /**
+     * 密码
+     */
+    private String password;
+    /**
+     * 描述
+     */
+    @TableField("description")
+    private String des;
+
+}

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

@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.safe.dal.mysql.camera;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+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.*;
+
+/**
+ * 安防前端设备 Mapper
+ *
+ * @author caoyang
+ */
+@Mapper
+public interface SafeCameraMapper extends BaseMapperX<SafeCameraDO> {
+
+    default PageResult<SafeCameraDO> selectPage(AppSafeCameraPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<SafeCameraDO>()
+                .likeIfPresent(SafeCameraDO::getName, reqVO.getName())
+                .eqIfPresent(SafeCameraDO::getCode, reqVO.getCode())
+                .eqIfPresent(SafeCameraDO::getType, reqVO.getType())
+                .eqIfPresent(SafeCameraDO::getServerId, reqVO.getServerId())
+                .likeIfPresent(SafeCameraDO::getDes, reqVO.getDes())
+                .orderByDesc(SafeCameraDO::getId));
+    }
+
+}

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

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.safe.dal.mysql.server;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+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.*;
+
+/**
+ * 安防后端设备 Mapper
+ *
+ * @author caoyang
+ */
+@Mapper
+public interface SafeServerMapper extends BaseMapperX<SafeServerDO> {
+
+    default PageResult<SafeServerDO> selectPage(AppSafeServerPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<SafeServerDO>()
+                .likeIfPresent(SafeServerDO::getName, reqVO.getName())
+                .eqIfPresent(SafeServerDO::getType, reqVO.getType())
+                .eqIfPresent(SafeServerDO::getBrand, reqVO.getBrand())
+                .eqIfPresent(SafeServerDO::getModel, reqVO.getModel())
+                .eqIfPresent(SafeServerDO::getOrgId, reqVO.getOrgId())
+                .likeIfPresent(SafeServerDO::getDes, reqVO.getDes())
+                .orderByDesc(SafeServerDO::getId));
+    }
+
+}

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

@@ -0,0 +1,53 @@
+package cn.iocoder.yudao.module.safe.service.camera;
+
+import jakarta.validation.*;
+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;
+
+/**
+ * 安防前端设备 Service 接口
+ *
+ * @author caoyang
+ */
+public interface SafeCameraService {
+
+    /**
+     * 创建安防前端设备
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createCamera(@Valid AppSafeCameraSaveReqVO createReqVO);
+
+    /**
+     * 更新安防前端设备
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateCamera(@Valid AppSafeCameraSaveReqVO updateReqVO);
+
+    /**
+     * 删除安防前端设备
+     *
+     * @param id 编号
+     */
+    void deleteCamera(Long id);
+
+    /**
+     * 获得安防前端设备
+     *
+     * @param id 编号
+     * @return 安防前端设备
+     */
+    SafeCameraDO getCamera(Long id);
+
+    /**
+     * 获得安防前端设备分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 安防前端设备分页
+     */
+    PageResult<SafeCameraDO> getCameraPage(AppSafeCameraPageReqVO pageReqVO);
+
+}

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

@@ -0,0 +1,70 @@
+package cn.iocoder.yudao.module.safe.service.camera;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.safe.controller.admin.camera.vo.AppSafeCameraPageReqVO;
+import cn.iocoder.yudao.module.safe.controller.admin.camera.vo.AppSafeCameraSaveReqVO;
+import cn.iocoder.yudao.module.safe.dal.dataobject.camera.SafeCameraDO;
+import cn.iocoder.yudao.module.safe.dal.mysql.camera.SafeCameraMapper;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.safe.enums.ErrorCodeConstants.CAMERA_NOT_EXISTS;
+
+/**
+ * 安防前端设备 Service 实现类
+ *
+ * @author caoyang
+ */
+@Service
+@Validated
+public class SafeCameraServiceImpl implements SafeCameraService {
+
+    @Resource
+    private SafeCameraMapper cameraMapper;
+
+    @Override
+    public Long createCamera(AppSafeCameraSaveReqVO createReqVO) {
+        // 插入
+        SafeCameraDO camera = BeanUtils.toBean(createReqVO, SafeCameraDO.class);
+        cameraMapper.insert(camera);
+        // 返回
+        return camera.getId();
+    }
+
+    @Override
+    public void updateCamera(AppSafeCameraSaveReqVO updateReqVO) {
+        // 校验存在
+        validateCameraExists(updateReqVO.getId());
+        // 更新
+        SafeCameraDO updateObj = BeanUtils.toBean(updateReqVO, SafeCameraDO.class);
+        cameraMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteCamera(Long id) {
+        // 校验存在
+        validateCameraExists(id);
+        // 删除
+        cameraMapper.deleteById(id);
+    }
+
+    private void validateCameraExists(Long id) {
+        if (cameraMapper.selectById(id) == null) {
+            throw exception(CAMERA_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public SafeCameraDO getCamera(Long id) {
+        return cameraMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<SafeCameraDO> getCameraPage(AppSafeCameraPageReqVO pageReqVO) {
+        return cameraMapper.selectPage(pageReqVO);
+    }
+
+}

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

@@ -0,0 +1,61 @@
+package cn.iocoder.yudao.module.safe.service.server;
+
+import jakarta.validation.*;
+import cn.iocoder.yudao.module.safe.controller.admin.server.vo.*;
+import cn.iocoder.yudao.module.safe.dal.dataobject.server.SafeServerDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import java.util.List;
+
+/**
+ * 安防后端设备 Service 接口
+ *
+ * @author caoyang
+ */
+public interface SafeServerService {
+
+    /**
+     * 创建安防后端设备
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createServer(@Valid AppSafeServerSaveReqVO createReqVO);
+
+    /**
+     * 更新安防后端设备
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateServer(@Valid AppSafeServerSaveReqVO updateReqVO);
+
+    /**
+     * 删除安防后端设备
+     *
+     * @param id 编号
+     */
+    void deleteServer(Long id);
+
+    /**
+     * 获得安防后端设备
+     *
+     * @param id 编号
+     * @return 安防后端设备
+     */
+    SafeServerDO getServer(Long id);
+
+    /**
+     * 获得安防后端设备分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 安防后端设备分页
+     */
+    PageResult<SafeServerDO> getServerPage(AppSafeServerPageReqVO pageReqVO);
+
+    /**
+     * 获得所有后端设备信息
+     * @return
+     */
+    public List<SafeServerDO> getAllServer();
+
+}

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

@@ -0,0 +1,78 @@
+package cn.iocoder.yudao.module.safe.service.server;
+
+import org.springframework.stereotype.Service;
+import jakarta.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import cn.iocoder.yudao.module.safe.controller.admin.server.vo.*;
+import cn.iocoder.yudao.module.safe.dal.dataobject.server.SafeServerDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+import cn.iocoder.yudao.module.safe.dal.mysql.server.SafeServerMapper;
+
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.safe.enums.ErrorCodeConstants.*;
+
+/**
+ * 安防后端设备 Service 实现类
+ *
+ * @author caoyang
+ */
+@Service
+@Validated
+public class SafeServerServiceImpl implements SafeServerService {
+
+    @Resource
+    private SafeServerMapper serverMapper;
+
+    @Override
+    public Long createServer(AppSafeServerSaveReqVO createReqVO) {
+        // 插入
+        SafeServerDO server = BeanUtils.toBean(createReqVO, SafeServerDO.class);
+        serverMapper.insert(server);
+        // 返回
+        return server.getId();
+    }
+
+    @Override
+    public void updateServer(AppSafeServerSaveReqVO updateReqVO) {
+        // 校验存在
+        validateServerExists(updateReqVO.getId());
+        // 更新
+        SafeServerDO updateObj = BeanUtils.toBean(updateReqVO, SafeServerDO.class);
+        serverMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteServer(Long id) {
+        // 校验存在
+        validateServerExists(id);
+        // 删除
+        serverMapper.deleteById(id);
+    }
+
+    private void validateServerExists(Long id) {
+        if (serverMapper.selectById(id) == null) {
+            throw exception(SERVER_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public SafeServerDO getServer(Long id) {
+        return serverMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<SafeServerDO> getServerPage(AppSafeServerPageReqVO pageReqVO) {
+        return serverMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public List<SafeServerDO> getAllServer() {
+        return serverMapper.selectList();
+    }
+
+}

+ 12 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/resources/mapper/camera/SafeCameraMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.iocoder.yudao.module.safe.dal.mysql.camera.SafeCameraMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 12 - 0
yudao-module-safe/yudao-module-safe-biz/src/main/resources/mapper/server/SafeServerMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.iocoder.yudao.module.safe.dal.mysql.server.SafeServerMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 7 - 0
yudao-server/pom.xml

@@ -101,6 +101,13 @@
             <version>${revision}</version>
         </dependency>
 
+        <!-- 安防 相关模块。默认注释,保证编译速度 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-module-safe-biz</artifactId>
+            <version>${revision}</version>
+        </dependency>
+
         <!-- spring boot 配置所需依赖 -->
         <dependency>
             <groupId>org.springframework.boot</groupId>