S SmartDocs
シリーズ: Go go 37 行 · 更新日 2026-04-18

goods.go

Go/Baasid/internal/models/goods.go

package models

import (
	"time"

	"github.com/google/uuid"
)

// Goods maps to table "goods" (商品).
//
// The public REST API exposes JSON field names "_id" and "goods_name", while
// the physical column for the product title is "name" per the data
// dictionary in the specification.
type Goods struct {
	// ID is the product UUID, column "_id".
	ID uuid.UUID `gorm:"column:_id;type:uuid;primaryKey;default:gen_random_uuid()"`

	// Name is the product name (商品名稱), column "name".
	Name string `gorm:"column:name;size:128;not null"`

	// CrUser is the creator's system_user._id (外鍵).
	CrUser uuid.UUID `gorm:"column:cr_user;type:uuid;not null"`

	// CrDatetime defaults to creation time.
	CrDatetime time.Time `gorm:"column:cr_datetime;autoCreateTime"`

	// UpUser is the last updater's system_user._id (外鍵).
	UpUser uuid.UUID `gorm:"column:up_user;type:uuid;not null"`

	// UpDatetime is maintained by GORM on each update.
	UpDatetime time.Time `gorm:"column:up_datetime;autoUpdateTime"`
}

// TableName tells GORM the physical table name.
func (Goods) TableName() string {
	return "goods"
}

関連記事