package handler import ( "time" "silk-server-go/internal/model" ) // CameraPublic 摄像头对外返回的非敏感字段。 type CameraPublic struct { ID uint `json:"id"` RoomID *string `json:"roomId,omitempty"` Code string `json:"code"` Name string `json:"name"` RtspURL *string `json:"rtspUrl,omitempty"` HTTPURL *string `json:"httpUrl,omitempty"` Username *string `json:"username,omitempty"` Position *string `json:"position,omitempty"` Resolution *string `json:"resolution,omitempty"` FPS *int `json:"fps,omitempty"` IsOnline bool `json:"isOnline"` GbDeviceID *string `json:"gbDeviceId,omitempty"` GbChannelID *string `json:"gbChannelId,omitempty"` GbAuthID *string `json:"gbAuthId,omitempty"` GbStreamType *string `json:"gbStreamType,omitempty"` GbTransport *string `json:"gbTransport,omitempty"` GbAlarmChannelID *string `json:"gbAlarmChannelId,omitempty"` GbVoiceChannelID *string `json:"gbVoiceChannelId,omitempty"` GbManufacturer *string `json:"gbManufacturer,omitempty"` ManufacturerID *string `json:"manufacturerId,omitempty"` StreamURL *string `json:"streamUrl,omitempty"` HlsURL *string `json:"hlsUrl,omitempty"` FlvURL *string `json:"flvUrl,omitempty"` WebrtcURL *string `json:"webrtcUrl,omitempty"` SnapshotURL *string `json:"snapshotUrl,omitempty"` Online bool `json:"online"` Enabled bool `json:"enabled"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } // CameraInput 摄像头创建输入,允许接收密码字段,但不会作为公开响应。 type CameraInput struct { ID uint `json:"id,omitempty"` RoomID *string `json:"roomId,omitempty"` Code string `json:"code,omitempty"` Name string `json:"name"` RtspURL *string `json:"rtspUrl,omitempty"` HTTPURL *string `json:"httpUrl,omitempty"` Username *string `json:"username,omitempty"` PasswordEnc *string `json:"passwordEnc,omitempty"` Position *string `json:"position,omitempty"` Resolution *string `json:"resolution,omitempty"` FPS *int `json:"fps,omitempty"` IsOnline bool `json:"isOnline"` GbDeviceID *string `json:"gbDeviceId,omitempty"` GbChannelID *string `json:"gbChannelId,omitempty"` GbAuthID *string `json:"gbAuthId,omitempty"` GbAuthPassword *string `json:"gbAuthPassword,omitempty"` GbStreamType *string `json:"gbStreamType,omitempty"` GbTransport *string `json:"gbTransport,omitempty"` GbAlarmChannelID *string `json:"gbAlarmChannelId,omitempty"` GbVoiceChannelID *string `json:"gbVoiceChannelId,omitempty"` GbManufacturer *string `json:"gbManufacturer,omitempty"` ManufacturerID *string `json:"manufacturerId,omitempty"` Enabled bool `json:"enabled"` } func (in CameraInput) toModel() model.Camera { return model.Camera{ RoomID: in.RoomID, Code: in.Code, Name: in.Name, RtspURL: in.RtspURL, HTTPURL: in.HTTPURL, Username: in.Username, PasswordEnc: in.PasswordEnc, Position: in.Position, Resolution: in.Resolution, FPS: in.FPS, IsOnline: in.IsOnline, GbDeviceID: in.GbDeviceID, GbChannelID: in.GbChannelID, GbAuthID: in.GbAuthID, GbAuthPassword: in.GbAuthPassword, GbStreamType: in.GbStreamType, GbTransport: in.GbTransport, GbAlarmChannelID: in.GbAlarmChannelID, GbVoiceChannelID: in.GbVoiceChannelID, GbManufacturer: in.GbManufacturer, ManufacturerID: in.ManufacturerID, Enabled: in.Enabled, } } func toCameraPublic(camera model.Camera) CameraPublic { return CameraPublic{ ID: camera.ID, RoomID: camera.RoomID, Code: camera.Code, Name: camera.Name, RtspURL: camera.RtspURL, HTTPURL: camera.HTTPURL, Username: camera.Username, Position: camera.Position, Resolution: camera.Resolution, FPS: camera.FPS, IsOnline: camera.IsOnline, GbDeviceID: camera.GbDeviceID, GbChannelID: camera.GbChannelID, GbAuthID: camera.GbAuthID, GbStreamType: camera.GbStreamType, GbTransport: camera.GbTransport, GbAlarmChannelID: camera.GbAlarmChannelID, GbVoiceChannelID: camera.GbVoiceChannelID, GbManufacturer: camera.GbManufacturer, ManufacturerID: camera.ManufacturerID, StreamURL: camera.StreamURL, HlsURL: camera.HlsURL, FlvURL: camera.FlvURL, WebrtcURL: camera.WebrtcURL, SnapshotURL: camera.SnapshotURL, Online: camera.Online, Enabled: camera.Enabled, CreatedAt: camera.CreatedAt, UpdatedAt: camera.UpdatedAt, } }