73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package profile
|
|
|
|
import (
|
|
"base/internal/domain/profile"
|
|
"base/internal/dto"
|
|
)
|
|
|
|
// DomainProfileToProfileResponse converts a domain profile to ProfileResponse.
|
|
// Used by specialist overview and other consumers that have a domain profile.
|
|
func DomainProfileToProfileResponse(p *profile.Profile) *dto.ProfileResponse {
|
|
if p == nil {
|
|
return nil
|
|
}
|
|
roleLevel := ""
|
|
if p.Hero.Role != nil {
|
|
roleLevel = p.Hero.Role.Level
|
|
}
|
|
resp := &dto.ProfileResponse{
|
|
ID: p.ID,
|
|
Handle: p.Handle,
|
|
PageSectionOrder: p.PageSectionOrder,
|
|
Hero: dto.HeroDTO{
|
|
RoleLevel: roleLevel,
|
|
FirstName: p.Hero.FirstName,
|
|
LastName: p.Hero.LastName,
|
|
Company: p.Hero.Company,
|
|
ShortDescription: p.Hero.ShortDescription,
|
|
ResumeLink: p.Hero.ResumeLink,
|
|
CTAEnabled: p.Hero.CTAEnabled,
|
|
Avatar: p.Hero.Avatar,
|
|
},
|
|
About: dto.AboutDTO{
|
|
ProfilePicture: p.About.ProfilePicture,
|
|
About: p.About.About,
|
|
},
|
|
Contact: dto.ContactDTO{
|
|
Email: p.Contact.Email,
|
|
Phone: p.Contact.Phone,
|
|
},
|
|
PageSetting: dto.PageSettingDTO{
|
|
VisibilityLevel: p.PageSetting.VisibilityLevel,
|
|
},
|
|
}
|
|
|
|
if p.Hero.Role != nil {
|
|
resp.Hero.RoleID = &p.Hero.Role.ID
|
|
}
|
|
|
|
for _, skill := range p.Skills {
|
|
resp.Skills = append(resp.Skills, dto.SkillDTO{
|
|
SkillName: skill.SkillName,
|
|
Level: skill.Level,
|
|
})
|
|
}
|
|
|
|
for _, achievement := range p.About.Achievements {
|
|
resp.About.Achievements = append(resp.About.Achievements, dto.AchievementDTO{
|
|
Title: achievement.Title,
|
|
Value: achievement.Value,
|
|
Enabled: achievement.Enabled,
|
|
})
|
|
}
|
|
|
|
for _, sl := range p.Contact.SocialLinks {
|
|
resp.Contact.SocialLinks = append(resp.Contact.SocialLinks, dto.SocialLinkDTO{
|
|
LinkType: sl.LinkType,
|
|
Link: sl.Link,
|
|
})
|
|
}
|
|
|
|
return resp
|
|
}
|