introducing redux and fixing stuff

This commit is contained in:
2022-03-23 01:53:45 +01:00
parent c6bef04c73
commit 66a61d4cf9
29 changed files with 567 additions and 188 deletions

View File

@@ -26,16 +26,17 @@ func getCardById(c *gin.Context) {
}
func createCard(c *gin.Context) {
var card models.Card
var card models.CardDto
if err := c.BindJSON(&card); err != nil {
return
}
card.UserID = c.GetUint("user_id")
cardDbo := card.ToDbo()
cardDbo.UserID = uint(c.GetFloat64("user_id"))
if models.DB.Create(&card).Save(&card).Error != nil {
if models.DB.Create(&cardDbo).Save(&cardDbo).Error != nil {
return
}
c.IndentedJSON(http.StatusCreated, card.ToDto())
c.IndentedJSON(http.StatusCreated, cardDbo.ToDto())
}
func updateCard(c *gin.Context) {

View File

@@ -40,7 +40,7 @@ func createCardDeck(c *gin.Context) {
if err := c.BindJSON(&cardDeck); err != nil {
return
}
cardDeck.UserID = c.GetUint("user_id")
cardDeck.UserID = uint(c.GetFloat64("user_id"))
if models.DB.Scopes(auth.UserScope(c)).Create(&cardDeck).Save(&cardDeck).Error != nil {
return