-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
47 lines (38 loc) · 1.06 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package service
import (
"github.com/hadihammurabi/belajar-go-graphql/internal/app/entity"
"github.com/hadihammurabi/belajar-go-graphql/internal/app/repository"
"github.com/sarulabs/di"
uuid "github.com/satori/go.uuid"
)
// UserService struct
type UserService struct {
repo *repository.Repository
}
// NewUserService func
func NewUserService(ioc di.Container) entity.UserService {
repo := getRepository(ioc)
return &UserService{
repo,
}
}
// All func
func (u UserService) All() ([]*entity.User, error) {
return u.repo.User.All()
}
// Create func
func (u UserService) Create(user *entity.User) (*entity.User, error) {
return u.repo.User.Create(user)
}
// FindByEmail func
func (u UserService) FindByEmail(email string) (*entity.User, error) {
return u.repo.User.FindByEmail(email)
}
// FindByID func
func (u UserService) FindByID(id uuid.UUID) (*entity.User, error) {
return u.repo.User.FindByID(id)
}
// ChangePassword func
func (u UserService) ChangePassword(id uuid.UUID, password string) (*entity.User, error) {
return u.repo.User.ChangePassword(id, password)
}