38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"fiskerinc.com/modules/common/dbbasemodel"
|
|
)
|
|
|
|
// CarUpdate schema
|
|
type CarUpdate struct {
|
|
ID int64 `json:"id,omitempty"`
|
|
VIN string `pg:",unique:vin_update_manifest" json:"vin" validate:"required,max=17"`
|
|
UpdateManifestID int64 `pg:",unique:vin_update_manifest" json:"manifest_id,omitempty" validate:"required"`
|
|
Status string `pg:"default:'pending'" json:"status,omitempty" validate:"max=100"`
|
|
ErrorCode int `json:"err,omitempty"`
|
|
Info string `json:"info,omitempty" pg:"info" validate:"max=1000"`
|
|
Username string `json:"username,omitempty" validate:"required"`
|
|
UpdateManifest *UpdateManifest `pg:"rel:has-one" json:"updatemanifest,omitempty"`
|
|
UpdateSource string
|
|
dbbasemodel.DBModelBase
|
|
}
|
|
|
|
func (cu CarUpdate) String() string {
|
|
return fmt.Sprintf("CarUpdate<%d %d %s %s>", cu.ID, cu.UpdateManifestID, cu.VIN, cu.Status)
|
|
}
|
|
|
|
func (cu *CarUpdate) Scrub() {
|
|
cu.UpdateManifestID = 0
|
|
cu.UpdateManifest = nil
|
|
cu.CreatedAt = nil
|
|
cu.UpdatedAt = nil
|
|
}
|
|
|
|
const (
|
|
UPDATE_SOURCE_OTA = "OTA" // The cloud has deployed this update
|
|
UPDATE_SOURCE_AFTERSALES = "AFTERSALES" // An update generated to be sent by aftersales.
|
|
UPDATE_SOURCE_FLASHPACK = "FLASHPACK"
|
|
)
|