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

30 lines
1.4 KiB
Plaintext

package model
import (
"encoding/json"
"time"
"gorm.io/gorm"
)
// SlaPolicy represents a SLA policy for response/resolution time targets.
// Reference: Chatwoot enterprise SlaPolicy + P2B M11 spec
type SlaPolicy 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"`
Description string `gorm:"type:text" json:"description"`
FirstResponseTimeThreshold int `json:"first_response_time_threshold"` // seconds
NextResponseTimeThreshold int `json:"next_response_time_threshold"` // seconds
ResolutionTimeThreshold int `json:"resolution_time_threshold"` // seconds
OnlyDuringBusinessHours bool `gorm:"default:false" json:"only_during_business_hours"`
ConversationTags []string `gorm:"type:text[]" json:"conversation_tags"`
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"`
AppliedSLAs []AppliedSLA `gorm:"foreignKey:SlaPolicyID" json:"applied_slas,omitempty"`
}
func (SlaPolicy) TableName() string { return "sla_policies" }