72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package mapper
|
|
|
|
import (
|
|
"narasi-ahli-be/app/database/entity"
|
|
"narasi-ahli-be/app/module/ai_chat/response"
|
|
)
|
|
|
|
func AIChatSessionsResponseMapper(session *entity.AIChatSessions) *response.AIChatSessionsResponse {
|
|
result := &response.AIChatSessionsResponse{
|
|
ID: session.ID,
|
|
SessionID: session.SessionID,
|
|
UserID: session.UserID,
|
|
AgentID: session.AgentID,
|
|
Title: session.Title,
|
|
MessageCount: session.MessageCount,
|
|
IsActive: session.IsActive,
|
|
CreatedAt: session.CreatedAt,
|
|
UpdatedAt: session.UpdatedAt,
|
|
}
|
|
|
|
if session.User != nil {
|
|
result.User = &response.UserBasicInfo{
|
|
ID: session.User.ID,
|
|
Username: session.User.Username,
|
|
Fullname: session.User.Fullname,
|
|
Email: session.User.Email,
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
func AIChatMessagesResponseMapper(message *entity.AIChatMessages) *response.AIChatMessagesResponse {
|
|
return &response.AIChatMessagesResponse{
|
|
ID: message.ID,
|
|
SessionID: message.SessionID,
|
|
MessageType: message.MessageType,
|
|
Content: message.Content,
|
|
IsActive: message.IsActive,
|
|
CreatedAt: message.CreatedAt,
|
|
}
|
|
}
|
|
|
|
func AIChatSessionWithMessagesResponseMapper(session *entity.AIChatSessions, messages []*entity.AIChatMessages) *response.AIChatSessionWithMessagesResponse {
|
|
sessionResponse := AIChatSessionsResponseMapper(session)
|
|
|
|
var messagesResponse []*response.AIChatMessagesResponse
|
|
for _, message := range messages {
|
|
messagesResponse = append(messagesResponse, AIChatMessagesResponseMapper(message))
|
|
}
|
|
|
|
return &response.AIChatSessionWithMessagesResponse{
|
|
Session: sessionResponse,
|
|
Messages: messagesResponse,
|
|
}
|
|
}
|
|
|
|
func AIChatLogsResponseMapper(log *entity.AIChatLogs) *response.AIChatLogsResponse {
|
|
result := &response.AIChatLogsResponse{
|
|
ID: log.ID,
|
|
UserID: log.UserID,
|
|
SessionID: log.SessionID,
|
|
StartDate: log.StartDate,
|
|
EndDate: log.EndDate,
|
|
TotalDuration: log.TotalDuration,
|
|
CreatedAt: log.CreatedAt,
|
|
UpdatedAt: log.UpdatedAt,
|
|
}
|
|
|
|
return result
|
|
}
|