Adds points to user when action completed
This commit is contained in:
13
main.go
13
main.go
@@ -133,6 +133,19 @@ func completeTask(c *gin.Context) {
|
|||||||
c.IndentedJSON(http.StatusNotModified, completedTask)
|
c.IndentedJSON(http.StatusNotModified, completedTask)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add points to user table
|
||||||
|
stmt, err = db.Prepare("UPDATE users SET points = points + ? WHERE uid=?")
|
||||||
|
if err != nil {
|
||||||
|
c.IndentedJSON(http.StatusNotModified, completedTask)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = stmt.Exec(completedTask.PointsGained, completedTask.UID)
|
||||||
|
if err != nil {
|
||||||
|
c.IndentedJSON(http.StatusNotModified, completedTask)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
c.IndentedJSON(http.StatusOK, completedTask)
|
c.IndentedJSON(http.StatusOK, completedTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user