package mapper import ( "encoding/json" "jaecoo-be/app/database/entity" res "jaecoo-be/app/module/sales_agents/response" ) func SalesAgentsResponseMapper(agent *entity.SalesAgents, host string) *res.SalesAgentsResponse { if agent == nil { return nil } var agentType []string if agent.AgentType != nil && *agent.AgentType != "" { json.Unmarshal([]byte(*agent.AgentType), &agentType) } response := &res.SalesAgentsResponse{ ID: agent.ID, Name: agent.Name, JobTitle: agent.JobTitle, Phone: agent.Phone, AgentType: agentType, ProfilePicturePath: agent.ProfilePicturePath, IsActive: agent.IsActive, CreatedAt: agent.CreatedAt, UpdatedAt: agent.UpdatedAt, } if agent.ProfilePicturePath != nil && *agent.ProfilePicturePath != "" { profilePictureUrl := host + "/sales-agents/profile-picture/viewer/" + *agent.ProfilePicturePath response.ProfilePictureUrl = &profilePictureUrl } return response }