🚚 Rename daily-sign to check-in

This commit is contained in:
2024-11-27 21:57:10 +08:00
parent 1515e29d5b
commit c16019341f
6 changed files with 32 additions and 27 deletions

View File

@ -9,7 +9,7 @@ import (
"strconv"
)
func listDailySignRecord(c *fiber.Ctx) error {
func listCheckInRecord(c *fiber.Ctx) error {
take := c.QueryInt("take", 0)
offset := c.QueryInt("offset", 0)
@ -20,13 +20,13 @@ func listDailySignRecord(c *fiber.Ctx) error {
var count int64
if err := database.C.
Model(&models.SignRecord{}).
Model(&models.CheckInRecord{}).
Where("account_id = ?", user.ID).
Count(&count).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
var records []models.SignRecord
var records []models.CheckInRecord
if err := database.C.
Where("account_id = ?", user.ID).
Limit(take).Offset(offset).
@ -41,7 +41,7 @@ func listDailySignRecord(c *fiber.Ctx) error {
})
}
func listOtherUserDailySignRecord(c *fiber.Ctx) error {
func listOtherUserCheckInRecord(c *fiber.Ctx) error {
take := c.QueryInt("take", 0)
offset := c.QueryInt("offset", 0)
@ -56,13 +56,13 @@ func listOtherUserDailySignRecord(c *fiber.Ctx) error {
var count int64
if err := database.C.
Model(&models.SignRecord{}).
Model(&models.CheckInRecord{}).
Where("account_id = ?", account.ID).
Count(&count).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
var records []models.SignRecord
var records []models.CheckInRecord
if err := database.C.
Where("account_id = ?", account.ID).
Limit(take).Offset(offset).
@ -77,26 +77,26 @@ func listOtherUserDailySignRecord(c *fiber.Ctx) error {
})
}
func getTodayDailySign(c *fiber.Ctx) error {
func getTodayCheckIn(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
if record, err := services.GetTodayDailySign(user); err != nil {
if record, err := services.GetTodayCheckIn(user); err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
} else {
return c.JSON(record)
}
}
func doDailySign(c *fiber.Ctx) error {
func doCheckIn(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
if record, err := services.DailySign(user); err != nil {
if record, err := services.CheckIn(user); err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
} else {
services.AddEvent(user.ID, "dailySign", strconv.Itoa(int(record.ID)), c.IP(), c.Get(fiber.HeaderUserAgent))

View File

@ -10,11 +10,11 @@ func MapAPIs(app *fiber.App, baseURL string) {
api := app.Group(baseURL).Name("API")
{
daily := api.Group("/daily").Name("Daily Sign API")
checkIn := api.Group("/check-in").Name("Daily Check In API")
{
daily.Get("/", listDailySignRecord)
daily.Get("/today", getTodayDailySign)
daily.Post("/", doDailySign)
checkIn.Get("/", listCheckInRecord)
checkIn.Get("/today", getTodayCheckIn)
checkIn.Post("/", doCheckIn)
}
notify := api.Group("/notifications").Name("Notifications API")
@ -97,7 +97,7 @@ func MapAPIs(app *fiber.App, baseURL string) {
directory.Get("/", getOtherUserinfo)
directory.Get("/status", getStatus)
directory.Get("/daily", listOtherUserDailySignRecord)
directory.Get("/check-in", listOtherUserCheckInRecord)
}
api.Get("/users", getOtherUserinfoBatch)