@@ -20,6 +20,33 @@ func (c *Controller) hello(w http.ResponseWriter, r *http.Request) {
2020 w .Write ([]byte (GREETING ))
2121}
2222
23+ type answerResponse struct {
24+ ID uuid.UUID `json:"id"`
25+ ProblemID uuid.UUID `json:"problem_id"`
26+ ProblemCode string `json:"problem_code"`
27+ TeamID uuid.UUID `json:"team_id"`
28+ Body string `json:"body"`
29+ CreatedAt time.Time `json:"created_at"`
30+ UpdatedAt time.Time `json:"updated_at"`
31+ }
32+
33+ func newAnswerResponseFrom (answer Answer , problem Problem ) answerResponse {
34+ bodies := []string {}
35+ for _ , b := range answer .Bodies {
36+ bodies = append (bodies , b ... )
37+ }
38+
39+ return answerResponse {
40+ ID : answer .ID ,
41+ ProblemID : answer .ProblemID ,
42+ ProblemCode : problem .Code ,
43+ TeamID : answer .TeamID ,
44+ CreatedAt : answer .CreatedAt ,
45+ UpdatedAt : answer .UpdatedAt ,
46+ Body : strings .Join (bodies , "\n " ),
47+ }
48+ }
49+
2350type listProblemEnvironmentsResponse []ProblemEnvironment
2451
2552func (c * Controller ) listProblemEnvironments (w http.ResponseWriter , r * http.Request ) {
@@ -90,17 +117,7 @@ func (c *Controller) getAnswerID(w http.ResponseWriter, r *http.Request) {
90117 }
91118}
92119
93- type listLatestUnconfirmedAnswersForLocalProblemResponse []listLatestUnconfirmedAnswersForLocalProblemResponseItem
94-
95- type listLatestUnconfirmedAnswersForLocalProblemResponseItem struct {
96- ID uuid.UUID `json:"id"`
97- ProblemID uuid.UUID `json:"problem_id"`
98- ProblemCode string `json:"problem_code"`
99- TeamID uuid.UUID `json:"team_id"`
100- CreatedAt time.Time `json:"created_at"`
101- UpdatedAt time.Time `json:"updated_at"`
102- Body string `json:"body"`
103- }
120+ type listLatestUnconfirmedAnswersForLocalProblemResponse []answerResponse
104121
105122func (c * Controller ) listLatestUnconfirmedAnswersForLocalProblem (w http.ResponseWriter , r * http.Request ) {
106123 ctx := r .Context ()
0 commit comments