✨ List other user daily records
This commit is contained in:
parent
10e4a67835
commit
53c6b2a636
@ -59,8 +59,6 @@ func MapAPIs(app *fiber.App, baseURL string) {
|
||||
me.Delete("/tickets/:ticketId", killTicket)
|
||||
|
||||
me.Post("/confirm", doRegisterConfirm)
|
||||
me.Post("/password-reset", requestResetPassword)
|
||||
me.Patch("/password-reset", confirmResetPassword)
|
||||
|
||||
me.Get("/status", getMyselfStatus)
|
||||
me.Post("/status", setStatus)
|
||||
@ -80,14 +78,19 @@ func MapAPIs(app *fiber.App, baseURL string) {
|
||||
relations.Post("/:relatedId/decline", declineFriend)
|
||||
}
|
||||
|
||||
me.Post("/password-reset", requestResetPassword)
|
||||
me.Patch("/password-reset", confirmResetPassword)
|
||||
|
||||
me.Post("/deletion", requestDeleteAccount)
|
||||
me.Post("/deletion/confirm", confirmDeleteAccount)
|
||||
me.Patch("/deletion", confirmDeleteAccount)
|
||||
}
|
||||
|
||||
directory := api.Group("/users/:alias").Name("User Directory")
|
||||
{
|
||||
directory.Get("/", getOtherUserinfo)
|
||||
directory.Get("/status", getStatus)
|
||||
|
||||
directory.Get("/daily", listOtherUserDailySignRecord)
|
||||
}
|
||||
|
||||
api.Get("/users", getOtherUserinfoBatch)
|
||||
|
@ -40,6 +40,42 @@ func listDailySignRecord(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func listOtherUserDailySignRecord(c *fiber.Ctx) error {
|
||||
take := c.QueryInt("take", 0)
|
||||
offset := c.QueryInt("offset", 0)
|
||||
|
||||
alias := c.Params("alias")
|
||||
|
||||
var account models.Account
|
||||
if err := database.C.
|
||||
Where(&models.Account{Name: alias}).
|
||||
First(&account).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
var count int64
|
||||
if err := database.C.
|
||||
Model(&models.SignRecord{}).
|
||||
Where("account_id = ?", account.ID).
|
||||
Count(&count).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
var records []models.SignRecord
|
||||
if err := database.C.
|
||||
Where("account_id = ?", account.ID).
|
||||
Limit(take).Offset(offset).
|
||||
Order("created_at DESC").
|
||||
Find(&records).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": records,
|
||||
})
|
||||
}
|
||||
|
||||
func getTodayDailySign(c *fiber.Ctx) error {
|
||||
if err := exts.EnsureAuthenticated(c); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user