From b1e2389ff27a16f25ffa3b74d2c68442f0dda12b Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Mon, 3 Jul 2023 23:20:33 +0300 Subject: feat: display score count and time in record response (#42) Former-commit-id: f123f9383519780a6e6d0f6828332635b93bad82 --- backend/controllers/recordController.go | 8 ++++---- backend/models/responses.go | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'backend') 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 import ( "context" - b64 "encoding/base64" + "encoding/base64" "io" "log" "mime/multipart" @@ -31,7 +31,7 @@ import ( // @Param partner_demo formData file false "Partner Demo" // @Param is_partner_orange formData boolean false "Is Partner Orange" // @Param partner_id formData string false "Partner ID" -// @Success 200 {object} models.Response +// @Success 200 {object} models.Response{data=models.RecordResponse} // @Failure 400 {object} models.Response // @Failure 401 {object} models.Response // @Router /maps/{id}/record [post] @@ -183,7 +183,7 @@ func CreateRecordWithDemo(c *gin.Context) { c.JSON(http.StatusOK, models.Response{ Success: true, Message: "Successfully created record.", - Data: nil, + Data: models.RecordResponse{ScoreCount: hostDemoScoreCount, ScoreTime: hostDemoScoreTime}, }) } @@ -240,7 +240,7 @@ func DownloadDemoWithID(c *gin.Context) { // Use Service account func serviceAccount() *http.Client { - privateKey, _ := b64.StdEncoding.DecodeString(os.Getenv("GOOGLE_PRIVATE_KEY_BASE64")) + privateKey, _ := base64.StdEncoding.DecodeString(os.Getenv("GOOGLE_PRIVATE_KEY_BASE64")) config := &jwt.Config{ Email: os.Getenv("GOOGLE_CLIENT_EMAIL"), 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 { Maps []MapShort `json:"maps"` } +type RecordResponse struct { + ScoreCount int `json:"score_count"` + ScoreTime int `json:"score_time"` +} + func ErrorResponse(message string) Response { return Response{ Success: false, -- cgit v1.2.3