forked from nixcn/nixcn-cms
Checkin time data column, checkin module
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
12
data/user.go
12
data/user.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user