index.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  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. export type CameraCapability = 'switch_only' | 'ptz_enabled'
  127. export type CameraHeartbeatStatus = 'active' | 'hold' | 'dead'
  128. // 摄像头详情 (Admin 用)
  129. export interface CameraInfoDTO extends CameraAddRequest {
  130. /* 主键ID */
  131. id?: number
  132. /* IP地址 */
  133. ip?: string
  134. /* 端口 */
  135. port?: number
  136. /* 用户名 */
  137. username?: string
  138. /* 品牌(兼容旧数据) */
  139. brand?: string
  140. /* 能力 */
  141. capability?: CameraCapability
  142. /* 心跳状态 */
  143. status?: CameraHeartbeatStatus
  144. /* 推流地址 */
  145. rtspUrl?: string
  146. /* 通道号 */
  147. channelNo?: string
  148. /* 备注 */
  149. remark?: string
  150. /* 是否启用 */
  151. enabled?: boolean
  152. /* 创建时间(ISO) */
  153. createdAt?: string
  154. /* 更新时间(ISO) */
  155. updatedAt?: string
  156. }
  157. // 添加摄像头请求
  158. export interface CameraAddRequest {
  159. /* 摄像头ID */
  160. cameraId?: string
  161. /* 设备名称 */
  162. cameraName?: string
  163. /* 参数配置 JSON 字符串 */
  164. paramConfig?: string
  165. /* 设备运行参数 JSON 字符串 */
  166. runtimeParams?: string
  167. /* 绑定的 LSS 节点 ID */
  168. lssId?: string
  169. /* 摄像头型号 */
  170. model?: string
  171. /* 厂商名称 */
  172. vendorName?: string
  173. }
  174. // 添加通道请求
  175. export interface ChannelAddRequest {
  176. channelId: string
  177. name: string
  178. rtspUrl?: string
  179. defaultView?: boolean
  180. }
  181. // 更新摄像头请求
  182. export interface CameraUpdateRequest {
  183. id: number
  184. name?: string
  185. ip?: string
  186. port?: number
  187. username?: string
  188. password?: string
  189. brand?: string
  190. capability?: 'switch_only' | 'ptz_enabled'
  191. machineId?: string
  192. lssId?: string
  193. model?: string
  194. rtspUrl?: string
  195. channelNo?: string
  196. remark?: string
  197. enabled?: boolean
  198. paramConfig?: string
  199. runtimeParams?: string
  200. channels?: ChannelUpdateRequest[]
  201. }
  202. // 更新通道请求
  203. export interface ChannelUpdateRequest {
  204. id?: number
  205. channelId?: string
  206. name?: string
  207. rtspUrl?: string
  208. defaultView?: boolean
  209. }
  210. // 切换通道请求
  211. export interface SwitchChannelRequest {
  212. machineId: string
  213. channelId: string
  214. }
  215. // 机器信息
  216. export interface MachineDTO {
  217. id: number
  218. machineId: string
  219. name: string
  220. location: string
  221. description: string
  222. enabled: boolean
  223. cameraCount: number
  224. createdAt: string
  225. updatedAt: string
  226. }
  227. // 添加机器请求
  228. export interface MachineAddRequest {
  229. machineId: string
  230. name: string
  231. location?: string
  232. description?: string
  233. }
  234. // 更新机器请求
  235. export interface MachineUpdateRequest {
  236. id: number
  237. name?: string
  238. location?: string
  239. description?: string
  240. enabled?: boolean
  241. }
  242. // 仪表盘统计
  243. export interface DashboardStatsDTO {
  244. machineTotal: number
  245. machineEnabled: number
  246. cameraTotal: number
  247. cameraOnline: number
  248. cameraOffline: number
  249. channelTotal: number
  250. }
  251. // 修改密码请求
  252. export interface ChangePasswordRequest {
  253. oldPassword: string
  254. newPassword: string
  255. }
  256. // PTZ 动作类型
  257. export type PTZAction =
  258. | 'up'
  259. | 'down'
  260. | 'left'
  261. | 'right'
  262. | 'zoom_in'
  263. | 'zoom_out'
  264. | 'stop'
  265. | 'UP'
  266. | 'DOWN'
  267. | 'LEFT'
  268. | 'RIGHT'
  269. | 'ZOOM_IN'
  270. | 'ZOOM_OUT'
  271. | 'STOP'
  272. // PTZ 直接控制请求 (pan/tilt/zoom 方式)
  273. export interface PTZControlRequest {
  274. pan?: number // 水平移动速度 -100 ~ 100
  275. tilt?: number // 垂直移动速度 -100 ~ 100
  276. zoom?: number // 缩放速度 -100 ~ 100
  277. channel?: number // 通道号(可选)
  278. }
  279. // Admin PTZ 控制请求
  280. export interface AdminPTZRequest {
  281. id: number
  282. action: PTZAction
  283. speed?: number // 0.0 - 1.0
  284. }
  285. // 摄像头列表请求参数
  286. export interface CameraListRequest extends PageRequest {
  287. machineId?: string
  288. lssId?: string
  289. status?: 'ONLINE' | 'OFFLINE'
  290. enabled?: boolean
  291. }
  292. // 机器列表请求参数
  293. export interface MachineListRequest extends PageRequest {
  294. // 继承 PageRequest 的所有属性
  295. }
  296. // 兼容旧代码的类型别名
  297. export type CameraDevice = CameraInfoDTO
  298. export type CameraChannel = ChannelInfoDTO
  299. // 播放响应 (保留用于视频播放)
  300. export interface PlayResponse {
  301. streamId: string
  302. flv: string
  303. ws_flv?: string
  304. rtsp?: string
  305. rtmp?: string
  306. hls?: string
  307. rtc?: string
  308. mediaServerId?: string
  309. deviceId?: string
  310. channelId?: string
  311. }
  312. // 录像记录 (保留用于视频回放)
  313. export interface RecordItem {
  314. name?: string
  315. start: number
  316. end: number
  317. secrecy?: number
  318. type?: string
  319. }
  320. // ==================== LSS 节点相关类型 ====================
  321. // LSS 节点状态
  322. export type LssNodeStatus = 'hold' | 'active' | 'dead'
  323. // LSS 节点信息 (新 API)
  324. export interface IAblyChannels {
  325. registry: string
  326. commandPrefix: string
  327. commandSuffix: string
  328. statusSuffix: string
  329. taskPrefix: string
  330. taskSuffix: string
  331. }
  332. export interface IAblyHeartbeat {
  333. intervalMs: number
  334. }
  335. export interface IAbly {
  336. apiKey: string
  337. channels: IAblyChannels
  338. heartbeat: IAblyHeartbeat
  339. }
  340. export interface LssNodeDTO {
  341. ably?: IAbly
  342. id: number
  343. lssId: string
  344. lssName: string
  345. machineId: string
  346. address: string
  347. ip: string
  348. maxTasks: number
  349. currentTasks: number
  350. loadRate: number
  351. status: LssNodeStatus
  352. ablyClientId?: string
  353. ablyConnected?: boolean
  354. lastAblyHeartbeat?: string
  355. lastHeartbeatAt?: string
  356. ffmpegVersion?: string
  357. systemInfo?: string
  358. enabled: boolean
  359. createdAt: string
  360. updatedAt: string
  361. }
  362. // LSS 节点列表请求参数
  363. export interface LssNodeListRequest extends PageRequest {
  364. status?: LssNodeStatus
  365. machineId?: string
  366. }
  367. // LSS 节点统计信息
  368. export interface LssNodeStatsDTO {
  369. total: number
  370. online: number
  371. offline: number
  372. busy: number
  373. maintenance: number
  374. }
  375. // 兼容旧代码 - LSS 心跳状态
  376. export type LssHeartbeatStatus = 'active' | 'hold' | 'dead'
  377. // 兼容旧代码 - LSS 信息 (旧 API)
  378. export interface LssDTO {
  379. id: number
  380. lssId: string
  381. name: string
  382. address: string
  383. publicIp?: string
  384. heartbeat?: LssHeartbeatStatus
  385. heartbeatTime?: string
  386. ablyInfo?: string
  387. }
  388. // 兼容旧代码 - LSS 列表请求参数
  389. export interface LssListRequest extends PageRequest {
  390. heartbeat?: LssHeartbeatStatus
  391. }
  392. // ==================== StreamChannel 推流通道相关类型 (Cloudflare Stream) ====================
  393. // 推流模式
  394. export type StreamChannelMode = 'WHIP' | 'RTMPS' | 'SRT'
  395. // 推流通道信息 (StreamChannelInfoDTO)
  396. export interface StreamChannelDTO {
  397. id: number
  398. channelId: string
  399. name: string
  400. accountId?: string
  401. liveInputId?: string
  402. customerSubdomain?: string
  403. mode?: StreamChannelMode
  404. whipUrl?: string
  405. rtmpsUrl?: string
  406. hlsPlaybackUrl?: string
  407. whepPlaybackUrl?: string
  408. recordingEnabled?: boolean
  409. enabled: boolean
  410. createdAt: string
  411. updatedAt: string
  412. }
  413. // 推流通道列表请求参数
  414. export interface StreamChannelListRequest extends PageRequest {
  415. // 继承 PageRequest 的所有属性 (page, size, keyword, enabled, sortBy, sortDir)
  416. }
  417. // 创建推流通道请求
  418. export interface StreamChannelAddRequest {
  419. channelId: string
  420. name: string
  421. accountId?: string
  422. apiToken?: string
  423. liveInputId: string
  424. streamKey?: string
  425. customerSubdomain: string
  426. mode?: StreamChannelMode
  427. recordingEnabled?: boolean
  428. }
  429. // 更新推流通道请求
  430. export interface StreamChannelUpdateRequest {
  431. id: number
  432. name?: string
  433. accountId?: string
  434. apiToken?: string
  435. liveInputId?: string
  436. streamKey?: string
  437. customerSubdomain?: string
  438. mode?: StreamChannelMode
  439. recordingEnabled?: boolean
  440. enabled?: boolean
  441. }
  442. // ==================== LiveStream 推流管理相关类型 ====================
  443. // LiveStream 状态
  444. // IDLE("idle", "空闲"),
  445. // /**
  446. // * 启动中 - FFmpeg进程正在启动
  447. // */
  448. // STARTING("starting", "启动中"),
  449. // /**
  450. // * 推流中 - 正常推流
  451. // */
  452. // STREAMING("streaming", "推流中"),
  453. // /**
  454. // * 停止中 - 正在停止推流
  455. // */
  456. // STOPPING("stopping", "停止中"),
  457. // /**
  458. // * 已停止 - 推流已停止
  459. // */
  460. // STOPPED("stopped", "已停止"),
  461. // /**
  462. // * 错误 - 推流发生错误
  463. // */
  464. // ERROR("error", "错误"),
  465. // /**
  466. // * 重连中 - 正在重新连接
  467. // */
  468. // RECONNECTING("reconnecting", "重连中");
  469. export type LiveStreamStatus = 'idle' | 'streaming'
  470. // 'IDLE' | 'STREAMING' | 'STOPPED' | 'ERROR'
  471. /**
  472. * 空闲 - 未开始推流
  473. */
  474. // LiveStream 信息 (LiveStreamInfoDTO)
  475. export interface LiveStreamDTO {
  476. id: number
  477. streamSn: string
  478. name: string
  479. lssId?: string
  480. cameraId?: string
  481. channelId?: number
  482. pushMethod?: string
  483. commandTemplate?: string
  484. timeoutSeconds?: number
  485. status: '1' | '0' // 开启或暂停
  486. enabled: boolean
  487. remark?: string
  488. createdAt: string
  489. updatedAt: string
  490. taskStreamSn?: string
  491. playbackUrl?: string
  492. }
  493. // LiveStream 列表请求参数
  494. export interface LiveStreamListRequest extends PageRequest {
  495. // 继承 PageRequest 的所有属性 (page, size, keyword, enabled, sortBy, sortDir)
  496. }
  497. // 创建 LiveStream 请求
  498. export interface LiveStreamAddRequest {
  499. name: string
  500. lssId: string
  501. cameraId?: string
  502. channelId?: number
  503. pushMethod?: string
  504. commandTemplate?: string
  505. timeoutSeconds?: number
  506. remark?: string
  507. }
  508. // 更新 LiveStream 请求
  509. export interface LiveStreamUpdateRequest {
  510. id: number
  511. name?: string
  512. lssId?: string
  513. cameraId?: string
  514. channelId?: number
  515. pushMethod?: string
  516. commandTemplate?: string
  517. timeoutSeconds?: number
  518. enabled?: boolean
  519. remark?: string
  520. }
  521. // ==================== 摄像头厂家相关类型 ====================
  522. // 摄像头厂家信息
  523. export interface CameraVendorDTO {
  524. id: number
  525. code: string
  526. name: string
  527. description?: string
  528. logoUrl?: string
  529. supportOnvif: boolean
  530. supportPtz: boolean
  531. supportIsapi: boolean
  532. supportGb28181: boolean
  533. supportAudio: boolean
  534. resolution?: string
  535. defaultPort?: number
  536. defaultRtspPort?: number
  537. rtspUrlTemplate?: string
  538. enabled: boolean
  539. sortOrder?: number
  540. createdAt: string
  541. updatedAt: string
  542. }
  543. // 摄像头厂家列表请求参数
  544. export interface CameraVendorListRequest extends PageRequest {
  545. // 继承 PageRequest 的所有属性
  546. }
  547. // 创建摄像头厂家请求
  548. export interface CameraVendorAddRequest {
  549. code: string
  550. name: string
  551. description?: string
  552. logoUrl?: string
  553. supportOnvif?: boolean
  554. supportPtz?: boolean
  555. supportIsapi?: boolean
  556. supportGb28181?: boolean
  557. supportAudio?: boolean
  558. resolution?: string
  559. defaultPort?: number
  560. defaultRtspPort?: number
  561. rtspUrlTemplate?: string
  562. enabled?: boolean
  563. sortOrder?: number
  564. }
  565. // 更新摄像头厂家请求
  566. export interface CameraVendorUpdateRequest {
  567. id: number
  568. code: string
  569. name: string
  570. description?: string
  571. logoUrl?: string
  572. supportOnvif?: boolean
  573. supportPtz?: boolean
  574. supportIsapi?: boolean
  575. supportGb28181?: boolean
  576. supportAudio?: boolean
  577. resolution?: string
  578. defaultPort?: number
  579. defaultRtspPort?: number
  580. rtspUrlTemplate?: string
  581. enabled?: boolean
  582. sortOrder?: number
  583. }
  584. // ==================== 推流服务相关类型 (Stream Push) ====================
  585. // 本地视频推流 DTO
  586. export interface LocalVideoStreamDTO {
  587. streamName: string
  588. sourceType: 'local_video' | 'rtsp_camera'
  589. sourcePath: string
  590. rtspUrl?: string
  591. loop: boolean
  592. streamTaskId?: string
  593. playbackUrl?: string
  594. status: string
  595. }
  596. // 启动本地视频推流请求
  597. export interface StartLocalStreamRequest {
  598. streamName?: string
  599. videoPath?: string
  600. loop?: boolean
  601. targetChannelId?: string
  602. }
  603. // 推流任务状态
  604. export type StreamTaskStatus = 'IDLE' | 'STARTING' | 'STREAMING' | 'STOPPED' | 'ERROR'
  605. // 推流任务 DTO
  606. export interface StreamTaskDTO {
  607. streamSn: string
  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. status: StreamTaskStatus
  616. statusDescription?: string
  617. errorMessage?: string
  618. retryCount: number
  619. remark?: string
  620. createdAt: string
  621. startedAt?: string
  622. stoppedAt?: string
  623. }
  624. // 启动推流任务请求
  625. export interface StartStreamTaskRequest {
  626. name?: string
  627. lssId?: string
  628. cameraId: string
  629. sourceRtspUrl?: string
  630. profile?: 'low_latency' | 'standard' | 'file_loop'
  631. whipUrl?: string
  632. playbackUrl?: string
  633. remark?: string
  634. }
  635. // 停止推流任务请求
  636. export interface StopStreamTaskRequest {
  637. taskId?: string
  638. lssId?: string
  639. }
  640. // 切换推流源请求
  641. export interface SwitchStreamSourceRequest {
  642. streamSn: string
  643. newCameraId: string
  644. newRtspUrl: string
  645. }
  646. // 推流通道信息 DTO (推流服务用)
  647. export interface StreamPushChannelDTO {
  648. channelId: string
  649. name: string
  650. mode: 'WHIP' | 'RTMPS'
  651. hlsPlaybackUrl?: string
  652. recordingEnabled: boolean
  653. }
  654. // 播放信息 DTO
  655. export interface PlaybackInfoDTO {
  656. streamSn: string
  657. name: string
  658. status: StreamTaskStatus
  659. whepUrl?: string
  660. hlsUrl?: string
  661. iframeCode?: string
  662. isLive: boolean
  663. }