diff --git a/internal/auth/auth.util.go b/internal/auth/auth.util.go index ddada75..91011ce 100644 --- a/internal/auth/auth.util.go +++ b/internal/auth/auth.util.go @@ -38,6 +38,9 @@ func ConvertRegisterRequestDTOToUser(dto *dto.RegisterRequestDTO, email string) func DesiredRoundDTOToModel(dto *dto.DesiredRound, userId int) model.DesiredRound { var desiredRound model.DesiredRound + if dto == nil { + return desiredRound + } desiredRound.Order = dto.Order desiredRound.Round = model.Round(dto.Round) desiredRound.UserId = uint(userId) @@ -88,6 +91,9 @@ func UserModelToUserDTO(mUser *model.User) dto.User { func InterestedFacultyToFacultyInfo(m *model.InterestedFaculty) dto.FacultyInfo { var facultyInfo dto.FacultyInfo + if m == nil { + return facultyInfo + } facultyInfo.Department.Code = m.DepartmentCode facultyInfo.Department.Name.En = m.Department.Name.En facultyInfo.Department.Name.Th = m.Department.Name.Th @@ -102,6 +108,9 @@ func InterestedFacultyToFacultyInfo(m *model.InterestedFaculty) dto.FacultyInfo func DesiredRoundModelToDTO(m *model.DesiredRound) dto.DesiredRound { var desiredRound dto.DesiredRound + if m == nil { + return desiredRound + } desiredRound.Order = m.Order desiredRound.Round = string(m.Round) return desiredRound @@ -109,6 +118,9 @@ func DesiredRoundModelToDTO(m *model.DesiredRound) dto.DesiredRound { func ScheduleModelToDTO(m *model.Schedule) dto.Schedule { var registeredEvent dto.Schedule + if m == nil { + return registeredEvent + } registeredEvent.Id = m.Id registeredEvent.CurrentAttendee = m.CurrentAttendee registeredEvent.StartsAt = m.StartsAt diff --git a/internal/dto/bilingual_field.dto.go b/internal/dto/bilingual_field.dto.go index 1c9087c..eb6a9e8 100644 --- a/internal/dto/bilingual_field.dto.go +++ b/internal/dto/bilingual_field.dto.go @@ -9,6 +9,9 @@ type BilingualField struct { func BilingualModelToDTO(m *model.Bilingual) BilingualField { var bf BilingualField + if m == nil { + return bf + } bf.En = m.En bf.Th = m.Th return bf diff --git a/internal/event/event.utils.go b/internal/event/event.utils.go index 23d1e6b..3082257 100644 --- a/internal/event/event.utils.go +++ b/internal/event/event.utils.go @@ -7,6 +7,9 @@ import ( func EventModelToDTO(m *model.Event) dto.Event { var event dto.Event + if m == nil { + return event + } event.Id = m.Id event.Name = dto.BilingualModelToDTO(&m.Name) event.Faculty.Code = m.FacultyCode @@ -26,6 +29,9 @@ func EventModelToDTO(m *model.Event) dto.Event { func ScheduleModelToDTO(m *model.Schedule) dto.Schedule { var schedule dto.Schedule + if m == nil { + return schedule + } schedule.Id = m.Id schedule.EndsAt = m.EndsAt schedule.StartsAt = m.StartsAt