Add a bunch of stuff, mostly user and db related
This commit is contained in:
parent
48b34bca9d
commit
143c3a8b81
62 changed files with 5093 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID int
|
||||
Name string
|
||||
|
@ -7,3 +11,23 @@ type User struct {
|
|||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
func (u *User) IsValid() error {
|
||||
if u.Name == "" {
|
||||
return fmt.Errorf("name must not be empty")
|
||||
}
|
||||
|
||||
if u.Mail == "" {
|
||||
return fmt.Errorf("mail must not be empty")
|
||||
}
|
||||
|
||||
if u.Username == "" {
|
||||
return fmt.Errorf("username must not be empty")
|
||||
}
|
||||
|
||||
if u.Password == "" {
|
||||
return fmt.Errorf("password must not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
9
model/utils.go
Normal file
9
model/utils.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func NewID() string {
|
||||
return uuid.New().String()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue