43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package web
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"ymhut-box/server/unified-management/internal/db"
|
|
)
|
|
|
|
type legacyFeedbackStatusDTO struct {
|
|
OK bool `json:"ok"`
|
|
Code string `json:"code"`
|
|
Status string `json:"status"`
|
|
StatusLabel string `json:"statusLabel"`
|
|
StatusDetail string `json:"statusDetail"`
|
|
Category string `json:"category"`
|
|
Priority string `json:"priority"`
|
|
HasReply bool `json:"hasReply"`
|
|
Reply string `json:"reply"`
|
|
ReceivedAt string `json:"receivedAt"`
|
|
UpdatedAt string `json:"updatedAt"`
|
|
MailSent bool `json:"mailSent"`
|
|
Duplicate bool `json:"duplicate,omitempty"`
|
|
}
|
|
|
|
func legacyFeedbackStatus(item db.Feedback, duplicate bool) legacyFeedbackStatusDTO {
|
|
reply := strings.TrimSpace(item.PublicReply)
|
|
return legacyFeedbackStatusDTO{
|
|
OK: true,
|
|
Code: item.Code,
|
|
Status: firstNonEmpty(item.Status, "new"),
|
|
StatusLabel: feedbackStatusLabel(item.Status),
|
|
StatusDetail: item.StatusDetail,
|
|
Category: item.Category,
|
|
Priority: item.Priority,
|
|
HasReply: reply != "",
|
|
Reply: reply,
|
|
ReceivedAt: item.CreatedAt,
|
|
UpdatedAt: firstNonEmpty(item.LastActivityAt, item.UpdatedAt, item.CreatedAt),
|
|
MailSent: item.MailSent,
|
|
Duplicate: duplicate,
|
|
}
|
|
}
|