Refactor and simplify package structure and interfaces.
Reorganize code by removing unused files, restructuring package organization, and updating import references to new paths. This simplifies handling of smart and protocol-related operations, improves maintainability, and eliminates redundancy.
This commit is contained in:
168
pkg/models/certificate.go
Normal file
168
pkg/models/certificate.go
Normal file
@ -0,0 +1,168 @@
|
||||
package models
|
||||
|
||||
type NetConnectionType uint
|
||||
|
||||
const (
|
||||
NetConnectionWired NetConnectionType = iota
|
||||
NetConnectionWireless
|
||||
)
|
||||
|
||||
type TimeShiftSupportFlag uint8
|
||||
|
||||
const (
|
||||
TimeShiftNotSupported TimeShiftSupportFlag = iota
|
||||
TimeShiftSupported
|
||||
)
|
||||
|
||||
type FileSystemVersionNumber uint8
|
||||
|
||||
const (
|
||||
FileSystemVersion4 FileSystemVersionNumber = iota
|
||||
FileSystemVersion5
|
||||
)
|
||||
|
||||
type CertificateConnectRequest struct {
|
||||
Net NetConnectionType `json:"NET"`
|
||||
SerialNumber string `json:"DSNO"`
|
||||
DeviceName string `json:"DEVNAME"`
|
||||
ChannelsNumber uint `json:"CHANNEL"`
|
||||
LicensePlate string `json:"CARNUM"`
|
||||
DeviceNumber string `json:"AUTONO"`
|
||||
VehicleNumber string `json:"AUTOCAR"`
|
||||
TimeShiftSupport TimeShiftSupportFlag `json:"TSE"`
|
||||
FileSystemVersion FileSystemVersionNumber `json:"FSV"`
|
||||
ICCID string `json:"ICCID"`
|
||||
EvidenceSupport string `json:"EV"`
|
||||
}
|
||||
|
||||
type CertificateConnectClientRequest struct {
|
||||
UK string `json:"UK"`
|
||||
}
|
||||
|
||||
type CertificateConnectResponse struct {
|
||||
ErrorCode uint `json:"ERRORCODE"`
|
||||
ErrorCause string `json:"ERRORCAUSE"`
|
||||
CommandMask uint `json:"MASKCMD"`
|
||||
}
|
||||
|
||||
type CertificateConnectClientResponse struct {
|
||||
S0 string `json:"S0"`
|
||||
}
|
||||
|
||||
type CertificateVerificationRequest struct {
|
||||
S0 string `json:"S0"`
|
||||
}
|
||||
|
||||
type CertificateVerificationResponse struct {
|
||||
ErrorCode uint `json:"ERRORCODE"`
|
||||
ErrorCause string `json:"ERRORCAUSE"`
|
||||
ReturnFlag bool `json:"RETURN"`
|
||||
}
|
||||
|
||||
type CertificateLoginRequest struct {
|
||||
ClientID uint `json:"CID,omitempty"`
|
||||
MAC string `json:"MAC,omitempty"`
|
||||
User string `json:"USER"`
|
||||
Password string `json:"PASSWD"`
|
||||
PlayDevID uint `json:"PLAYDEVID"`
|
||||
}
|
||||
|
||||
type CertificateLoginResponse struct {
|
||||
SerialNumber string `json:"DSNO"`
|
||||
DeviceName string `json:"DEVNAME"`
|
||||
ChannelsNumber uint `json:"CHANNEL"`
|
||||
UID string `json:"UID"`
|
||||
AlarmInputNumber uint `json:"ALARMIN"`
|
||||
AlarmOutputNumber uint `json:"ALARMOUT"`
|
||||
DeviceType string `json:"TYPE"`
|
||||
DeviceClass DeviceType `json:"DEVCLASS"`
|
||||
CurrentVersion string `json:"PRO"`
|
||||
LicensePlate string `json:"CARNUM"`
|
||||
UserLever UserAccessLevel `json:"LEVEL"`
|
||||
CompanyName string `json:"CPN"`
|
||||
CustomerName string `json:"CNAME"`
|
||||
AudioChannelsNumber uint `json:"ACHN"`
|
||||
}
|
||||
|
||||
type CertificateCreateStreamRequest struct {
|
||||
StreamName string `json:"STREAMNAME"`
|
||||
}
|
||||
|
||||
type CertificateCreateStreamResponse struct {
|
||||
ErrorCode uint `json:"ERRORCODE"`
|
||||
ErrorCause string `json:"ERRORCAUSE"`
|
||||
}
|
||||
|
||||
type CommandMaskParameters uint
|
||||
|
||||
const (
|
||||
CommandMaskAlarm = 1 << iota
|
||||
CommandMaskScanningGun
|
||||
CommandMaskPassengerFlow
|
||||
CommandMaskFaceContrast
|
||||
CommandMaskCard
|
||||
CommandMaskShutdownReport
|
||||
CommandMaskGPSReport
|
||||
CommandMaskAll = 0b1111111
|
||||
)
|
||||
|
||||
type DeviceType uint
|
||||
|
||||
const (
|
||||
DeviceTypeDVR DeviceType = 1 + iota
|
||||
DeviceTypeIPC
|
||||
DeviceTypeNVR
|
||||
DeviceTypeMIPC
|
||||
DeviceTypeMDVR
|
||||
)
|
||||
|
||||
type UserAccessLevel uint
|
||||
|
||||
const (
|
||||
UserAccessLevelSuperAdmin UserAccessLevel = iota
|
||||
UserAccessLevelAdministrator
|
||||
UserAccessLeverUser
|
||||
)
|
||||
|
||||
/*
|
||||
func (e *Package) RequestConnect(session string, serial string, numOfCams int) {
|
||||
e.Payload = map[string]any{
|
||||
"MODULE": "CERTIFICATE",
|
||||
"OPERATION": "CONNECT",
|
||||
"PARAMETER": map[string]any{
|
||||
"DSNO": serial,
|
||||
"CHANNEL": numOfCams,
|
||||
},
|
||||
"SESSION": session,
|
||||
}
|
||||
}
|
||||
|
||||
// video server util
|
||||
func (e *Package) ResponseConnect(Sid string, streamName string) {
|
||||
e.Payload = map[string]any{
|
||||
"MODULE": "CERTIFICATE",
|
||||
"OPERATION": "CREATESTREAM",
|
||||
"RESPONSE": map[string]any{
|
||||
"ERRORCODE": 0,
|
||||
"STREAMNAME": streamName,
|
||||
},
|
||||
"SESSION": Sid,
|
||||
}
|
||||
}
|
||||
|
||||
// main server util
|
||||
func (e *Package) ResponseCertificateConnect(Sid string) {
|
||||
e.Payload = map[string]any{
|
||||
"MODULE": "CERTIFICATE",
|
||||
"OPERATION": "CONNECT",
|
||||
"RESPONSE": map[string]any{
|
||||
"ERRORCAUSE": "",
|
||||
"ERRORCODE": 0,
|
||||
"MASKCMD": 5,
|
||||
"PRO": "1.0.5",
|
||||
},
|
||||
"SESSION": Sid,
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
Reference in New Issue
Block a user