🐛 Fix daily check issue

This commit is contained in:
2024-09-01 16:51:13 +08:00
parent 99f8e4c891
commit bee5b676fa
2 changed files with 8 additions and 9 deletions

View File

@ -7,11 +7,14 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"gorm.io/gorm"
"math/rand"
"time"
)
func CheckDailyCanSign(user models.Account) error {
probe := time.Now().Format("YYYY-MM-DD")
var record models.SignRecord
if err := database.C.Where("account_id = ? AND created_at::date = ?", user.ID).First(&record).Error; err != nil {
if err := database.C.Where("account_id = ? AND created_at::date = ?", user.ID, probe).First(&record).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}