aboutsummaryrefslogtreecommitdiff
path: root/backend/handlers/mod.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/handlers/mod.go')
-rw-r--r--backend/handlers/mod.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/backend/handlers/mod.go b/backend/handlers/mod.go
index 72a9fd8..1348547 100644
--- a/backend/handlers/mod.go
+++ b/backend/handlers/mod.go
@@ -16,7 +16,7 @@ type CreateMapSummaryRequest struct {
16 Description string `json:"description" binding:"required"` 16 Description string `json:"description" binding:"required"`
17 Showcase string `json:"showcase"` 17 Showcase string `json:"showcase"`
18 UserName string `json:"user_name" binding:"required"` 18 UserName string `json:"user_name" binding:"required"`
19 ScoreCount int `json:"score_count" binding:"required"` 19 ScoreCount *int `json:"score_count" binding:"required"`
20 RecordDate time.Time `json:"record_date" binding:"required"` 20 RecordDate time.Time `json:"record_date" binding:"required"`
21} 21}
22 22
@@ -25,7 +25,7 @@ type EditMapSummaryRequest struct {
25 Description string `json:"description" binding:"required"` 25 Description string `json:"description" binding:"required"`
26 Showcase string `json:"showcase"` 26 Showcase string `json:"showcase"`
27 UserName string `json:"user_name" binding:"required"` 27 UserName string `json:"user_name" binding:"required"`
28 ScoreCount int `json:"score_count" binding:"required"` 28 ScoreCount *int `json:"score_count" binding:"required"`
29 RecordDate time.Time `json:"record_date" binding:"required"` 29 RecordDate time.Time `json:"record_date" binding:"required"`
30} 30}
31 31
@@ -95,7 +95,7 @@ func CreateMapSummary(c *gin.Context) {
95 // Update database with new data 95 // Update database with new data
96 sql = `INSERT INTO map_history (map_id,category_id,user_name,score_count,description,showcase,record_date) 96 sql = `INSERT INTO map_history (map_id,category_id,user_name,score_count,description,showcase,record_date)
97 VALUES ($1,$2,$3,$4,$5)` 97 VALUES ($1,$2,$3,$4,$5)`
98 _, err = tx.Exec(sql, mapID, request.CategoryID, request.UserName, request.ScoreCount, request.Description, request.Showcase, request.RecordDate) 98 _, err = tx.Exec(sql, mapID, request.CategoryID, request.UserName, *request.ScoreCount, request.Description, request.Showcase, request.RecordDate)
99 if err != nil { 99 if err != nil {
100 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryCreateFail, fmt.Sprintf("INSERT#map_history: %s", err.Error())) 100 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryCreateFail, fmt.Sprintf("INSERT#map_history: %s", err.Error()))
101 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 101 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))
@@ -105,7 +105,7 @@ func CreateMapSummary(c *gin.Context) {
105 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 105 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))
106 return 106 return
107 } 107 }
108 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryCreateSuccess, fmt.Sprintf("MapID: %d | CategoryID: %d | ScoreCount: %d", mapID, request.CategoryID, request.ScoreCount)) 108 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryCreateSuccess, fmt.Sprintf("MapID: %d | CategoryID: %d | ScoreCount: %d", mapID, request.CategoryID, *request.ScoreCount))
109 c.JSON(http.StatusOK, models.Response{ 109 c.JSON(http.StatusOK, models.Response{
110 Success: true, 110 Success: true,
111 Message: "Successfully created map summary.", 111 Message: "Successfully created map summary.",
@@ -158,7 +158,7 @@ func EditMapSummary(c *gin.Context) {
158 defer tx.Rollback() 158 defer tx.Rollback()
159 // Update database with new data 159 // Update database with new data
160 sql := `UPDATE map_history SET user_name = $2, score_count = $3, record_date = $4, description = $5, showcase = $6 WHERE id = $1` 160 sql := `UPDATE map_history SET user_name = $2, score_count = $3, record_date = $4, description = $5, showcase = $6 WHERE id = $1`
161 _, err = tx.Exec(sql, request.RouteID, request.UserName, request.ScoreCount, request.RecordDate, request.Description, request.Showcase) 161 _, err = tx.Exec(sql, request.RouteID, request.UserName, *request.ScoreCount, request.RecordDate, request.Description, request.Showcase)
162 if err != nil { 162 if err != nil {
163 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryEditFail, fmt.Sprintf("(HistoryID: %d) UPDATE#map_history: %s", request.RouteID, err.Error())) 163 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryEditFail, fmt.Sprintf("(HistoryID: %d) UPDATE#map_history: %s", request.RouteID, err.Error()))
164 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 164 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))