index.ts 14 KB

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