The Go module name has been changed from `carrot_bbs` to `with_you`, which requires all import paths to be updated throughout the codebase and by external consumers. BREAKING CHANGE: Module name changed from carrot_bbs to with_you. All imports and dependencies must be updated from carrot_bbs/* to with_you/*.
36 lines
724 B
Go
36 lines
724 B
Go
package dto
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"with_you/internal/model"
|
|
)
|
|
|
|
func ConvertScheduleCourseToResponse(course *model.ScheduleCourse, weeks []int) *ScheduleCourseResponse {
|
|
if course == nil {
|
|
return nil
|
|
}
|
|
return &ScheduleCourseResponse{
|
|
ID: course.ID,
|
|
Name: course.Name,
|
|
Teacher: course.Teacher,
|
|
Location: course.Location,
|
|
DayOfWeek: course.DayOfWeek,
|
|
StartSection: course.StartSection,
|
|
EndSection: course.EndSection,
|
|
Weeks: weeks,
|
|
Color: course.Color,
|
|
}
|
|
}
|
|
|
|
func ParseWeeksJSON(raw string) []int {
|
|
if raw == "" {
|
|
return []int{}
|
|
}
|
|
var weeks []int
|
|
if err := json.Unmarshal([]byte(raw), &weeks); err != nil {
|
|
return []int{}
|
|
}
|
|
return weeks
|
|
}
|