package model

import (
	"time"
)

// Permissible represents a permission rule for a platform app.
// Reference: P2B M12 spec (polymorphic Permissible pattern)
type Permissible struct {
	ID                uint      `gorm:"primaryKey" json:"id"`
	PlatformAppID     uint      `gorm:"not null;index" json:"platform_app_id"`
	PermissibleType   string    `gorm:"size:100;not null;index" json:"permissible_type"` // User/Account
	PermissibleID     uint      `gorm:"not null;index" json:"permissible_id"`
	CreatedAt         time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt         time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	PlatformApp PlatformApp `gorm:"foreignKey:PlatformAppID" json:"platform_app,omitempty"`
}

func (Permissible) TableName() string { return "permissibles" }