cml04-falcon-ui/types/barcode.go

50 lines
905 B
Go
Raw Normal View History

2024-10-06 04:55:38 +02:00
package types
import (
"time"
"gorm.io/gorm"
)
type BarcodeStatus uint16
type LoadingBed uint8
const (
ATA12 LoadingBed = iota + 1
ATA345
ALL
)
2024-10-07 10:25:25 +02:00
var MapLoadingBed = map[string]LoadingBed{
"1": ATA12,
"2": ATA345,
"3": ALL,
}
2024-10-08 10:32:07 +02:00
var MapFormatBed = map[LoadingBed]string{
ATA12: "ATA12",
ATA345: "ATA345",
ALL: "TODOS",
}
2024-10-06 04:55:38 +02:00
type Barcode struct {
Barcode string `gorm:"primaryKey"`
LoadingBed LoadingBed
CreatedAt time.Time `gorm:"->;<-:create" json:"createdat,omitempty"`
UpdatedAt time.Time `json:"updatedat,omitempty"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedat,omitempty"`
}
2024-10-08 09:00:33 +02:00
2024-10-08 10:32:07 +02:00
func (b *Barcode) FormatLoadingBed() string {
return MapFormatBed[b.LoadingBed]
}
func (b *Barcode) FormatCreatedAt() string {
return b.CreatedAt.Format("02/01/2006 15:04:03")
}
2024-10-08 09:00:33 +02:00
2024-10-08 10:32:07 +02:00
func (b *Barcode) FormatUpdateAt() string {
return b.UpdatedAt.Format("02/01/2006 15:04:03")
}