forked from nixcn/nixcn-cms
Add user service checkin func
- User service SetCheckinState NOTE: Not Tested Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
11
data/user.go
11
data/user.go
@@ -5,7 +5,7 @@ import "github.com/google/uuid"
|
|||||||
type User struct {
|
type User struct {
|
||||||
Id uint `json:"id" gorm:"primarykey;autoincrement"`
|
Id uint `json:"id" gorm:"primarykey;autoincrement"`
|
||||||
UUID uuid.UUID `json:"uuid" gorm:"type:uuid;uniqueindex;not null"`
|
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"`
|
Email string `json:"email" gorm:"uniqueindex;not null"`
|
||||||
Nickname string `json:"nickname" gorm:"not null"`
|
Nickname string `json:"nickname" gorm:"not null"`
|
||||||
Type string `json:"type" gorm:"not null"`
|
Type string `json:"type" gorm:"not null"`
|
||||||
@@ -20,3 +20,12 @@ func (self *User) GetByEmail(email string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user