Skip to content

Commit

Permalink
feat: Users view historical reply floor
Browse files Browse the repository at this point in the history
  • Loading branch information
Linn3a committed Jul 31, 2023
1 parent 1aa7cb1 commit f6f6d21
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions apis/floor/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,41 @@ func DeleteFloor(c *fiber.Ctx) error {
return Serialize(c, &floor)
}

// ListReplyFloors
//
// @Summary List User's Reply Floors
// @Tags Floor
// @Produce application/json
// @Router /floors/reply [get]
// @Param object query ListModel false "query"
// @Success 200 {array} Floor
// @Failure 404 {object} MessageModel
func ListReplyFloors(c *fiber.Ctx) error {
//get user
user, err := GetUser(c)
if err != nil {
return err
}

var query ListModel
err = common.ValidateQuery(c, &query)
if err != nil {
return err
}

// get floors
var floors Floors
result := DB.Limit(query.Size).Order(query.OrderBy+" "+query.Sort).
Where("user_id = ? and ranking >= ?", user.ID, query.Offset).
Preload("Mention").
Find(&floors)

if result.Error != nil {
return result.Error
}
return Serialize(c, &floors)
}

// GetFloorHistory
//
// @Summary Get A Floor's History, admin only
Expand Down
1 change: 1 addition & 0 deletions apis/floor/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "github.com/gofiber/fiber/v2"
func RegisterRoutes(app fiber.Router) {
app.Get("/holes/:id/floors", ListFloorsInAHole)
app.Get("/floors", ListFloorsOld)
app.Get("/floors/reply", ListReplyFloors)
app.Get("/floors/:id", GetFloor)
app.Post("/holes/:id/floors", CreateFloor)
app.Post("/floors", CreateFloorOld)
Expand Down

0 comments on commit f6f6d21

Please sign in to comment.