Initial commit

This commit is contained in:
KamilM1205 2025-09-16 13:26:27 +04:00
commit c0cb826917
63 changed files with 2069 additions and 0 deletions

View file

@ -0,0 +1,42 @@
package entities
import (
"errors"
"github.com/google/uuid"
)
const UserTable = "users"
type User struct {
Id uuid.UUID `db:"id"`
UserName string `db:"username"`
Password string `db:"password"`
}
func CreateUser(userName string, password string) (user User, err error) {
user = User{
Id: uuid.New(),
UserName: userName,
Password: password,
}
err = user.Validate()
return
}
func (u *User) Validate() error {
if err := uuid.Validate(u.Id.String()); err != nil {
return errors.New("Invalid user.id")
}
if u.UserName == "" {
return errors.New("Empty user.name")
}
if u.Password == "" {
return errors.New("Empty user.password")
}
return nil
}