modified: main_dc/yalarba/api_yal/internal/database/psql_db.go
new file: main_dc/yalarba/api_yal/internal/models/appeal.go add appeal struct and add it into autoMigrate
This commit is contained in:
@@ -49,6 +49,7 @@ func autoMigrate(db *gorm.DB) error {
|
|||||||
&models.Rating{},
|
&models.Rating{},
|
||||||
&models.Feedback{},
|
&models.Feedback{},
|
||||||
&models.Comment{},
|
&models.Comment{},
|
||||||
|
&models.Appeal{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, model := range models {
|
for _, model := range models {
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppealType определяет тип обращения
|
||||||
|
type AppealType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// AppealTypeComplaint - жалоба
|
||||||
|
AppealTypeComplaint AppealType = "complaint"
|
||||||
|
// AppealTypeSuggestion - предложение
|
||||||
|
AppealTypeSuggestion AppealType = "suggestion"
|
||||||
|
// AppealTypeWish - пожелание
|
||||||
|
AppealTypeWish AppealType = "wish"
|
||||||
|
// AppealTypeQuestion - вопрос
|
||||||
|
AppealTypeQuestion AppealType = "question"
|
||||||
|
// AppealTypeOther - другое
|
||||||
|
AppealTypeOther AppealType = "other"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppealStatus определяет статус обработки обращения
|
||||||
|
type AppealStatus string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// AppealStatusNew - новое обращение
|
||||||
|
AppealStatusNew AppealStatus = "new"
|
||||||
|
// AppealStatusInProgress - в обработке
|
||||||
|
AppealStatusInProgress AppealStatus = "in_progress"
|
||||||
|
// AppealStatusResolved - решено
|
||||||
|
AppealStatusResolved AppealStatus = "resolved"
|
||||||
|
// AppealStatusRejected - отклонено
|
||||||
|
AppealStatusRejected AppealStatus = "rejected"
|
||||||
|
// AppealStatusClosed - закрыто
|
||||||
|
AppealStatusClosed AppealStatus = "closed"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppealPriority определяет приоритет обращения
|
||||||
|
type AppealPriority string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// AppealPriorityLow - низкий
|
||||||
|
AppealPriorityLow AppealPriority = "low"
|
||||||
|
// AppealPriorityMedium - средний
|
||||||
|
AppealPriorityMedium AppealPriority = "medium"
|
||||||
|
// AppealPriorityHigh - высокий
|
||||||
|
AppealPriorityHigh AppealPriority = "high"
|
||||||
|
// AppealPriorityCritical - критичный
|
||||||
|
AppealPriorityCritical AppealPriority = "critical"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Appeal представляет обращение пользователя (жалоба, предложение, пожелание)
|
||||||
|
type Appeal struct {
|
||||||
|
/*ID, CreatedAt, UpdatedAt, DeletedAt (Update's history)*/
|
||||||
|
Base Base `gorm:"embedded"`
|
||||||
|
|
||||||
|
// Автор обращения (может быть анонимным)
|
||||||
|
AuthorID *uint `gorm:"index" json:"author_id,omitempty"` // NULL для анонимных обращений
|
||||||
|
Author *Account `gorm:"foreignKey:AuthorID;references:ID" json:"author,omitempty"`
|
||||||
|
|
||||||
|
// Основная информация
|
||||||
|
Type AppealType `gorm:"not null;index" json:"type"`
|
||||||
|
Status AppealStatus `gorm:"not null;default:'new';index" json:"status"`
|
||||||
|
Priority AppealPriority `gorm:"not null;default:'medium';index" json:"priority"`
|
||||||
|
|
||||||
|
// Содержание
|
||||||
|
Title string `gorm:"not null" json:"title"`
|
||||||
|
Message string `gorm:"not null;type:text" json:"message"`
|
||||||
|
|
||||||
|
// Вложения (ссылки на файлы, изображения)
|
||||||
|
Attachments []string `gorm:"type:text[];serializer:json" json:"attachments,omitempty"`
|
||||||
|
|
||||||
|
// Контактная информация для обратной связи (если автор не авторизован)
|
||||||
|
ContactName string `json:"contact_name,omitempty"`
|
||||||
|
ContactEmail string `json:"contact_email,omitempty"`
|
||||||
|
ContactPhone string `json:"contact_phone,omitempty"`
|
||||||
|
|
||||||
|
// Связь с конкретными сущностями (опционально)
|
||||||
|
ObjectID *uint `gorm:"index" json:"object_id,omitempty"`
|
||||||
|
Object *Object `gorm:"foreignKey:ObjectID;references:ID" json:"object,omitempty"`
|
||||||
|
|
||||||
|
FeedbackID *uint `gorm:"index" json:"feedback_id,omitempty"`
|
||||||
|
Feedback *Feedback `gorm:"foreignKey:FeedbackID;references:ID" json:"feedback,omitempty"`
|
||||||
|
|
||||||
|
CommentID *uint `gorm:"index" json:"comment_id,omitempty"`
|
||||||
|
Comment *Comment `gorm:"foreignKey:CommentID;references:ID" json:"comment,omitempty"`
|
||||||
|
|
||||||
|
// Метаданные
|
||||||
|
IPAddress string `json:"ip_address,omitempty"`
|
||||||
|
UserAgent string `json:"user_agent,omitempty"`
|
||||||
|
|
||||||
|
// История обработки
|
||||||
|
AssignedToID *uint `gorm:"index" json:"assigned_to_id,omitempty"`
|
||||||
|
AssignedTo *Account `gorm:"foreignKey:AssignedToID;references:ID" json:"assigned_to,omitempty"`
|
||||||
|
|
||||||
|
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
|
||||||
|
ResolvedBy *uint `json:"resolved_by,omitempty"`
|
||||||
|
Resolution string `json:"resolution,omitempty"` // Ответ/решение по обращению
|
||||||
|
|
||||||
|
// Дополнительные поля
|
||||||
|
Category string `json:"category,omitempty"` // Пользовательская категория
|
||||||
|
Labels []string `gorm:"type:text[];serializer:json" json:"labels,omitempty"`
|
||||||
|
CustomData map[string]interface{} `gorm:"type:jsonb;serializer:json" json:"custom_data,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppealHistory записывает историю изменений статуса обращения
|
||||||
|
type AppealHistory struct {
|
||||||
|
Base Base `gorm:"embedded"`
|
||||||
|
|
||||||
|
AppealID uint `gorm:"not null;index" json:"appeal_id"`
|
||||||
|
Appeal Appeal `gorm:"foreignKey:AppealID;references:ID" json:"appeal,omitempty"`
|
||||||
|
|
||||||
|
UserID *uint `json:"user_id,omitempty"` // Кто изменил
|
||||||
|
User *Account `gorm:"foreignKey:UserID;references:ID" json:"user,omitempty"`
|
||||||
|
|
||||||
|
OldStatus AppealStatus `json:"old_status"`
|
||||||
|
NewStatus AppealStatus `json:"new_status"`
|
||||||
|
|
||||||
|
Comment string `json:"comment,omitempty"` // Пояснение к изменению
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user