Serie: Go
go
31 righe
· Aggiornato 2026-04-18
system_user.go
Go/Baasid/internal/models/system_user.go
// Package models defines GORM entity structs that map to PostgreSQL tables.
//
// Table and column names follow the specification document (Baasid backend
// project v1.1): system_user uses "_id" as primary key column name, matching
// the goods table's foreign-key references.
package models
import "github.com/google/uuid"
// SystemUser maps to table "system_user" (登入帳號).
//
// Password stores a bcrypt hash (never the plaintext password). The spec
// lists varchar(128); a bcrypt hash is 60 characters, so 128 is sufficient.
type SystemUser struct {
// ID is the primary key UUID, column "_id" in SQL.
ID uuid.UUID `gorm:"column:_id;type:uuid;primaryKey;default:gen_random_uuid()"`
// Account is the login name; unique across the whole system.
Account string `gorm:"size:128;uniqueIndex;not null"`
// Password is the bcrypt hash of the user's password.
Password string `gorm:"size:128;not null"`
// Name is the display name returned to the client after successful login.
Name string `gorm:"size:128"`
}
// TableName tells GORM to use "system_user" instead of the default plural.
func (SystemUser) TableName() string {
return "system_user"
}
Articoli correlati
Go
go
Aggiornato 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/hashpw/main.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/server/main.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
docs.go
docs.go — go source code from the Go learning materials (Go/Baasid/docs/docs.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
jwt.go
jwt.go — go source code from the Go learning materials (Go/Baasid/internal/auth/jwt.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
password.go
password.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
password_test.go
password_test.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password_test.go).
Leggi l'articolo →