소스 검색

refactor(camera): update camera data structure and submission process

- Refactored the CameraInfoDTO and CameraAddRequest interfaces to use optional properties for better flexibility and compatibility with existing data.
- Renamed attributes in the camera submission process to align with the updated interface, including changing 'name' to 'cameraName' and adding 'vendorName'.
- Enhanced the clarity of the code by introducing new types for camera capabilities and heartbeat statuses.
yb 1 주 전
부모
커밋
f25299e54b
3개의 변경된 파일32개의 추가작업 그리고 60개의 파일을 삭제
  1. 27 41
      src/types/index.ts
  2. 1 8
      src/views/camera/index.vue
  3. 4 11
      src/views/lss/index.vue

+ 27 - 41
src/types/index.ts

@@ -140,55 +140,41 @@ export interface ChannelInfoDTO {
   status: 'ONLINE' | 'OFFLINE'
 }
 
+export type CameraCapability = 'switch_only' | 'ptz_enabled'
+export type CameraHeartbeatStatus = 'active' | 'hold' | 'dead'
+
 // 摄像头详情 (Admin 用)
 export interface CameraInfoDTO {
-  id: number
-  cameraId: string
-  name: string
-  ip: string
-  port: number
-  username: string
-  brand: string
-  capability: 'switch_only' | 'ptz_enabled'
-  status: 'active' | 'hold' | 'dead'
-  lssId?: string
-  model?: string
-  rtspUrl?: string
-  channelNo?: string
-  remark?: string
-  machineId?: string
-  machineName?: string
-  enabled: boolean
-  channels?: ChannelInfoDTO[]
-  /**
-   * 参数配置
-   */
-  paramConfig?: string
-  /**
-   * 运行参数
-   */
-  runtimeParams?: string
-  createdAt: string
-  updatedAt: string
+  id?: number // 主键ID
+  cameraId?: string // 摄像头ID
+  cameraName?: string // 设备名称
+  ip?: string // IP地址
+  port?: number // 端口
+  username?: string // 用户名
+  vendorName?: string // 厂商名称
+  brand?: string // 品牌(兼容旧数据)
+  capability?: CameraCapability // 能力
+  status?: CameraHeartbeatStatus // 心跳状态
+  lssId?: string // 绑定的 LSS 节点 ID
+  model?: string // 摄像头型号
+  rtspUrl?: string // RTSP 推流地址
+  channelNo?: string // 通道号
+  remark?: string // 备注
+  paramConfig?: string // 参数配置 JSON 字符串
+  runtimeParams?: string // 设备运行参数 JSON 字符串
+  enabled?: boolean // 是否启用
+  createdAt?: string // 创建时间(ISO)
+  updatedAt?: string // 更新时间(ISO)
 }
 
 // 添加摄像头请求
 export interface CameraAddRequest {
   cameraId: string
-  name: string
-  ip: string
-  port?: number
-  username?: string
-  password?: string
-  brand?: string
-  capability?: 'switch_only' | 'ptz_enabled'
-  machineId?: string
-  lssId?: string
+  cameraName?: string
+  vendorName?: string
   model?: string
-  rtspUrl?: string
-  channelNo?: string
-  remark?: string
-  channels?: ChannelAddRequest[]
+  paramConfig?: string
+  runtimeParams?: string
 }
 
 // 添加通道请求

+ 1 - 8
src/views/camera/index.vue

@@ -628,14 +628,7 @@ async function handleSubmit() {
         } else {
           const addData: CameraAddRequest = {
             cameraId: form.cameraId,
-            name: form.name,
-            ip: form.ip,
-            port: form.port,
-            username: form.username,
-            password: form.password || undefined,
-            brand: form.brand,
-            capability: form.capability,
-            machineId: form.machineId || undefined
+            cameraName: form.name
           }
           const res = await adminAddCamera(addData)
           if (res.success) {

+ 4 - 11
src/views/lss/index.vue

@@ -1141,18 +1141,11 @@ async function handleSubmitCamera() {
         // 新增模式:创建摄像头并绑定到当前 LSS
         const data: CameraAddRequest = {
           cameraId: cameraForm.cameraId,
-          name: cameraForm.name,
-          ip: cameraForm.ip,
-          port: cameraForm.port,
-          username: cameraForm.username,
-          password: cameraForm.password,
-          brand: cameraForm.brand,
-          capability: cameraForm.capability,
-          lssId: currentLss.value?.lssId,
-          rtspUrl: cameraForm.rtspUrl,
+          cameraName: cameraForm.cameraName,
+          vendorName: cameraForm.vendorName,
           model: cameraForm.model,
-          channelNo: cameraForm.channelNo,
-          remark: cameraForm.remark
+          paramConfig: cameraForm.paramConfig,
+          runtimeParams: cameraForm.runtimeParams
         }
         const res = await adminAddCamera(data)
         if (res.success) {