You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
984 B
Go
36 lines
984 B
Go
package http
|
|
|
|
import (
|
|
"time"
|
|
|
|
domain "knowfoolery/backend/services/question-bank-service/internal/domain/question"
|
|
)
|
|
|
|
// QuestionResponse is a public API response payload for question data.
|
|
type QuestionResponse struct {
|
|
ID string `json:"id"`
|
|
Theme string `json:"theme"`
|
|
Text string `json:"text"`
|
|
Hint string `json:"hint,omitempty"`
|
|
Difficulty domain.Difficulty `json:"difficulty"`
|
|
IsActive bool `json:"is_active,omitempty"`
|
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
}
|
|
|
|
func toQuestionResponse(q *domain.Question, admin bool) QuestionResponse {
|
|
resp := QuestionResponse{
|
|
ID: q.ID,
|
|
Theme: q.Theme,
|
|
Text: q.Text,
|
|
Hint: q.Hint,
|
|
Difficulty: q.Difficulty,
|
|
}
|
|
if admin {
|
|
resp.IsActive = q.IsActive
|
|
resp.CreatedAt = &q.CreatedAt
|
|
resp.UpdatedAt = &q.UpdatedAt
|
|
}
|
|
return resp
|
|
}
|