Add a bunch of stuff, mostly user and db related

This commit is contained in:
Miguel de la Cruz 2021-09-11 21:38:38 +02:00
parent 48b34bca9d
commit 143c3a8b81
62 changed files with 5093 additions and 0 deletions

View file

@ -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
View file

@ -0,0 +1,9 @@
package model
import (
"github.com/google/uuid"
)
func NewID() string {
return uuid.New().String()
}