// API 响应类型 - 基础响应(无数据) export interface BaseResponse { success: boolean errCode?: string errMessage?: string } // API 响应类型 - 单个数据响应 export interface IBaseResponse { data?: T success: boolean errCode?: string errMessage?: string } // API 响应类型 - 分页列表响应 export interface IResponse { success: boolean errCode?: string errMessage?: string data: { total: string list: T[] } } // 兼容旧代码 - ApiResponse 别名 export type ApiResponse = IResponse // 分页参数(旧版,兼容) export interface PageParams { pageNum: number pageSize: number } // 分页响应(旧版,兼容) export interface PageResult { total: number rows: T[] } // 分页请求参数(新版) export interface PageRequest { page?: number size?: number keyword?: string enabled?: boolean | null sortBy?: string sortDir?: 'ASC' | 'DESC' } // 分页响应(新版) export interface PageResponse { list: T[] page: number size: number total: number totalPages: number hasNext: boolean hasPrevious: boolean } // 带分页的 API 响应 export interface IPageResponse { success: boolean errCode?: string errMessage?: string data: PageResponse } // 列表 API 响应(数组形式) export interface IListResponse { success: boolean errCode?: string errMessage?: string data: T[] } // 登录参数 export interface LoginParams { username: string password: string } // 登录响应 export interface LoginResponse { token: string tokenType: string expiresIn: number refreshToken?: string admin: AdminInfo } // 管理员信息 export interface AdminInfo { id: number username: string nickname: string role: string lastLoginAt?: string } // 用户信息 (兼容旧代码) export interface UserInfo { id: number username: string nickname: string role: string lastLoginAt?: string } // 通道信息 (Controller 用) export interface ChannelDTO { channelId: string name: string rtspUrl: string defaultView: boolean status: 'ONLINE' | 'OFFLINE' cameraId: string } // 摄像头信息 (Controller 用) export interface CameraDTO { cameraId: string name: string machineId: string status: 'ONLINE' | 'OFFLINE' capability: 'switch_only' | 'ptz_enabled' ptzSupported: boolean channels: ChannelDTO[] } // 通道详情 (Admin 用) export interface ChannelInfoDTO { id: number channelId: string name: string rtspUrl: string defaultView: boolean status: 'ONLINE' | 'OFFLINE' } export type CameraCapability = 'switch_only' | 'ptz_enabled' export type CameraHeartbeatStatus = 'active' | 'hold' | 'dead' // 摄像头详情 (Admin 用) export interface CameraInfoDTO extends CameraAddRequest { /* 主键ID */ id?: number /* IP地址 */ ip?: string /* 端口 */ port?: number /* 用户名 */ username?: string /* 品牌(兼容旧数据) */ brand?: string /* 能力 */ capability?: CameraCapability /* 心跳状态 */ status?: CameraHeartbeatStatus /* 推流地址 */ rtspUrl?: string /* 通道号 */ channelNo?: string /* 备注 */ remark?: string /* 是否启用 */ enabled?: boolean /* 创建时间(ISO) */ createdAt?: string /* 更新时间(ISO) */ updatedAt?: string } // 添加摄像头请求 export interface CameraAddRequest { /* 摄像头ID */ cameraId?: string /* 设备名称 */ cameraName?: string /* 参数配置 JSON 字符串 */ paramConfig?: string /* 设备运行参数 JSON 字符串 */ runtimeParams?: string /* 绑定的 LSS 节点 ID */ lssId?: string /* 摄像头型号 */ model?: string /* 厂商名称 */ vendorName?: string } // 添加通道请求 export interface ChannelAddRequest { channelId: string name: string rtspUrl?: string defaultView?: boolean } // 更新摄像头请求 export interface CameraUpdateRequest { id: number name?: string ip?: string port?: number username?: string password?: string brand?: string capability?: 'switch_only' | 'ptz_enabled' machineId?: string lssId?: string model?: string rtspUrl?: string channelNo?: string remark?: string enabled?: boolean paramConfig?: string runtimeParams?: string channels?: ChannelUpdateRequest[] } // 更新通道请求 export interface ChannelUpdateRequest { id?: number channelId?: string name?: string rtspUrl?: string defaultView?: boolean } // 切换通道请求 export interface SwitchChannelRequest { machineId: string channelId: string } // 机器信息 export interface MachineDTO { id: number machineId: string name: string location: string description: string enabled: boolean cameraCount: number createdAt: string updatedAt: string } // 添加机器请求 export interface MachineAddRequest { machineId: string name: string location?: string description?: string } // 更新机器请求 export interface MachineUpdateRequest { id: number name?: string location?: string description?: string enabled?: boolean } // 仪表盘统计 export interface DashboardStatsDTO { machineTotal: number machineEnabled: number cameraTotal: number cameraOnline: number cameraOffline: number channelTotal: number } // 修改密码请求 export interface ChangePasswordRequest { oldPassword: string newPassword: string } // PTZ 动作类型 export type PTZAction = | 'up' | 'down' | 'left' | 'right' | 'zoom_in' | 'zoom_out' | 'stop' | 'UP' | 'DOWN' | 'LEFT' | 'RIGHT' | 'ZOOM_IN' | 'ZOOM_OUT' | 'STOP' // PTZ 直接控制请求 (pan/tilt/zoom 方式) export interface PTZControlRequest { pan?: number // 水平移动速度 -100 ~ 100 tilt?: number // 垂直移动速度 -100 ~ 100 zoom?: number // 缩放速度 -100 ~ 100 channel?: number // 通道号(可选) } // Admin PTZ 控制请求 export interface AdminPTZRequest { id: number action: PTZAction speed?: number // 0.0 - 1.0 } // 摄像头列表请求参数 export interface CameraListRequest extends PageRequest { machineId?: string lssId?: string status?: 'ONLINE' | 'OFFLINE' enabled?: boolean } // 机器列表请求参数 export interface MachineListRequest extends PageRequest { // 继承 PageRequest 的所有属性 } // 兼容旧代码的类型别名 export type CameraDevice = CameraInfoDTO export type CameraChannel = ChannelInfoDTO // 播放响应 (保留用于视频播放) export interface PlayResponse { streamId: string flv: string ws_flv?: string rtsp?: string rtmp?: string hls?: string rtc?: string mediaServerId?: string deviceId?: string channelId?: string } // 录像记录 (保留用于视频回放) export interface RecordItem { name?: string start: number end: number secrecy?: number type?: string } // ==================== LSS 节点相关类型 ==================== // LSS 节点状态 export type LssNodeStatus = 'hold' | 'active' | 'dead' // LSS 节点信息 (新 API) export interface IAblyChannels { registry: string commandPrefix: string commandSuffix: string statusSuffix: string taskPrefix: string taskSuffix: string } export interface IAblyHeartbeat { intervalMs: number } export interface IAbly { apiKey: string channels: IAblyChannels heartbeat: IAblyHeartbeat } export interface LssNodeDTO { ably?: IAbly id: number lssId: string lssName: string machineId: string address: string ip: string maxTasks: number currentTasks: number loadRate: number status: LssNodeStatus ablyClientId?: string ablyConnected?: boolean lastAblyHeartbeat?: string lastHeartbeatAt?: string ffmpegVersion?: string systemInfo?: string enabled: boolean createdAt: string updatedAt: string } // LSS 节点列表请求参数 export interface LssNodeListRequest extends PageRequest { status?: LssNodeStatus machineId?: string } // LSS 节点统计信息 export interface LssNodeStatsDTO { total: number online: number offline: number busy: number maintenance: number } // 兼容旧代码 - LSS 心跳状态 export type LssHeartbeatStatus = 'active' | 'hold' | 'dead' // 兼容旧代码 - LSS 信息 (旧 API) export interface LssDTO { id: number lssId: string name: string address: string publicIp?: string heartbeat?: LssHeartbeatStatus heartbeatTime?: string ablyInfo?: string } // 兼容旧代码 - LSS 列表请求参数 export interface LssListRequest extends PageRequest { heartbeat?: LssHeartbeatStatus } // ==================== StreamChannel 推流通道相关类型 (Cloudflare Stream) ==================== // 推流模式 export type StreamChannelMode = 'WHIP' | 'RTMPS' | 'SRT' // 推流通道信息 (StreamChannelInfoDTO) export interface StreamChannelDTO { id: number channelId: string name: string accountId?: string liveInputId?: string customerSubdomain?: string mode?: StreamChannelMode whipUrl?: string rtmpsUrl?: string hlsPlaybackUrl?: string whepPlaybackUrl?: string recordingEnabled?: boolean enabled: boolean createdAt: string updatedAt: string } // 推流通道列表请求参数 export interface StreamChannelListRequest extends PageRequest { // 继承 PageRequest 的所有属性 (page, size, keyword, enabled, sortBy, sortDir) } // 创建推流通道请求 export interface StreamChannelAddRequest { channelId: string name: string accountId?: string apiToken?: string liveInputId: string streamKey?: string customerSubdomain: string mode?: StreamChannelMode recordingEnabled?: boolean } // 更新推流通道请求 export interface StreamChannelUpdateRequest { id: number name?: string accountId?: string apiToken?: string liveInputId?: string streamKey?: string customerSubdomain?: string mode?: StreamChannelMode recordingEnabled?: boolean enabled?: boolean } // ==================== LiveStream 推流管理相关类型 ==================== // LiveStream 状态 // IDLE("idle", "空闲"), // /** // * 启动中 - FFmpeg进程正在启动 // */ // STARTING("starting", "启动中"), // /** // * 推流中 - 正常推流 // */ // STREAMING("streaming", "推流中"), // /** // * 停止中 - 正在停止推流 // */ // STOPPING("stopping", "停止中"), // /** // * 已停止 - 推流已停止 // */ // STOPPED("stopped", "已停止"), // /** // * 错误 - 推流发生错误 // */ // ERROR("error", "错误"), // /** // * 重连中 - 正在重新连接 // */ // RECONNECTING("reconnecting", "重连中"); export type LiveStreamStatus = 'idle' | 'streaming' // 'IDLE' | 'STREAMING' | 'STOPPED' | 'ERROR' /** * 空闲 - 未开始推流 */ // LiveStream 信息 (LiveStreamInfoDTO) export interface LiveStreamDTO { id: number streamSn: string name: string lssId?: string cameraId?: string channelId?: number pushMethod?: string commandTemplate?: string timeoutSeconds?: number status: '1' | '0' // 开启或暂停 enabled: boolean remark?: string createdAt: string updatedAt: string taskStreamSn?: string playbackUrl?: string } // LiveStream 列表请求参数 export interface LiveStreamListRequest extends PageRequest { // 继承 PageRequest 的所有属性 (page, size, keyword, enabled, sortBy, sortDir) } // 创建 LiveStream 请求 export interface LiveStreamAddRequest { name: string lssId: string cameraId?: string channelId?: number pushMethod?: string commandTemplate?: string timeoutSeconds?: number remark?: string } // 更新 LiveStream 请求 export interface LiveStreamUpdateRequest { id: number name?: string lssId?: string cameraId?: string channelId?: number pushMethod?: string commandTemplate?: string timeoutSeconds?: number enabled?: boolean remark?: string } // ==================== 摄像头厂家相关类型 ==================== // 摄像头厂家信息 export interface CameraVendorDTO { id: number code: string name: string description?: string logoUrl?: string supportOnvif: boolean supportPtz: boolean supportIsapi: boolean supportGb28181: boolean supportAudio: boolean resolution?: string defaultPort?: number defaultRtspPort?: number rtspUrlTemplate?: string enabled: boolean sortOrder?: number createdAt: string updatedAt: string } // 摄像头厂家列表请求参数 export interface CameraVendorListRequest extends PageRequest { // 继承 PageRequest 的所有属性 } // 创建摄像头厂家请求 export interface CameraVendorAddRequest { code: string name: string description?: string logoUrl?: string supportOnvif?: boolean supportPtz?: boolean supportIsapi?: boolean supportGb28181?: boolean supportAudio?: boolean resolution?: string defaultPort?: number defaultRtspPort?: number rtspUrlTemplate?: string enabled?: boolean sortOrder?: number } // 更新摄像头厂家请求 export interface CameraVendorUpdateRequest { id: number code: string name: string description?: string logoUrl?: string supportOnvif?: boolean supportPtz?: boolean supportIsapi?: boolean supportGb28181?: boolean supportAudio?: boolean resolution?: string defaultPort?: number defaultRtspPort?: number rtspUrlTemplate?: string enabled?: boolean sortOrder?: number } // ==================== 推流服务相关类型 (Stream Push) ==================== // 本地视频推流 DTO export interface LocalVideoStreamDTO { streamName: string sourceType: 'local_video' | 'rtsp_camera' sourcePath: string rtspUrl?: string loop: boolean streamTaskId?: string playbackUrl?: string status: string } // 启动本地视频推流请求 export interface StartLocalStreamRequest { streamName?: string videoPath?: string loop?: boolean targetChannelId?: string } // 推流任务状态 export type StreamTaskStatus = 'IDLE' | 'STARTING' | 'STREAMING' | 'STOPPED' | 'ERROR' // 推流任务 DTO export interface StreamTaskDTO { streamSn: string name: string lssId: string cameraId: string sourceRtspUrl: string profile: 'low_latency' | 'standard' | 'file_loop' whipUrl: string playbackUrl: string status: StreamTaskStatus statusDescription?: string errorMessage?: string retryCount: number remark?: string createdAt: string startedAt?: string stoppedAt?: string } // 启动推流任务请求 export interface StartStreamTaskRequest { name?: string lssId?: string cameraId: string sourceRtspUrl?: string profile?: 'low_latency' | 'standard' | 'file_loop' whipUrl?: string playbackUrl?: string remark?: string } // 停止推流任务请求 export interface StopStreamTaskRequest { taskId?: string lssId?: string } // 切换推流源请求 export interface SwitchStreamSourceRequest { streamSn: string newCameraId: string newRtspUrl: string } // 推流通道信息 DTO (推流服务用) export interface StreamPushChannelDTO { channelId: string name: string mode: 'WHIP' | 'RTMPS' hlsPlaybackUrl?: string recordingEnabled: boolean } // 播放信息 DTO export interface PlaybackInfoDTO { streamSn: string name: string status: StreamTaskStatus whepUrl?: string hlsUrl?: string iframeCode?: string isLive: boolean }