index.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. // API 响应类型 - 基础响应(无数据)
  2. export interface BaseResponse {
  3. success: boolean
  4. errCode?: string
  5. errMessage?: string
  6. }
  7. // API 响应类型 - 单个数据响应
  8. export interface IBaseResponse<T> {
  9. data?: T
  10. success: boolean
  11. errCode?: string
  12. errMessage?: string
  13. }
  14. // API 响应类型 - 分页列表响应
  15. export interface IResponse<T> {
  16. success: boolean
  17. errCode?: string
  18. errMessage?: string
  19. data: {
  20. total: string
  21. list: T[]
  22. }
  23. }
  24. // 兼容旧代码 - ApiResponse 别名
  25. export type ApiResponse<T = any> = IResponse<T>
  26. // 分页参数(旧版,兼容)
  27. export interface PageParams {
  28. pageNum: number
  29. pageSize: number
  30. }
  31. // 分页响应(旧版,兼容)
  32. export interface PageResult<T = any> {
  33. total: number
  34. rows: T[]
  35. }
  36. // 分页请求参数(新版)
  37. export interface PageRequest {
  38. page?: number
  39. size?: number
  40. keyword?: string
  41. enabled?: boolean | null
  42. sortBy?: string
  43. sortDir?: 'ASC' | 'DESC'
  44. }
  45. // 分页响应(新版)
  46. export interface PageResponse<T> {
  47. list: T[]
  48. page: number
  49. size: number
  50. total: number
  51. totalPages: number
  52. hasNext: boolean
  53. hasPrevious: boolean
  54. }
  55. // 带分页的 API 响应
  56. export interface IPageResponse<T> {
  57. success: boolean
  58. errCode?: string
  59. errMessage?: string
  60. data: PageResponse<T>
  61. }
  62. // 列表 API 响应(数组形式)
  63. export interface IListResponse<T> {
  64. success: boolean
  65. errCode?: string
  66. errMessage?: string
  67. data: T[]
  68. }
  69. // 登录参数
  70. export interface LoginParams {
  71. username: string
  72. password: string
  73. }
  74. // 登录响应
  75. export interface LoginResponse {
  76. token: string
  77. tokenType: string
  78. expiresIn: number
  79. refreshToken?: string
  80. admin: AdminInfo
  81. }
  82. // 管理员信息
  83. export interface AdminInfo {
  84. id: number
  85. username: string
  86. nickname: string
  87. role: string
  88. lastLoginAt?: string
  89. }
  90. // 用户信息 (兼容旧代码)
  91. export interface UserInfo {
  92. id: number
  93. username: string
  94. nickname: string
  95. role: string
  96. lastLoginAt?: string
  97. }
  98. // 通道信息 (Controller 用)
  99. export interface ChannelDTO {
  100. channelId: string
  101. name: string
  102. rtspUrl: string
  103. defaultView: boolean
  104. status: 'ONLINE' | 'OFFLINE'
  105. cameraId: string
  106. }
  107. // 摄像头信息 (Controller 用)
  108. export interface CameraDTO {
  109. cameraId: string
  110. name: string
  111. machineId: string
  112. status: 'ONLINE' | 'OFFLINE'
  113. capability: 'switch_only' | 'ptz_enabled'
  114. ptzSupported: boolean
  115. channels: ChannelDTO[]
  116. }
  117. // 通道详情 (Admin 用)
  118. export interface ChannelInfoDTO {
  119. id: number
  120. channelId: string
  121. name: string
  122. rtspUrl: string
  123. defaultView: boolean
  124. status: 'ONLINE' | 'OFFLINE'
  125. }
  126. // 摄像头详情 (Admin 用)
  127. export interface CameraInfoDTO {
  128. id: number
  129. cameraId: string
  130. name: string
  131. ip: string
  132. port: number
  133. username: string
  134. brand: string
  135. capability: 'switch_only' | 'ptz_enabled'
  136. status: 'ONLINE' | 'OFFLINE'
  137. lssId?: string
  138. model?: string
  139. rtspUrl?: string
  140. channelNo?: string
  141. remark?: string
  142. machineId?: string
  143. machineName?: string
  144. enabled: boolean
  145. channels?: ChannelInfoDTO[]
  146. /**
  147. * 参数配置
  148. */
  149. paramConfig?: string
  150. /**
  151. * 运行参数
  152. */
  153. runtimeParams?: string
  154. createdAt: string
  155. updatedAt: string
  156. }
  157. // 添加摄像头请求
  158. export interface CameraAddRequest {
  159. cameraId: string
  160. name: string
  161. ip: string
  162. port?: number
  163. username?: string
  164. password?: string
  165. brand?: string
  166. capability?: 'switch_only' | 'ptz_enabled'
  167. machineId?: string
  168. lssId?: string
  169. model?: string
  170. rtspUrl?: string
  171. channelNo?: string
  172. remark?: string
  173. channels?: ChannelAddRequest[]
  174. }
  175. // 添加通道请求
  176. export interface ChannelAddRequest {
  177. channelId: string
  178. name: string
  179. rtspUrl?: string
  180. defaultView?: boolean
  181. }
  182. // 更新摄像头请求
  183. export interface CameraUpdateRequest {
  184. id: number
  185. name?: string
  186. ip?: string
  187. port?: number
  188. username?: string
  189. password?: string
  190. brand?: string
  191. capability?: 'switch_only' | 'ptz_enabled'
  192. machineId?: string
  193. lssId?: string
  194. model?: string
  195. rtspUrl?: string
  196. channelNo?: string
  197. remark?: string
  198. enabled?: boolean
  199. paramConfig?: string
  200. runtimeParams?: string
  201. channels?: ChannelUpdateRequest[]
  202. }
  203. // 更新通道请求
  204. export interface ChannelUpdateRequest {
  205. id?: number
  206. channelId?: string
  207. name?: string
  208. rtspUrl?: string
  209. defaultView?: boolean
  210. }
  211. // 切换通道请求
  212. export interface SwitchChannelRequest {
  213. machineId: string
  214. channelId: string
  215. }
  216. // 机器信息
  217. export interface MachineDTO {
  218. id: number
  219. machineId: string
  220. name: string
  221. location: string
  222. description: string
  223. enabled: boolean
  224. cameraCount: number
  225. createdAt: string
  226. updatedAt: string
  227. }
  228. // 添加机器请求
  229. export interface MachineAddRequest {
  230. machineId: string
  231. name: string
  232. location?: string
  233. description?: string
  234. }
  235. // 更新机器请求
  236. export interface MachineUpdateRequest {
  237. id: number
  238. name?: string
  239. location?: string
  240. description?: string
  241. enabled?: boolean
  242. }
  243. // 仪表盘统计
  244. export interface DashboardStatsDTO {
  245. machineTotal: number
  246. machineEnabled: number
  247. cameraTotal: number
  248. cameraOnline: number
  249. cameraOffline: number
  250. channelTotal: number
  251. }
  252. // 修改密码请求
  253. export interface ChangePasswordRequest {
  254. oldPassword: string
  255. newPassword: string
  256. }
  257. // PTZ 动作类型
  258. export type PTZAction =
  259. | 'up'
  260. | 'down'
  261. | 'left'
  262. | 'right'
  263. | 'zoom_in'
  264. | 'zoom_out'
  265. | 'stop'
  266. | 'UP'
  267. | 'DOWN'
  268. | 'LEFT'
  269. | 'RIGHT'
  270. | 'ZOOM_IN'
  271. | 'ZOOM_OUT'
  272. | 'STOP'
  273. // PTZ 直接控制请求 (pan/tilt/zoom 方式)
  274. export interface PTZControlRequest {
  275. pan?: number // 水平移动速度 -100 ~ 100
  276. tilt?: number // 垂直移动速度 -100 ~ 100
  277. zoom?: number // 缩放速度 -100 ~ 100
  278. channel?: number // 通道号(可选)
  279. }
  280. // Admin PTZ 控制请求
  281. export interface AdminPTZRequest {
  282. id: number
  283. action: PTZAction
  284. speed?: number // 0.0 - 1.0
  285. }
  286. // 摄像头列表请求参数
  287. export interface CameraListRequest extends PageRequest {
  288. machineId?: string
  289. lssId?: string
  290. status?: 'ONLINE' | 'OFFLINE'
  291. enabled?: boolean
  292. }
  293. // 机器列表请求参数
  294. export interface MachineListRequest extends PageRequest {
  295. // 继承 PageRequest 的所有属性
  296. }
  297. // 兼容旧代码的类型别名
  298. export type CameraDevice = CameraInfoDTO
  299. export type CameraChannel = ChannelInfoDTO
  300. // 播放响应 (保留用于视频播放)
  301. export interface PlayResponse {
  302. streamId: string
  303. flv: string
  304. ws_flv?: string
  305. rtsp?: string
  306. rtmp?: string
  307. hls?: string
  308. rtc?: string
  309. mediaServerId?: string
  310. deviceId?: string
  311. channelId?: string
  312. }
  313. // 录像记录 (保留用于视频回放)
  314. export interface RecordItem {
  315. name?: string
  316. start: number
  317. end: number
  318. secrecy?: number
  319. type?: string
  320. }
  321. // ==================== LSS 节点相关类型 ====================
  322. // LSS 节点状态
  323. export type LssNodeStatus = 'hold' | 'active' | 'dead'
  324. // LSS 节点信息 (新 API)
  325. export interface LssNodeDTO {
  326. id: number
  327. lssId: string
  328. lssName: string
  329. machineId?: string
  330. address: string
  331. publicIp?: string
  332. maxTasks: number
  333. currentTasks: number
  334. status: LssNodeStatus
  335. heartbeat?: LssHeartbeatStatus
  336. heartbeatTime?: string
  337. ablyInfo?: string
  338. ffmpegVersion?: string
  339. systemInfo?: string
  340. enabled: boolean
  341. createdAt: string
  342. updatedAt: string
  343. }
  344. // LSS 节点列表请求参数
  345. export interface LssNodeListRequest extends PageRequest {
  346. status?: LssNodeStatus
  347. machineId?: string
  348. }
  349. // LSS 节点统计信息
  350. export interface LssNodeStatsDTO {
  351. total: number
  352. online: number
  353. offline: number
  354. busy: number
  355. maintenance: number
  356. }
  357. // 兼容旧代码 - LSS 心跳状态
  358. export type LssHeartbeatStatus = 'active' | 'hold' | 'dead'
  359. // 兼容旧代码 - LSS 信息 (旧 API)
  360. export interface LssDTO {
  361. id: number
  362. lssId: string
  363. name: string
  364. address: string
  365. publicIp?: string
  366. heartbeat?: LssHeartbeatStatus
  367. heartbeatTime?: string
  368. ablyInfo?: string
  369. }
  370. // 兼容旧代码 - LSS 列表请求参数
  371. export interface LssListRequest extends PageRequest {
  372. heartbeat?: LssHeartbeatStatus
  373. }
  374. // ==================== StreamChannel 推流通道相关类型 (Cloudflare Stream) ====================
  375. // 推流模式
  376. export type StreamChannelMode = 'WHIP' | 'RTMPS' | 'SRT'
  377. // 推流通道信息 (StreamChannelInfoDTO)
  378. export interface StreamChannelDTO {
  379. id: number
  380. channelId: string
  381. name: string
  382. accountId?: string
  383. liveInputId?: string
  384. customerSubdomain?: string
  385. mode?: StreamChannelMode
  386. whipUrl?: string
  387. rtmpsUrl?: string
  388. hlsPlaybackUrl?: string
  389. whepPlaybackUrl?: string
  390. recordingEnabled?: boolean
  391. enabled: boolean
  392. createdAt: string
  393. updatedAt: string
  394. }
  395. // 推流通道列表请求参数
  396. export interface StreamChannelListRequest extends PageRequest {
  397. // 继承 PageRequest 的所有属性 (page, size, keyword, enabled, sortBy, sortDir)
  398. }
  399. // 创建推流通道请求
  400. export interface StreamChannelAddRequest {
  401. channelId: string
  402. name: string
  403. accountId?: string
  404. apiToken?: string
  405. liveInputId: string
  406. streamKey?: string
  407. customerSubdomain: string
  408. mode?: StreamChannelMode
  409. recordingEnabled?: boolean
  410. }
  411. // 更新推流通道请求
  412. export interface StreamChannelUpdateRequest {
  413. id: number
  414. name?: string
  415. accountId?: string
  416. apiToken?: string
  417. liveInputId?: string
  418. streamKey?: string
  419. customerSubdomain?: string
  420. mode?: StreamChannelMode
  421. recordingEnabled?: boolean
  422. enabled?: boolean
  423. }
  424. // ==================== LiveStream 推流管理相关类型 ====================
  425. // LiveStream 状态
  426. // IDLE("idle", "空闲"),
  427. // /**
  428. // * 启动中 - FFmpeg进程正在启动
  429. // */
  430. // STARTING("starting", "启动中"),
  431. // /**
  432. // * 推流中 - 正常推流
  433. // */
  434. // STREAMING("streaming", "推流中"),
  435. // /**
  436. // * 停止中 - 正在停止推流
  437. // */
  438. // STOPPING("stopping", "停止中"),
  439. // /**
  440. // * 已停止 - 推流已停止
  441. // */
  442. // STOPPED("stopped", "已停止"),
  443. // /**
  444. // * 错误 - 推流发生错误
  445. // */
  446. // ERROR("error", "错误"),
  447. // /**
  448. // * 重连中 - 正在重新连接
  449. // */
  450. // RECONNECTING("reconnecting", "重连中");
  451. export type LiveStreamStatus = 'idle' | 'streaming'
  452. // 'IDLE' | 'STREAMING' | 'STOPPED' | 'ERROR'
  453. /**
  454. * 空闲 - 未开始推流
  455. */
  456. // LiveStream 信息 (LiveStreamInfoDTO)
  457. export interface LiveStreamDTO {
  458. id: number
  459. streamSn: string
  460. name: string
  461. lssId?: string
  462. cameraId?: string
  463. channelId?: number
  464. pushMethod?: string
  465. commandTemplate?: string
  466. timeoutSeconds?: number
  467. status: LiveStreamStatus
  468. enabled: boolean
  469. remark?: string
  470. createdAt: string
  471. updatedAt: string
  472. taskStreamSn?: string
  473. playbackUrl?: string
  474. }
  475. // LiveStream 列表请求参数
  476. export interface LiveStreamListRequest extends PageRequest {
  477. // 继承 PageRequest 的所有属性 (page, size, keyword, enabled, sortBy, sortDir)
  478. }
  479. // 创建 LiveStream 请求
  480. export interface LiveStreamAddRequest {
  481. name: string
  482. lssId: string
  483. cameraId?: string
  484. channelId?: number
  485. pushMethod?: string
  486. commandTemplate?: string
  487. timeoutSeconds?: number
  488. remark?: string
  489. }
  490. // 更新 LiveStream 请求
  491. export interface LiveStreamUpdateRequest {
  492. id: number
  493. name?: string
  494. lssId?: string
  495. cameraId?: string
  496. channelId?: number
  497. pushMethod?: string
  498. commandTemplate?: string
  499. timeoutSeconds?: number
  500. enabled?: boolean
  501. remark?: string
  502. }
  503. // ==================== 摄像头厂家相关类型 ====================
  504. // 摄像头厂家信息
  505. export interface CameraVendorDTO {
  506. id: number
  507. code: string
  508. name: string
  509. description?: string
  510. logoUrl?: string
  511. supportOnvif: boolean
  512. supportPtz: boolean
  513. supportIsapi: boolean
  514. supportGb28181: boolean
  515. supportAudio: boolean
  516. resolution?: string
  517. defaultPort?: number
  518. defaultRtspPort?: number
  519. rtspUrlTemplate?: string
  520. enabled: boolean
  521. sortOrder?: number
  522. createdAt: string
  523. updatedAt: string
  524. }
  525. // 摄像头厂家列表请求参数
  526. export interface CameraVendorListRequest extends PageRequest {
  527. // 继承 PageRequest 的所有属性
  528. }
  529. // 创建摄像头厂家请求
  530. export interface CameraVendorAddRequest {
  531. code: string
  532. name: string
  533. description?: string
  534. logoUrl?: string
  535. supportOnvif?: boolean
  536. supportPtz?: boolean
  537. supportIsapi?: boolean
  538. supportGb28181?: boolean
  539. supportAudio?: boolean
  540. resolution?: string
  541. defaultPort?: number
  542. defaultRtspPort?: number
  543. rtspUrlTemplate?: string
  544. enabled?: boolean
  545. sortOrder?: number
  546. }
  547. // 更新摄像头厂家请求
  548. export interface CameraVendorUpdateRequest {
  549. id: number
  550. code: string
  551. name: string
  552. description?: string
  553. logoUrl?: string
  554. supportOnvif?: boolean
  555. supportPtz?: boolean
  556. supportIsapi?: boolean
  557. supportGb28181?: boolean
  558. supportAudio?: boolean
  559. resolution?: string
  560. defaultPort?: number
  561. defaultRtspPort?: number
  562. rtspUrlTemplate?: string
  563. enabled?: boolean
  564. sortOrder?: number
  565. }
  566. // ==================== 推流服务相关类型 (Stream Push) ====================
  567. // 本地视频推流 DTO
  568. export interface LocalVideoStreamDTO {
  569. streamName: string
  570. sourceType: 'local_video' | 'rtsp_camera'
  571. sourcePath: string
  572. rtspUrl?: string
  573. loop: boolean
  574. streamTaskId?: string
  575. playbackUrl?: string
  576. status: string
  577. }
  578. // 启动本地视频推流请求
  579. export interface StartLocalStreamRequest {
  580. streamName?: string
  581. videoPath?: string
  582. loop?: boolean
  583. targetChannelId?: string
  584. }
  585. // 推流任务状态
  586. export type StreamTaskStatus = 'IDLE' | 'STARTING' | 'STREAMING' | 'STOPPED' | 'ERROR'
  587. // 推流任务 DTO
  588. export interface StreamTaskDTO {
  589. streamSn: string
  590. name: string
  591. lssId: string
  592. cameraId: string
  593. sourceRtspUrl: string
  594. profile: 'low_latency' | 'standard' | 'file_loop'
  595. whipUrl: string
  596. playbackUrl: string
  597. status: StreamTaskStatus
  598. statusDescription?: string
  599. errorMessage?: string
  600. retryCount: number
  601. remark?: string
  602. createdAt: string
  603. startedAt?: string
  604. stoppedAt?: string
  605. }
  606. // 启动推流任务请求
  607. export interface StartStreamTaskRequest {
  608. name?: string
  609. lssId?: string
  610. cameraId: string
  611. sourceRtspUrl?: string
  612. profile?: 'low_latency' | 'standard' | 'file_loop'
  613. whipUrl?: string
  614. playbackUrl?: string
  615. remark?: string
  616. }
  617. // 停止推流任务请求
  618. export interface StopStreamTaskRequest {
  619. taskId?: string
  620. lssId?: string
  621. }
  622. // 切换推流源请求
  623. export interface SwitchStreamSourceRequest {
  624. streamSn: string
  625. newCameraId: string
  626. newRtspUrl: string
  627. }
  628. // 推流通道信息 DTO (推流服务用)
  629. export interface StreamPushChannelDTO {
  630. channelId: string
  631. name: string
  632. mode: 'WHIP' | 'RTMPS'
  633. hlsPlaybackUrl?: string
  634. recordingEnabled: boolean
  635. }
  636. // 播放信息 DTO
  637. export interface PlaybackInfoDTO {
  638. streamSn: string
  639. name: string
  640. status: StreamTaskStatus
  641. whepUrl?: string
  642. hlsUrl?: string
  643. iframeCode?: string
  644. isLive: boolean
  645. }