Documentation ¶
Index ¶
- type AuthRequest
- type AuthResponse
- type Repository
- type Request
- type Response
- type Service
- func (s Service) CreateUser(user *User) (*Response, error)
- func (s Service) DeleteUser(id int) error
- func (s Service) GetUserByEmail(email string) (user User, err error)
- func (s Service) GetUserById(id int) (user User, err error)
- func (s Service) UpdateUser(user *User, id int) (err error)
- func (s Service) UpdateUserPassword(user *User, id int) (err error)
- type User
- type UserRepository
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRequest ¶
AuthRequest handles data for /auth/login
type AuthResponse ¶
type AuthResponse struct {
Token string `json:"token"`
}
AuthResponse is the response DTO for the auth resource
type Repository ¶
Repository concrete type
func (Repository) Create ¶
func (r Repository) Create(user *User) error
func (Repository) Delete ¶
func (r Repository) Delete(id int) (err error)
func (Repository) FindOneByEmail ¶
func (r Repository) FindOneByEmail(email string) (user User, err error)
type Service ¶
type Service struct {
Repository UserRepository
}
func (Service) CreateUser ¶
CreateUser on app
func (Service) DeleteUser ¶
func (Service) GetUserByEmail ¶
type User ¶
type User struct { gorm.Model Email string `gorm:"unique_index;not null" json:"email"` Name string `json:"name"` Password string `gorm:"not null" json:"password,omitempty"` }
User is the model for the DB
type UserRepository ¶
type UserRepository interface { FindAll() (users *gorm.DB, err error) FindOneByEmail(email string) (user User, err error) FindById(id int) (user User, err error) Create(user *User) error Delete(id int) error }
UserRepository Contract
func NewUserRepository ¶
func NewUserRepository() UserRepository
NewUserRepository repository postgres implementation
type UserService ¶
type UserService interface { CreateUser(user *User) (*Response, error) UpdateUser(user *User, id int) error DeleteUser(id int) error GetUserByEmail(email string) (user User, err error) GetUserById(id int) (user User, err error) }
func NewUserService ¶
func NewUserService() (service UserService)
Click to show internal directories.
Click to hide internal directories.