diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-07-03 23:20:33 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-07-03 23:20:33 +0300 |
| commit | b1e2389ff27a16f25ffa3b74d2c68442f0dda12b (patch) | |
| tree | 4aada25fc3e681a286771b71385aa2826f64bac9 | |
| parent | docs: refactor docs (diff) | |
| download | lphub-b1e2389ff27a16f25ffa3b74d2c68442f0dda12b.tar.gz lphub-b1e2389ff27a16f25ffa3b74d2c68442f0dda12b.tar.bz2 lphub-b1e2389ff27a16f25ffa3b74d2c68442f0dda12b.zip | |
feat: display score count and time in record response (#42)
Former-commit-id: f123f9383519780a6e6d0f6828332635b93bad82
| -rw-r--r-- | backend/controllers/recordController.go | 8 | ||||
| -rw-r--r-- | backend/models/responses.go | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go index af8eb63..d1404f4 100644 --- a/backend/controllers/recordController.go +++ b/backend/controllers/recordController.go | |||
| @@ -2,7 +2,7 @@ package controllers | |||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | b64 "encoding/base64" | 5 | "encoding/base64" |
| 6 | "io" | 6 | "io" |
| 7 | "log" | 7 | "log" |
| 8 | "mime/multipart" | 8 | "mime/multipart" |
| @@ -31,7 +31,7 @@ import ( | |||
| 31 | // @Param partner_demo formData file false "Partner Demo" | 31 | // @Param partner_demo formData file false "Partner Demo" |
| 32 | // @Param is_partner_orange formData boolean false "Is Partner Orange" | 32 | // @Param is_partner_orange formData boolean false "Is Partner Orange" |
| 33 | // @Param partner_id formData string false "Partner ID" | 33 | // @Param partner_id formData string false "Partner ID" |
| 34 | // @Success 200 {object} models.Response | 34 | // @Success 200 {object} models.Response{data=models.RecordResponse} |
| 35 | // @Failure 400 {object} models.Response | 35 | // @Failure 400 {object} models.Response |
| 36 | // @Failure 401 {object} models.Response | 36 | // @Failure 401 {object} models.Response |
| 37 | // @Router /maps/{id}/record [post] | 37 | // @Router /maps/{id}/record [post] |
| @@ -183,7 +183,7 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 183 | c.JSON(http.StatusOK, models.Response{ | 183 | c.JSON(http.StatusOK, models.Response{ |
| 184 | Success: true, | 184 | Success: true, |
| 185 | Message: "Successfully created record.", | 185 | Message: "Successfully created record.", |
| 186 | Data: nil, | 186 | Data: models.RecordResponse{ScoreCount: hostDemoScoreCount, ScoreTime: hostDemoScoreTime}, |
| 187 | }) | 187 | }) |
| 188 | } | 188 | } |
| 189 | 189 | ||
| @@ -240,7 +240,7 @@ func DownloadDemoWithID(c *gin.Context) { | |||
| 240 | 240 | ||
| 241 | // Use Service account | 241 | // Use Service account |
| 242 | func serviceAccount() *http.Client { | 242 | func serviceAccount() *http.Client { |
| 243 | privateKey, _ := b64.StdEncoding.DecodeString(os.Getenv("GOOGLE_PRIVATE_KEY_BASE64")) | 243 | privateKey, _ := base64.StdEncoding.DecodeString(os.Getenv("GOOGLE_PRIVATE_KEY_BASE64")) |
| 244 | config := &jwt.Config{ | 244 | config := &jwt.Config{ |
| 245 | Email: os.Getenv("GOOGLE_CLIENT_EMAIL"), | 245 | Email: os.Getenv("GOOGLE_CLIENT_EMAIL"), |
| 246 | PrivateKey: []byte(privateKey), | 246 | PrivateKey: []byte(privateKey), |
diff --git a/backend/models/responses.go b/backend/models/responses.go index dc554ff..459911c 100644 --- a/backend/models/responses.go +++ b/backend/models/responses.go | |||
| @@ -50,6 +50,11 @@ type ChapterMapsResponse struct { | |||
| 50 | Maps []MapShort `json:"maps"` | 50 | Maps []MapShort `json:"maps"` |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | type RecordResponse struct { | ||
| 54 | ScoreCount int `json:"score_count"` | ||
| 55 | ScoreTime int `json:"score_time"` | ||
| 56 | } | ||
| 57 | |||
| 53 | func ErrorResponse(message string) Response { | 58 | func ErrorResponse(message string) Response { |
| 54 | return Response{ | 59 | return Response{ |
| 55 | Success: false, | 60 | Success: false, |