Checkin time data column, checkin module

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2025-12-25 02:17:28 +08:00
parent ca08c997c8
commit 396ab10469
6 changed files with 22 additions and 9 deletions

View File

@@ -1,6 +1,10 @@
package data
import "github.com/google/uuid"
import (
"time"
"github.com/google/uuid"
)
type User struct {
Id uint `json:"id" gorm:"primarykey;autoincrement"`
@@ -11,7 +15,7 @@ type User struct {
Nickname string `json:"nickname"`
Subtitle string `json:"subtitle"`
Avatar string `json:"avatar"`
Checkin bool `json:"checkin" gorm:"not null;default:false"`
Checkin time.Time `json:"checkin"`
}
func (self *User) GetByEmail(email string) error {
@@ -28,11 +32,11 @@ func (self *User) GetByUserId(userId string) error {
return nil
}
func (self *User) SetCheckinState(userId uuid.UUID, state bool) error {
func (self *User) SetCheckinState(userId uuid.UUID, time time.Time) error {
if err := Database.Where("user_id = ?", userId).First(&self).Error; err != nil {
return err
}
self.Checkin = state
self.Checkin = time
Database.Save(&self)
return nil
}