59 lines
2.2 KiB
Go
59 lines
2.2 KiB
Go
package provisioning
|
|
|
|
import (
|
|
"time"
|
|
|
|
common "git.ilapage.cn/ila/yovision/Sense/server/common/models"
|
|
)
|
|
|
|
const (
|
|
BatchReady = "ready"
|
|
BatchRunning = "running"
|
|
BatchSucceeded = "succeeded"
|
|
BatchPartial = "partial"
|
|
BatchFailed = "failed"
|
|
|
|
ItemInvalid = "invalid"
|
|
ItemReady = "ready"
|
|
ItemQuotaExceeded = "quota_exceeded"
|
|
ItemRunning = "running"
|
|
ItemSucceeded = "succeeded"
|
|
ItemFailed = "failed"
|
|
)
|
|
|
|
type Batch struct {
|
|
ID string `gorm:"size:36;primaryKey" json:"id"`
|
|
IdempotencyKey string `gorm:"size:128;not null;uniqueIndex" json:"idempotencyKey"`
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
QuotaLimit int `gorm:"not null" json:"quotaLimit"`
|
|
ExistingCount int `gorm:"not null" json:"existingCount"`
|
|
TotalCount int `gorm:"not null" json:"totalCount"`
|
|
ReadyCount int `gorm:"not null" json:"readyCount"`
|
|
SuccessCount int `gorm:"not null" json:"successCount"`
|
|
FailureCount int `gorm:"not null" json:"failureCount"`
|
|
common.ControlBy
|
|
common.ModelTime
|
|
Items []Item `gorm:"foreignKey:BatchID" json:"items,omitempty"`
|
|
}
|
|
|
|
func (Batch) TableName() string { return "sense_provisioning_batches" }
|
|
|
|
type Item struct {
|
|
ID string `gorm:"size:36;primaryKey" json:"id"`
|
|
BatchID string `gorm:"size:36;not null;uniqueIndex:batch_line;index" json:"batchId"`
|
|
LineNumber int `gorm:"not null;uniqueIndex:batch_line" json:"lineNumber"`
|
|
Name string `gorm:"size:128;not null" json:"name"`
|
|
Location string `gorm:"size:255;not null;default:''" json:"location"`
|
|
Address string `gorm:"size:1024;not null" json:"address"`
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
FailureCode string `gorm:"size:64;not null;default:''" json:"failureCode,omitempty"`
|
|
Detail string `gorm:"size:512;not null;default:''" json:"detail,omitempty"`
|
|
DeviceID string `gorm:"size:36;not null;default:'';index" json:"deviceId,omitempty"`
|
|
Attempts int `gorm:"not null;default:0" json:"attempts"`
|
|
LastTriedAt *time.Time `json:"lastTriedAt,omitempty"`
|
|
common.ControlBy
|
|
common.ModelTime
|
|
}
|
|
|
|
func (Item) TableName() string { return "sense_provisioning_items" }
|