修复put

This commit is contained in:
jiayuqi7813
2022-07-14 00:23:48 +08:00
parent f383eab282
commit e70bde7bd4

View File

@@ -139,19 +139,20 @@ func EditChallenge(c *gin.Context) {
c.JSON(400, gin.H{"code": 400, "msg": "Request format wrong!"}) c.JSON(400, gin.H{"code": 400, "msg": "Request format wrong!"})
return return
} }
challenge := &Challenge{ attachmentString := strings.Join(request.Attachment, ",")
ID: cid, hintString := strings.Join(request.Hints, ",")
challenge := &CrDb{
Name: request.Name, Name: request.Name,
Score: request.Score, Score: request.Score,
Flag: request.Flag, Flag: request.Flag,
Description: request.Description, Description: request.Description,
Attachment: request.Attachment, Attachment: attachmentString,
Category: request.Category, Category: request.Category,
Tags: request.Tags, Tags: request.Tags,
Hints: request.Hints, Hints: hintString,
Visible: request.Visible, Visible: request.Visible,
} }
err := DB.Table("challenge").Where("id = ?", cid).Updates(challenge).Error err := DB.Debug().Table("challenge").Where("id = ?", cid).Updates(challenge).Error
if err != nil { if err != nil {
c.JSON(400, gin.H{"code": 400, "msg": "Update challenge failure!"}) c.JSON(400, gin.H{"code": 400, "msg": "Update challenge failure!"})
return return