diff --git a/data/user.go b/data/user.go index cff1d2a..7efe964 100644 --- a/data/user.go +++ b/data/user.go @@ -5,7 +5,7 @@ import "github.com/google/uuid" type User struct { Id uint `json:"id" gorm:"primarykey;autoincrement"` UUID uuid.UUID `json:"uuid" gorm:"type:uuid;uniqueindex;not null"` - UserId string `json:"user_id" gorm:"size:8;uniqueindex;not null"` + UserId uuid.UUID `json:"user_id" gorm:"size:8;uniqueindex;not null"` Email string `json:"email" gorm:"uniqueindex;not null"` Nickname string `json:"nickname" gorm:"not null"` Type string `json:"type" gorm:"not null"` @@ -20,3 +20,12 @@ func (self *User) GetByEmail(email string) error { } return nil } + +func (self *User) SetCheckinState(email string, state bool) error { + if err := Database.Where("email = ?", email).First(&self).Error; err != nil { + return err + } + self.Checkin = state + Database.Save(&self) + return nil +}