up
This commit is contained in:
@@ -25,10 +25,11 @@ func (ProyectoTicket) TableName() string { return "proyecto_tickets" }
|
||||
|
||||
type TicketMensaje struct {
|
||||
gorm.Model
|
||||
TicketID uint `json:"ticket_id" gorm:"column:ticket_id;index"`
|
||||
Contenido string `json:"contenido" gorm:"column:contenido;type:text"`
|
||||
EsAdmin bool `json:"es_admin" gorm:"column:es_admin;default:false"`
|
||||
AutorNombre string `json:"autor_nombre" gorm:"column:autor_nombre"`
|
||||
TicketID uint `json:"ticket_id" gorm:"column:ticket_id;index"`
|
||||
Contenido string `json:"contenido" gorm:"column:contenido;type:text"`
|
||||
EsAdmin bool `json:"es_admin" gorm:"column:es_admin;default:false"`
|
||||
AutorNombre string `json:"autor_nombre" gorm:"column:autor_nombre"`
|
||||
LeidoPortal bool `json:"leido_portal" gorm:"column:leido_portal;default:false"`
|
||||
}
|
||||
|
||||
func (TicketMensaje) TableName() string { return "ticket_mensajes" }
|
||||
@@ -77,3 +78,11 @@ func GetAllTickets(estado string) ([]ProyectoTicket, error) {
|
||||
err := db.Find(&items).Error
|
||||
return items, err
|
||||
}
|
||||
|
||||
// MarkTicketMessagesReadByPortal marca como leídos todos los mensajes de admin
|
||||
// de un ticket para el portal user (cuando abre el ticket).
|
||||
func MarkTicketMessagesReadByPortal(ticketID uint) error {
|
||||
return app.Http.Database.DB.Model(&TicketMensaje{}).
|
||||
Where("ticket_id = ? AND es_admin = true AND leido_portal = false", ticketID).
|
||||
Update("leido_portal", true).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user