S SmartDocs
シリーズ: Go go 31 行 · 更新日 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"
}

関連記事