🐛 Fix date formatting issue on daily signing

This commit is contained in:
LittleSheep 2024-09-02 22:48:06 +08:00
parent a23c51f483
commit 3ce5ef6617
2 changed files with 6 additions and 6 deletions

8
.idea/workspace.xml generated
View File

@ -4,9 +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=":sparkles: Can get today's daily sign record"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix auto maintain range missing models">
<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/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.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" />
@ -153,7 +153,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":wastebasket: Clean up code" />
<MESSAGE value=":sparkles: Use capital to deal with links" /> <MESSAGE value=":sparkles: Use capital to deal with links" />
<MESSAGE value=":bug: Fix internal token audience update isn't fully applied" /> <MESSAGE value=":bug: Fix internal token audience update isn't fully applied" />
<MESSAGE value=":arrow_up: Implement list user relative grpc function" /> <MESSAGE value=":arrow_up: Implement list user relative grpc function" />
@ -178,7 +177,8 @@
<MESSAGE value=":sparkles: Daily signs" /> <MESSAGE value=":sparkles: Daily signs" />
<MESSAGE value=":bug: Fix daily check issue" /> <MESSAGE value=":bug: Fix daily check issue" />
<MESSAGE value=":sparkles: Can get today's daily sign record" /> <MESSAGE value=":sparkles: Can get today's daily sign record" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Can get today's daily sign record" /> <MESSAGE value=":bug: Fix auto maintain range missing models" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix auto maintain range missing models" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -11,7 +11,7 @@ import (
) )
func CheckDailyCanSign(user models.Account) error { func CheckDailyCanSign(user models.Account) error {
probe := time.Now().Format("YYYY-MM-DD") probe := time.Now().Format("2006-01-02")
var record models.SignRecord var record models.SignRecord
if err := database.C.Where("account_id = ? AND created_at::date = ?", user.ID, probe).First(&record).Error; err != nil { if err := database.C.Where("account_id = ? AND created_at::date = ?", user.ID, probe).First(&record).Error; err != nil {
@ -24,7 +24,7 @@ func CheckDailyCanSign(user models.Account) error {
} }
func GetTodayDailySign(user models.Account) (models.SignRecord, error) { func GetTodayDailySign(user models.Account) (models.SignRecord, error) {
probe := time.Now().Format("YYYY-MM-DD") probe := time.Now().Format("2006-01-02")
var record models.SignRecord var record models.SignRecord
if err := database.C.Where("account_id = ? AND created_at::date = ?", user.ID, probe).First(&record).Error; err != nil { if err := database.C.Where("account_id = ? AND created_at::date = ?", user.ID, probe).First(&record).Error; err != nil {