🐛 Fix daily check issue

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

View File

@ -4,13 +4,9 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix query statement column issue"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Daily signs">
<change afterPath="$PROJECT_DIR$/pkg/internal/models/sign_record.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pkg/internal/server/api/sign_api.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pkg/internal/services/sign.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/services/sign.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/sign.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -157,7 +153,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":sparkles: Account groups" />
<MESSAGE value=":sparkles: Default user group" /> <MESSAGE value=":sparkles: Default user group" />
<MESSAGE value=":bug: Fix permissions in groups" /> <MESSAGE value=":bug: Fix permissions in groups" />
<MESSAGE value=":wastebasket: Clean up code" /> <MESSAGE value=":wastebasket: Clean up code" />
@ -182,7 +177,8 @@
<MESSAGE value=":bug: Fix preloading issue" /> <MESSAGE value=":bug: Fix preloading issue" />
<MESSAGE value=":bug: Fix bot related key api issue" /> <MESSAGE value=":bug: Fix bot related key api issue" />
<MESSAGE value=":bug: Fix query statement column issue" /> <MESSAGE value=":bug: Fix query statement column issue" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix query statement column issue" /> <MESSAGE value=":sparkles: Daily signs" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Daily signs" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -7,11 +7,14 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/models" "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"gorm.io/gorm" "gorm.io/gorm"
"math/rand" "math/rand"
"time"
) )
func CheckDailyCanSign(user models.Account) error { func CheckDailyCanSign(user models.Account) error {
probe := time.Now().Format("YYYY-MM-DD")
var record models.SignRecord 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) { if errors.Is(err, gorm.ErrRecordNotFound) {
return nil return nil
} }