I am batman

This commit is contained in:
2026-07-12 20:26:16 -04:00
commit 5a3a6357cf
37 changed files with 2938 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package models
import (
"time"
"gorm.io/gorm"
)
type Chat struct {
gorm.Model
Name string
TicketID *uint
Ticket *Ticket `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
IsPrivate bool `gorm:"default:false"`
Users []User `gorm:"many2many:chat_users;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Messages []ChatMessage `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}
type ChatMessage struct {
gorm.Model
ChatID uint
Chat Chat `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
SentAt time.Time
SenderID uint
Sender User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
Content string `gorm:"not null"`
}

View File

@@ -0,0 +1,15 @@
package models
import (
"gorm.io/gorm"
)
type Client struct {
gorm.Model
Name string `gorm:"not null"`
Email string `gorm:"uniqueIndex;not null"`
Phone string
Users []User
Tickets []Ticket
}

View File

@@ -0,0 +1,21 @@
package models
import (
"gorm.io/gorm"
)
type TaskSection struct {
gorm.Model
Title string `gorm:"not null" json:"title"`
Position int `gorm:"not null;default:0" json:"position"`
Tasks []Tasks `gorm:"foreignKey:SectionID;references:ID;constraint:OnDelete:CASCADE;" json:"tasks,omitempty"`
}
type Tasks struct {
gorm.Model
Title string `gorm:"not null" json:"title"`
Description string `json:"description"`
Position int `gorm:"not null;default:0" json:"position"`
SectionID uint `gorm:"index" json:"section_id"`
Section TaskSection `gorm:"foreignKey:SectionID;references:ID;constraint:OnDelete:CASCADE;" json:"section,omitempty"`
}

View File

@@ -0,0 +1,25 @@
package models
import (
"gorm.io/gorm"
)
type Ticket struct {
gorm.Model
Title string `gorm:"not null"`
Description string
ReporterID uint
Reporter User `gorm:"foreignKey:ReporterID"`
AssigneeID uint
Assignee User `gorm:"foreignKey:AssigneeID"`
ClientID uint
Client Client
Status string `gorm:"default:'Open'"` // Add this line
Priority string `gorm:"default:'Normal'"` // Add this line
Chats []Chat
}

View File

@@ -0,0 +1,26 @@
package models
import (
"time"
"gorm.io/gorm"
)
type User struct {
gorm.Model
Email string `gorm:"uniqueIndex;not null"`
Password string `gorm:"not null"`
Name string
Role string `gorm:"default:User"`
Active bool `gorm:"default:true"`
Username string `gorm:"uniqueIndex"`
Address string
PhoneNumber string
ProfilePhoto []byte `gorm:"type:bytea"`
ClientID *uint
Client *Client
VerificationToken string `json:"-"`
ResetToken string `json:"-"`
ResetTokenExpiry time.Time `json:"-"`
}