Add user db search
- Search user by email Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
21
data/user.go
Normal file
21
data/user.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package data
|
||||
|
||||
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"`
|
||||
Email string `json:"email" gorm:"uniqueindex;not null"`
|
||||
Nickname string `json:"nickname" gorm:"not null"`
|
||||
Type string `json:"type" gorm:"not null"`
|
||||
Subtitle string `json:"subtitle" gorm:"not null"`
|
||||
Avatar string `json:"avatar" gorm:"not null"`
|
||||
}
|
||||
|
||||
func (self *User) GetByEmail(email string) error {
|
||||
if err := Database.Where("email = ?", email).First(&self).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user