Skip to content

Commit

Permalink
fix: do not show user_id in floor history when user changed it himself
Browse files Browse the repository at this point in the history
  • Loading branch information
ppolariss committed Sep 28, 2024
1 parent 32a7df5 commit 68f4c90
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions apis/floor/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,24 @@ func GetFloorHistory(c *fiber.Ctx) error {
return common.Forbidden()
}

var floor Floor
var histories []FloorHistory
result := DB.Where("floor_id = ?", floorID).Find(&histories)
if result.Error != nil {
return result.Error

err = DB.Transaction(func(tx *gorm.DB) (err error) {
err = tx.First(&floor, floorID).Error
if err != nil {
return
}
err = tx.Where("floor_id = ?", floorID).Find(&histories).Error
return
})
if err != nil {
return err
}
for _, history := range histories {
if floor.UserID == history.UserID {
history.UserID = 1
}
}
return c.JSON(&histories)
}
Expand Down

0 comments on commit 68f4c90

Please sign in to comment.