I am batman
This commit is contained in:
33
internal/models/chatModel.go
Normal file
33
internal/models/chatModel.go
Normal 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"`
|
||||
}
|
||||
15
internal/models/clientModel.go
Normal file
15
internal/models/clientModel.go
Normal 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
|
||||
}
|
||||
21
internal/models/taskModel.go
Normal file
21
internal/models/taskModel.go
Normal 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"`
|
||||
}
|
||||
25
internal/models/ticketModel.go
Normal file
25
internal/models/ticketModel.go
Normal 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
|
||||
}
|
||||
26
internal/models/userModel.go
Normal file
26
internal/models/userModel.go
Normal 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:"-"`
|
||||
}
|
||||
Reference in New Issue
Block a user