Documentation
¶
Index ¶
- Variables
- func EnsureRootUser(db *gorm.DB) error
- func Migrate(db *gorm.DB) error
- type Array
- type AuditLog
- type AuthToken
- type Base
- type Channel
- func (c *Channel) AfterCreate(tx *gorm.DB) error
- func (c *Channel) AfterDelete(tx *gorm.DB) error
- func (c *Channel) AfterSave(tx *gorm.DB) error
- func (c *Channel) AfterUpdate(tx *gorm.DB) error
- func (c *Channel) BeforeCreate(tx *gorm.DB) error
- func (c *Channel) BeforeDelete(tx *gorm.DB) error
- func (c *Channel) BeforeSave(tx *gorm.DB) error
- func (c *Channel) BeforeUpdate(tx *gorm.DB) error
- func (Channel) TableName() string
- type DeveltypePointBase
- type Device
- type DeviceState
- type DeviceTypePoint
- type Goose
- func (c *Goose) AfterCreate(tx *gorm.DB) error
- func (c *Goose) AfterDelete(tx *gorm.DB) error
- func (c *Goose) AfterSave(tx *gorm.DB) error
- func (c *Goose) AfterUpdate(tx *gorm.DB) error
- func (c *Goose) BeforeCreate(tx *gorm.DB) error
- func (c *Goose) BeforeDelete(tx *gorm.DB) error
- func (c *Goose) BeforeSave(tx *gorm.DB) error
- func (c *Goose) BeforeUpdate(tx *gorm.DB) error
- func (Goose) TableName() string
- type InstanceStatus
- type Kind
- type LogrusLogger
- func (l *LogrusLogger) Error(ctx context.Context, msg string, args ...interface{})
- func (l *LogrusLogger) Info(ctx context.Context, msg string, args ...interface{})
- func (l *LogrusLogger) LogMode(level logger.LogLevel) logger.Interface
- func (l *LogrusLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *LogrusLogger) Warn(ctx context.Context, msg string, args ...interface{})
- type MQTT
- func (c *MQTT) AfterCreate(tx *gorm.DB) error
- func (c *MQTT) AfterDelete(tx *gorm.DB) error
- func (c *MQTT) AfterSave(tx *gorm.DB) error
- func (c *MQTT) AfterUpdate(tx *gorm.DB) error
- func (c *MQTT) BeforeCreate(tx *gorm.DB) error
- func (c *MQTT) BeforeDelete(tx *gorm.DB) error
- func (c *MQTT) BeforeSave(tx *gorm.DB) error
- func (c *MQTT) BeforeUpdate(tx *gorm.DB) error
- func (MQTT) TableName() string
- type ModelInfo
- type ModelOpt
- type QueryOpt
- type RegAccess
- type RegType
- type Registry
- func (r *Registry) FindByTablePK(ctx context.Context, db *gorm.DB, table string, pkValue any) (any, error)
- func (r *Registry) FindByTablePKValue(ctx context.Context, db *gorm.DB, table string, pkValue any) (any, error)
- func (r *Registry) FindByTablePKWith(ctx context.Context, db *gorm.DB, table string, pkValue any, qopts ...QueryOpt) (any, error)
- func (r *Registry) Register(db *gorm.DB, model any, opts ...ModelOpt) error
- type Scalar
- func (s Scalar) Bool() (bool, error)
- func (s Scalar) Bytes() ([]byte, error)
- func (s Scalar) Equal(other Scalar) bool
- func (s Scalar) Float32() (float32, error)
- func (s Scalar) Float64() (float64, error)
- func (s *Scalar) IsZero() bool
- func (s Scalar) MarshalJSON() ([]byte, error)
- func (s *Scalar) Reset()
- func (s *Scalar) Scan(src any) error
- func (s *Scalar) SetBool(v bool)
- func (s *Scalar) SetBytes(v []byte)
- func (s *Scalar) SetFloat32(v float32)
- func (s *Scalar) SetFloat64(v float64)
- func (s *Scalar) SetSint16(v int16)
- func (s *Scalar) SetSint32(v int32)
- func (s *Scalar) SetSint64(v int64)
- func (s *Scalar) SetString(v string)
- func (s *Scalar) SetUint16(v uint16)
- func (s *Scalar) SetUint32(v uint32)
- func (s *Scalar) SetUint64(v uint64)
- func (s Scalar) Sint16() (int16, error)
- func (s Scalar) Sint32() (int32, error)
- func (s Scalar) Sint64() (int64, error)
- func (s Scalar) String() (string, error)
- func (s Scalar) Uint16() (uint16, error)
- func (s Scalar) Uint32() (uint32, error)
- func (s Scalar) Uint64() (uint64, error)
- func (s *Scalar) UnmarshalJSON(b []byte) error
- func (s Scalar) Value() (driver.Value, error)
- type ScalarJSON
- type Serial
- func (c *Serial) AfterCreate(tx *gorm.DB) error
- func (c *Serial) AfterDelete(tx *gorm.DB) error
- func (c *Serial) AfterSave(tx *gorm.DB) error
- func (c *Serial) AfterUpdate(tx *gorm.DB) error
- func (c *Serial) BeforeCreate(tx *gorm.DB) error
- func (c *Serial) BeforeDelete(tx *gorm.DB) error
- func (c *Serial) BeforeSave(tx *gorm.DB) error
- func (c *Serial) BeforeUpdate(tx *gorm.DB) error
- func (Serial) TableName() string
- type Setting
- type Site
- type TokenType
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrKindMismatch = errors.New("kind mismatch")
Functions ¶
func EnsureRootUser ¶
EnsureRootUser ensures the super user "root" exists. EnsureRootUser 确保超级用户 root 存在。
Types ¶
type Array ¶
type Array struct {
SiteID string
Site Site `gorm:"references:UUID"`
UUID string `gorm:"primaryKey;column:uuid;size:36;uniqueIndex;not null" json:"uuid"`
Name string `gorm:"column:name;size:150;uniqueIndex;not null" json:"name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Array 子阵
type AuditLog ¶
type AuditLog struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index;not null" json:"user_id"`
Username string `gorm:"index;size:64;not null" json:"username"`
// Action: "login", "create_user", "change_password", ...
// Action:动作,如 "login", "create_user", "change_password" 等。
Action string `gorm:"size:64;index;not null" json:"action"`
// Resource: "user", "token", "session", "audit"
// Resource:资源类型,如 "user", "token", "session", "audit"
Resource string `gorm:"size:64;index;not null" json:"resource"`
Method string `gorm:"size:16;not null" json:"method"`
Path string `gorm:"size:256;not null" json:"path"`
// Detail is extra JSON/text.
// Detail 是额外信息(JSON/文本)。
Detail string `gorm:"type:text" json:"detail,omitempty"`
IP string `gorm:"size:64" json:"ip,omitempty"`
UserAgent string `gorm:"size:256" json:"user_agent,omitempty"`
CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
}
AuditLog stores immutable audit records (no delete API). AuditLog 保存不可变审计记录(不提供删除 API)。
type AuthToken ¶
type AuthToken struct {
ID uint `gorm:"primaryKey" json:"id"`
// JTI is the unique identifier of JWT.
// JTI 是 JWT 的唯一标识。
JTI string `gorm:"uniqueIndex;size:64;not null" json:"jti"`
UserID uint `gorm:"index;not null" json:"user_id"`
User User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
Type TokenType `gorm:"size:16;index;not null" json:"type"`
// Name is optional token label.
// Name 是可选的 token 备注。
Name string `gorm:"size:128" json:"name,omitempty"`
IssuedAt time.Time `gorm:"not null" json:"issued_at"`
// ExpiresAt is optional absolute expiration.
// ExpiresAt 是可选的绝对过期时间。
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// LastSeenAt enables sliding idle timeout for web sessions.
// LastSeenAt 用于 Web 会话的滑动空闲超时。
LastSeenAt *time.Time `json:"last_seen_at,omitempty"`
// IdleTimeoutSeconds is used only for web sessions.
// IdleTimeoutSeconds 仅用于 Web 会话。
IdleTimeoutSeconds int `gorm:"not null;default:0" json:"idle_timeout_seconds"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
RevokedBy *uint `json:"revoked_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthToken stores token metadata (server-side session control). AuthToken 存储 token 元数据(服务端可控会话)。
type Base ¶
type Base struct {
ID string `gorm:"primaryKey;column:id;size:36;uniqueIndex;not null" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
Model a basic GoLang struct which includes the following fields: ID, CreatedAt, UpdatedAt, DeletedAt It may be embedded into your model or you may build your own model without it
type User struct {
Base
}
type Channel ¶
type Channel struct {
Base
Delay time.Duration `gorm:"column:delay" json:"delay"` // 时延 单位 毫秒
DebugLog bool `gorm:"column:debug_log" json:"debug_log"` // debug log 模式
DebugExpiry time.Time `gorm:"column:debug_expiry" json:"debug_expiry"` // debuglog 截止时间
VerifyHeader bool `gorm:"column:verify_header" json:"verify_header"` // 校验报文头
OnnectTimeout time.Duration `gorm:"column:onnect_timeout" json:"onnect_timeout"` // 连接超时时间 (ms),默认 3s
Downgrade bool `gorm:"column:down_grade" json:"down_grade"` // 设备降级
RetryMax uint64 `gorm:"column:retry_max" json:"retry_max"` // 最大重试次数,发送读指令失败后最大重试次数
RetryInterval time.Duration `gorm:"column:retry_interval" json:"retry_interval"` // 指令重新发送间隔 (ms)
Endianness uint `gorm:"column:endianness" json:"endianness"` // endianness
WordOrder uint `gorm:"column:word_order" json:"word_order"` // word ordering
SendInterval time.Duration `gorm:"column:send_interval" json:"send_interval"` // 指令发送间隔 (ms)
PhysicalLink string `gorm:"column:physical_link" json:"physical_link"` // serial、RTUclient、RTUserver、TCPclient、TCPserver
Disable bool `gorm:"column:disable" json:"disable"` // disable
Plugin string `gorm:"column:plugin;size:128;not null" json:"plugin"`
AddrStart bool `gorm:"column:addr_start" json:"addr_start"`
TCPIPAddr string `gorm:"column:tcp_ip_addr" json:"tcp_ip_addr"`
TCPPort uint16 `gorm:"column:tcp_port" json:"tcp_port"`
BackupTCPIPAddr string `gorm:"column:backup_tcp_ip_addr" json:"backup_tcp_ip_addr"`
BackupTCPPort uint16 `gorm:"column:backup_tcp_port" json:"backup_tcp_port"`
Status InstanceStatus `gorm:"-" json:"status"`
}
Channel 通道
func GetDefaultChannelRow ¶
type DeveltypePointBase ¶
type DeveltypePointBase struct {
Name string `gorm:"size:128;;not null"` // 信号名
NameCn string `gorm:"size:128;;not null"` // 信号名
Gain float64 `gorm:"not null;default:0"` // 文档里的 Gain
Unit string `gorm:"size:32"` // 单位(V, A, kWh, %...)
RW string `gorm:"size:8;not null;default:'RO'"` // RO / RW / WO
Address uint16 `gorm:"not null"` // Modbus 地址(手册里的 Address)
PointType string `gorm:"size:8;not null;default:'holding'"` // 点位类型
Quantity uint32 `gorm:"not null;default:1"` // 增益
DataType string `gorm:"size:32;not null"` // int16/uint16/int32/float32/bool/string...
ByteOrder string `gorm:"size:8"` // ABCD/BADC/CDAB/DCBA...
Offset float64 `gorm:"not null;default:0"` // offset
Desc string `gorm:"size:128"` // Desc
Disable bool `gorm:"not null;default:false"` // such as
}
type Device ¶
type Device struct {
ChannelID string
Base
Name string `gorm:"column:name;size:150;uniqueIndex;not null" json:"name"`
DeviceType string `gorm:"column:device_type;size:128;not null;index" json:"device_type"` // Requirement #4: weak association by type_key (no FK)
Transport string `gorm:"size:16;not null"` // tcp/rtu/rtu_over_tcp...
Endpoint string `gorm:"size:256;not null"` // host:port or /dev/ttyS1
SlaveID uint `gorm:"not null;default:1"`
PollIntervalMs int `gorm:"not null;default:1000"`
SN string `gorm:"column:sn;size:128;not null" json:"sn"`
DevicePlugin string `gorm:"column:device_plugin;size:128;not null" json:"device_plugin"`
SoftwareVersion string `gorm:"column:software_version;size:128;not null" json:"software_version"`
Model string `gorm:"column:model;size:128;not null" json:"model"`
Disable bool `gorm:"column:disable;size:128;not null" json:"disable"`
}
type DeviceState ¶
type DeviceState struct {
Online bool `gorm:"-" json:"online"`
}
type DeviceTypePoint ¶
type DeviceTypePoint struct {
Base
TypeKey string `gorm:"size:128;uniqueIndex;not null"`
Model string `gorm:"size:128"` // 逆变器/STS
Index uint `json:"index" yaml:"index"` // 点位 index
DeveltypePointBase
}
type Goose ¶
type Goose struct {
Base
Delay time.Duration `gorm:"column:delay" json:"delay"` // 时延 单位 毫秒
DebugLog bool `gorm:"column:debug_log" json:"debug_log"` // debug log 模式
DebugExpiry time.Time `gorm:"column:debug_expiry" json:"debug_expiry"` // debuglog 截止时间
OnnectTimeout time.Duration `gorm:"column:onnect_timeout" json:"onnect_timeout"` // 连接超时时间 (ms),默认 3s
Downgrade bool `gorm:"column:down_grade" json:"down_grade"` // 设备降级
RetryMax uint64 `gorm:"column:retry_max" json:"retry_max"` // 最大重试次数,发送读指令失败后最大重试次数
RetryInterval time.Duration `gorm:"column:retry_interval" json:"retry_interval"` // 指令重新发送间隔 (ms)
Disable bool `gorm:"column:disable" json:"disable"` // disable
Plugin string `gorm:"column:plugin;size:128;not null" json:"plugin"`
TCPIPAddr string `gorm:"column:tcp_ip_addr" json:"tcp_ip_addr"`
TCPPort uint16 `gorm:"column:tcp_port" json:"tcp_port"`
Status InstanceStatus `gorm:"-" json:"status"`
}
Goose 通道
type InstanceStatus ¶
type InstanceStatus struct {
Working bool `gorm:"-" json:"working"` // 工作状态
Linking bool `gorm:"-" json:"linking"` // 连接状态
CurrentDelay time.Duration `gorm:"-" json:"current_delay"` // 当前采集延迟
BytesSent uint64 `gorm:"-" json:"bytes_sent"` // bytes sent
BytesReceived uint64 `gorm:"-" json:"bytes_received"` // bytes received
PointsToalRead uint64 `gorm:"-" json:"points_total_read"` // 点位读取数总计
PointsErrorRead uint64 `gorm:"-" json:"points_error_read"` // 点位读取错误数总计
}
type LogrusLogger ¶
func NewLogrusLogger ¶
func NewLogrusLogger(log *logrus.Logger) *LogrusLogger
func (*LogrusLogger) Error ¶
func (l *LogrusLogger) Error(ctx context.Context, msg string, args ...interface{})
func (*LogrusLogger) Info ¶
func (l *LogrusLogger) Info(ctx context.Context, msg string, args ...interface{})
func (*LogrusLogger) LogMode ¶
func (l *LogrusLogger) LogMode(level logger.LogLevel) logger.Interface
type MQTT ¶
type MQTT struct {
Base
ID string `gorm:"primaryKey;column:id;size:36;uniqueIndex;not null" json:"id"`
Delay time.Duration `gorm:"column:delay" json:"delay"` // 时延 单位 毫秒
DebugLog bool `gorm:"column:debug_log" json:"debug_log"` // debug log 模式
DebugExpiry time.Time `gorm:"column:debug_expiry" json:"debug_expiry"` // debuglog 截止时间
OnnectTimeout time.Duration `gorm:"column:onnect_timeout" json:"onnect_timeout"` // 连接超时时间 (ms),默认 3s
Downgrade bool `gorm:"column:down_grade" json:"down_grade"` // 设备降级
RetryMax uint64 `gorm:"column:retry_max" json:"retry_max"` // 最大重试次数,发送读指令失败后最大重试次数
RetryInterval time.Duration `gorm:"column:retry_interval" json:"retry_interval"` // 指令重新发送间隔 (ms)
Disable bool `gorm:"column:disable" json:"disable"` // disable
Plugin string `gorm:"column:plugin;size:128;not null" json:"plugin"`
TCPIPAddr string `gorm:"column:tcp_ip_addr" json:"tcp_ip_addr"`
TCPPort uint16 `gorm:"column:tcp_port" json:"tcp_port"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Status InstanceStatus `gorm:"-" json:"status"`
}
MQTT 通道
type ModelInfo ¶
type ModelInfo struct {
// StructType must be a non-pointer struct type, e.g. reflect.TypeOf(User{})
StructType reflect.Type
// Table is resolved by GORM schema (honors TableName() and naming strategy)
Table string
// DefaultPreloads are applied on every FindByTablePK call.
DefaultPreloads []string
}
ModelInfo describes a model type and optional default preloads. ModelInfo:模型类型 + 默认 Preload
type ModelOpt ¶
type ModelOpt func(*ModelInfo)
ModelOpt allows configuring model info at register time. ModelOpt:注册模型时的配置项
func WithDefaultPreloads ¶
WithDefaultPreloads sets default preloads for this model. WithDefaultPreloads:给该模型设置“默认 Preload 列表”(每次 Find 都会自动 Preload)
type QueryOpt ¶
type QueryOpt func(*queryOptions)
QueryOpt allows customizing query (e.g., extra preloads). QueryOpt:可选的查询配置(例如额外 Preload)
func WithPreloads ¶
WithPreloads adds extra preloads for this query. WithPreloads:为本次查询额外指定 Preload(不影响注册时默认 Preload)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps DB table name -> model schema/type. Registry:tableName -> model 类型/信息
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) FindByTablePK ¶
func (r *Registry) FindByTablePK(ctx context.Context, db *gorm.DB, table string, pkValue any) (any, error)
FindByTablePK only needs table + pkValue. It will query using db.Model(&T{}).First(&T{}, pkValue) to keep soft delete/default scopes/hooks. FindByTablePK:只传 table + pkValue;内部用 Model(&T{}) + First(pk) 方式查询
func (*Registry) FindByTablePKValue ¶
func (r *Registry) FindByTablePKValue(ctx context.Context, db *gorm.DB, table string, pkValue any) (any, error)
FindByTablePKValue returns a non-pointer struct value (T) instead of *T. FindByTablePKValue:返回 struct 值(非指针)
func (*Registry) FindByTablePKWith ¶
func (r *Registry) FindByTablePKWith(ctx context.Context, db *gorm.DB, table string, pkValue any, qopts ...QueryOpt) (any, error)
FindByTablePKWith is the same as FindByTablePK, but allows optional preloads/scopes. FindByTablePKWith:在只传 table+pkValue 的基础上,允许可选 Preload/Scope
type Scalar ¶
type Scalar struct {
Kind Kind `json:"kind"`
Raw []byte `json:"raw"` // raw bytes, format depends on Kind
}
Scalar stores a typed value in raw bytes.
func (Scalar) MarshalJSON ¶
func (*Scalar) SetFloat32 ¶
func (*Scalar) SetFloat64 ¶
func (*Scalar) UnmarshalJSON ¶
type ScalarJSON ¶
type ScalarJSON []byte
ScalarJSON stores any JSON value (scalar/object/array) safely. ScalarJSON 用于安全存放任意 JSON 值(标量/对象/数组),避免 JSONB 标量 Scan 失败。
func (*ScalarJSON) Scan ¶
func (j *ScalarJSON) Scan(src any) error
Scan implements sql.Scanner / 实现 sql.Scanner
type Serial ¶
type Serial struct {
ID string `gorm:"primaryKey;column:id;size:36;uniqueIndex;not null" json:"id"`
Delay time.Duration `gorm:"column:delay" json:"delay"` // 时延 单位 毫秒
DebugLog bool `gorm:"column:debug_log" json:"debug_log"` // debug log 模式
DebugExpiry time.Time `gorm:"column:debug_expiry" json:"debug_expiry"` // debuglog 截止时间
VerifyHeader bool `gorm:"column:verify_header" json:"verify_header"` // 校验报文头
OnnectTimeout time.Duration `gorm:"column:onnect_timeout" json:"onnect_timeout"` // 连接超时时间 (ms),默认 3s
Downgrade bool `gorm:"column:down_grade" json:"down_grade"` // 设备降级
RetryMax uint64 `gorm:"column:retry_max" json:"retry_max"` // 最大重试次数,发送读指令失败后最大重试次数
RetryInterval time.Duration `gorm:"column:retry_interval" json:"retry_interval"` // 指令重新发送间隔 (ms)
Endianness uint `gorm:"column:endianness" json:"endianness"` // endianness
WordOrder uint `gorm:"column:word_order" json:"word_order"` // word ordering
SendInterval time.Duration `gorm:"column:send_interval" json:"send_interval"` // 指令发送间隔 (ms)
PhysicalLink string `gorm:"column:physical_link" json:"physical_link"` // serial、RTUclient、RTUserver、TCPclient、TCPserver
Disable bool `gorm:"column:disable" json:"disable"` // disable
Plugin string `gorm:"column:plugin;size:128;not null" json:"plugin"` // plugin
Device string `gorm:"uniqueIndex;size:256;not null" json:"device"` // Device is like "/dev/ttyUSB0" / 设备路径,例如 "/dev/ttyUSB0"
Device2 string `gorm:"uniqueIndex;size:256;not null" json:"device2"` // Device is like "/dev/ttyUSB0" / 设备路径,例如 "/dev/ttyUSB1"
StopBits uint `gorm:"column:stop_bits" json:"stop_bits"` // 停止位
Speed uint `gorm:"column:speed" json:"speed"` // speed
DataBits uint `gorm:"column:data_bits" json:"data_bits"` // data bits
Parity uint `gorm:"column:parity" json:"parity"` // parity
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Status InstanceStatus `gorm:"-" json:"status"`
}
Serial 通道
func GetDefaultSerialRow ¶
type Setting ¶
type Setting struct {
// UUID string primary key
// UUID 字符串主键
ID string `json:"id" gorm:"primaryKey;type:char(36)"`
// Unique key name
// 唯一配置名
Name string `json:"name" gorm:"size:128;uniqueIndex;not null"`
// Discriminator for value type: int|string|bool
// 值类型判别字段:int|string|bool
ValueType string `json:"value_type" gorm:"size:16;not null;index"`
// ValueJSON stores raw JSON scalar (10/"abc"/true) / 原始 JSON 标量
ValueJSON ScalarJSON `json:"value_json" gorm:"type:jsonb;not null" swaggertype:"string" example:"10"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Setting 系统配置表 Setting represents system settings table.
value_json 存放 JSON 原始值:可以是 number/string/bool value_type 作为判别字段:int/string/bool
func (*Setting) BeforeCreate ¶
BeforeCreate 在创建前生成 UUID / generate UUID before insert.
type Site ¶
type Site struct {
gorm.Model
UUID string `gorm:"primaryKey;column:uuid;size:36;uniqueIndex;not null" json:"uuid"`
Name string `gorm:"column:name;size:1024;uniqueIndex;not null" json:"name"`
Power uint64 // 电站额定充放电功率,单位 瓦特
Store uint64 // 电站额定储能容量,单位 瓦特H
GridConTime time.Time // 并网/启用时间
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type User ¶
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
Username string `gorm:"uniqueIndex;size:64;not null" json:"username"`
PasswordHash string `gorm:"size:255;not null" json:"-"`
IsRoot bool `gorm:"not null;default:false" json:"is_root"`
LastLogin *time.Time `json:"last_login"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents a local account. User 表示本地账号。