Documentation
¶
Index ¶
- type Bit
- type MariadbRepo
- func (r *MariadbRepo) Create(user *User) (string, error)
- func (r *MariadbRepo) Update(user *User) error
- func (r *MariadbRepo) UserByEmail(email string) (*User, error)
- func (r *MariadbRepo) UserById(id string) (*User, error)
- func (r *MariadbRepo) UserByUsername(username string) (*User, error)
- func (r *MariadbRepo) UserExists(email string, username string) (string, error)
- type PrivacyLevel
- type Reader
- type Repository
- type Service
- type User
- type UserService
- func (u *UserService) Create(user *User) (string, error)
- func (u *UserService) Login(username string, email string, password string) (*User, error)
- func (u *UserService) Update(user *User) error
- func (u *UserService) UserByEmail(email string) (*User, error)
- func (u *UserService) UserById(id string) (*User, error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MariadbRepo ¶
type MariadbRepo struct {
// contains filtered or unexported fields
}
MariadbRepo holds a connection
func NewRepository ¶
func NewRepository(context *gorm.DB) *MariadbRepo
NewRepository instansiates a repository obect
func (*MariadbRepo) Create ¶
func (r *MariadbRepo) Create(user *User) (string, error)
Create creates a user
func (*MariadbRepo) UserByEmail ¶
func (r *MariadbRepo) UserByEmail(email string) (*User, error)
UserByEmail get an user by its email
func (*MariadbRepo) UserById ¶
func (r *MariadbRepo) UserById(id string) (*User, error)
UserById fetches a user by the userId
func (*MariadbRepo) UserByUsername ¶
func (r *MariadbRepo) UserByUsername(username string) (*User, error)
UserByUsername gets a user by its username
func (*MariadbRepo) UserExists ¶
func (r *MariadbRepo) UserExists(email string, username string) (string, error)
UserExists returns an userId if the user exists
type PrivacyLevel ¶
type PrivacyLevel int
PrivacyLevel is a type that describes a users level of privacy
const ( // ProtectedLevel describes a level where a user can be seen by anyone who has a flightlog login ProtectedLevel PrivacyLevel = 0 // PrivateLevel describes a level where a user needs to grant access to those who wants access PrivateLevel PrivacyLevel = 1 // PublicLevel describes a user that anyone can watch with or without login PublicLevel PrivacyLevel = 2 )
type Reader ¶
type Reader interface { UserByEmail(email string) (*User, error) UserById(id string) (*User, error) }
Reader describes read related actions for a user
type Repository ¶
type Service ¶
type Service interface { Reader Writer Login(username string, email string, password string) (*User, error) }
Service define user service layer
type User ¶
type User struct { ID string `gorm:"primaryKey;column:id;size:64"` Givenname string `gorm:"column:givenname;size:64"` Familyname string `gorm:"column:familyname;size:64"` Email string `gorm:"column:email;size:320"` Active Bit `gorm:"column:active"` Username string `gorm:"column:username;size:32"` Privacy PrivacyLevel `gorm:"column:privacylevel"` UpdatedAt *time.Time `gorm:"column:updatedat;type:time"` CreatedAt *time.Time `gorm:"column:createdat;type:time"` DeletedAt *time.Time `gorm:"column:deletedat;type:time"` FlyingDevices []device.FlyingDevice `gorm:"foreignKey:userId"` }
User models a db user
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(repo Repository) *UserService
func (*UserService) Update ¶
func (u *UserService) Update(user *User) error
func (*UserService) UserByEmail ¶
func (u *UserService) UserByEmail(email string) (*User, error)
Click to show internal directories.
Click to hide internal directories.