feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
This commit is contained in:
45
internal/domain/device.go
Normal file
45
internal/domain/device.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
// DeviceType 设备类型
|
||||
type DeviceType int
|
||||
|
||||
const (
|
||||
DeviceTypeUnknown DeviceType = iota
|
||||
DeviceTypeWeb
|
||||
DeviceTypeMobile
|
||||
DeviceTypeDesktop
|
||||
)
|
||||
|
||||
// DeviceStatus 设备状态
|
||||
type DeviceStatus int
|
||||
|
||||
const (
|
||||
DeviceStatusInactive DeviceStatus = 0
|
||||
DeviceStatusActive DeviceStatus = 1
|
||||
)
|
||||
|
||||
// Device 设备模型
|
||||
type Device struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
UserID int64 `gorm:"not null;index" json:"user_id"`
|
||||
DeviceID string `gorm:"type:varchar(100);uniqueIndex;not null" json:"device_id"`
|
||||
DeviceName string `gorm:"type:varchar(100)" json:"device_name"`
|
||||
DeviceType DeviceType `gorm:"type:int;default:0" json:"device_type"`
|
||||
DeviceOS string `gorm:"type:varchar(50)" json:"device_os"`
|
||||
DeviceBrowser string `gorm:"type:varchar(50)" json:"device_browser"`
|
||||
IP string `gorm:"type:varchar(50)" json:"ip"`
|
||||
Location string `gorm:"type:varchar(100)" json:"location"`
|
||||
IsTrusted bool `gorm:"default:false" json:"is_trusted"` // 是否信任该设备
|
||||
TrustExpiresAt *time.Time `gorm:"type:datetime" json:"trust_expires_at"` // 信任过期时间
|
||||
Status DeviceStatus `gorm:"type:int;default:1" json:"status"`
|
||||
LastActiveTime time.Time `json:"last_active_time"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (Device) TableName() string {
|
||||
return "devices"
|
||||
}
|
||||
Reference in New Issue
Block a user