27 lines
1.2 KiB
Plaintext
27 lines
1.2 KiB
Plaintext
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// AccountUser represents the join between User and Account with role info.
|
|
// Reference: Chatwoot AccountUser model + P2B M1 spec
|
|
type AccountUser struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
AccountID uint `gorm:"not null;index" json:"account_id"`
|
|
UserID uint `gorm:"not null;index" json:"user_id"`
|
|
Role string `gorm:"size:50;not null;default:'agent'" json:"role"` // agent/administrator
|
|
CustomRoleID uint `gorm:"index" json:"custom_role_id"`
|
|
Availability string `gorm:"size:50;default:'offline'" json:"availability"` // online/offline/busy
|
|
AutoOffline bool `gorm:"default:false" json:"auto_offline"`
|
|
ActiveAt *time.Time `json:"active_at,omitempty"`
|
|
InvitedByID uint `gorm:"index" json:"invited_by_id"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
|
|
Account Account `gorm:"foreignKey:AccountID" json:"account,omitempty"`
|
|
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
CustomRole *CustomRole `gorm:"foreignKey:CustomRoleID" json:"custom_role,omitempty"`
|
|
}
|
|
|
|
func (AccountUser) TableName() string { return "account_users" } |