22 lines
864 B
Plaintext
22 lines
864 B
Plaintext
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
// CustomRole represents an enterprise custom role with permission matrix.
|
|
// Reference: Chatwoot enterprise CustomRole + P2B M1 spec
|
|
type CustomRole struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
AccountID uint `gorm:"not null;index" json:"account_id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Permissions json.RawMessage `gorm:"type:jsonb;not null" json:"permissions"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
|
|
Account Account `gorm:"foreignKey:AccountID" json:"account,omitempty"`
|
|
AccountUsers []AccountUser `gorm:"foreignKey:CustomRoleID" json:"account_users,omitempty"`
|
|
}
|
|
|
|
func (CustomRole) TableName() string { return "custom_roles" } |