Add user service checkin func

- User service SetCheckinState

NOTE: Not Tested

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2025-12-20 02:04:45 +08:00
parent f130401ff8
commit 1505783c62

View File

@@ -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
}