Files
gochat/internal/model/tag.go
T
2026-06-04 15:44:48 +08:00

24 lines
933 B
Go

package model
import (
"time"
"gorm.io/gorm"
)
// Tag represents a label/tag used across conversations and contacts.
// Reference: Chatwoot Tag + Taggings merged + P2B M4 spec
// Each tag belongs to an account and has a unique name within that account.
type Tag struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AccountID uint `gorm:"not null;uniqueIndex:idx_tag_account_name" json:"account_id"`
Name string `gorm:"size:255;not null;uniqueIndex:idx_tag_account_name" json:"name"`
Color string `gorm:"size:50" json:"color,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
Account Account `gorm:"foreignKey:AccountID" json:"account,omitempty"`
}
func (Tag) TableName() string { return "tags" }