feat: add user model

This commit is contained in:
Noah Hsu
2022-06-16 16:06:10 +08:00
parent 1df5472855
commit 56c95eadea
3 changed files with 109 additions and 3 deletions

24
internal/model/user.go Normal file
View File

@ -0,0 +1,24 @@
package model
const (
GENERAL = iota
GUEST // only one exists
ADMIN
)
type User struct {
ID uint `json:"id" gorm:"primaryKey"` // unique key
Name string `json:"name" gorm:"unique"` // username
Password string `json:"password"` // password
BasePath string `json:"base_path"` // base path
AllowUpload bool `json:"allow_upload"` // allow upload
Role int `json:"role"` // user's role
}
func (u User) IsGuest() bool {
return u.Role == GUEST
}
func (u User) IsAdmin() bool {
return u.Role == ADMIN
}