Files
Unified_Dashboard_Suite_Go/internal/khira/models.go
T

201 lines
6.9 KiB
Go

package khira
import "time"
type Role string
const (
RoleTester Role = "tester"
RoleIOS Role = "ios_dev"
RoleAndroid Role = "android_dev"
RoleBackend Role = "backend_dev"
RoleDesigner Role = "designer"
RoleLead Role = "team_lead"
)
func (r Role) DisplayName() string {
switch r {
case RoleTester:
return "Tester"
case RoleIOS, "frontend", "frontend_dev", "ios":
return "iOS Dev"
case RoleAndroid, "android":
return "Android Dev"
case RoleBackend, "backend":
return "Backend Dev"
case RoleDesigner, "design":
return "Designer"
case RoleLead, "lead", "admin":
return "Team Lead"
default:
return string(r)
}
}
func (r Role) IsValid() bool {
switch r {
case RoleTester, RoleIOS, RoleAndroid, RoleBackend, RoleDesigner, RoleLead:
return true
case "frontend_dev", "frontend", "backend", "lead", "engineer", "security":
return true
default:
return false
}
}
type User struct {
ID string `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
PasswordHash string `json:"password_hash,omitempty"`
Role string `json:"role"`
RoleDisplay string `json:"role_display"`
Avatar string `json:"avatar"`
AvatarType string `json:"avatar_type"`
ProfileImage string `json:"profile_image"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (u *User) Public() *User {
if u == nil {
return nil
}
clone := *u
clone.PasswordHash = ""
return &clone
}
type Priority string
const (
PriorityCritical Priority = "critical"
PriorityHigh Priority = "high"
PriorityMedium Priority = "medium"
PriorityLow Priority = "low"
)
type Status string
const (
StatusOpen Status = "open"
StatusInProgress Status = "in_progress"
StatusOnHold Status = "on_hold"
StatusCompleted Status = "completed"
StatusClosed Status = "closed"
)
type Attachment struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Size int64 `json:"size"`
Type string `json:"type"` // "file", "image", "link"
UploadedBy string `json:"uploaded_by"`
CreatedAt time.Time `json:"created_at"`
}
type Remark struct {
ID string `json:"id"`
AuthorUsername string `json:"author_username"`
AuthorName string `json:"author_name"`
AuthorRole string `json:"author_role"`
Type string `json:"type"` // comment, hold, resume, complete, priority_change, reassign, created, attachment, link
Text string `json:"text"`
Attachments []Attachment `json:"attachments,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type Ticket struct {
ID string `json:"id"`
Title string `json:"title"`
TicketType string `json:"ticket_type"` // "general" | "application"
GeneralCategory string `json:"general_category,omitempty"`
Department string `json:"department,omitempty"`
AppName string `json:"app_name,omitempty"`
Version string `json:"version,omitempty"`
FeatureName string `json:"feature_name,omitempty"`
APIKey string `json:"api_key,omitempty"`
IssueType string `json:"issue_type,omitempty"`
Priority string `json:"priority"`
Status string `json:"status"`
Description string `json:"description"`
AssistanceRequired string `json:"assistance_required"`
AdditionalInfo string `json:"additional_info,omitempty"`
CreatedBy string `json:"created_by"`
CreatedByName string `json:"created_by_name"`
CreatedByRole string `json:"created_by_role"`
AssignedTo string `json:"assigned_to"`
AssignedToName string `json:"assigned_to_name"`
AssignedToRole string `json:"assigned_to_role"`
HoldReason string `json:"hold_reason,omitempty"`
HeldBy string `json:"held_by,omitempty"`
HeldAt *time.Time `json:"held_at,omitempty"`
CompletionRemarks string `json:"completion_remarks,omitempty"`
CompletedBy string `json:"completed_by,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
Links []string `json:"links,omitempty"`
LinkedErrorID string `json:"linked_error_id,omitempty"`
Archived bool `json:"archived"`
Remarks []Remark `json:"remarks"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ErrorSeverity string
const (
SeverityCritical ErrorSeverity = "critical"
SeverityHigh ErrorSeverity = "high"
SeverityMedium ErrorSeverity = "medium"
SeverityLow ErrorSeverity = "low"
)
type ErrorStatus string
const (
ErrorStatusUnresolved ErrorStatus = "unresolved"
ErrorStatusInvestigating ErrorStatus = "investigating"
ErrorStatusResolved ErrorStatus = "resolved"
ErrorStatusIgnored ErrorStatus = "ignored"
)
type AppError struct {
ID string `json:"id"`
Fingerprint string `json:"fingerprint"`
AppName string `json:"app_name"`
Version string `json:"version"`
Environment string `json:"environment"` // production, staging, development
Service string `json:"service"` // feature / subsystem name
Endpoint string `json:"endpoint,omitempty"`
ExceptionType string `json:"exception_type"`
Message string `json:"message"`
StackTrace string `json:"stack_trace"`
Severity string `json:"severity"` // critical, high, medium, low
Status string `json:"status"` // unresolved, investigating, resolved, ignored
Occurrences int `json:"occurrences"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
ResolvedBy string `json:"resolved_by,omitempty"`
ResolutionNotes string `json:"resolution_notes,omitempty"`
LinkedTicketID string `json:"linked_ticket_id,omitempty"`
CreatedBy string `json:"created_by"`
RequestPayload string `json:"request_payload,omitempty"`
Archived bool `json:"archived"`
CreatedAt time.Time `json:"created_at"`
Tags []string `json:"tags,omitempty"`
}
type Notification struct {
ID string `json:"id"`
UserID string `json:"user_id"`
TicketID string `json:"ticket_id"`
Title string `json:"title"`
Message string `json:"message"`
Type string `json:"type"` // assignment, status_change, hold, complete, remark
Read bool `json:"read"`
CreatedAt time.Time `json:"created_at"`
}