-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempfetcher.go
102 lines (90 loc) · 2.53 KB
/
empfetcher.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package empfetcherapi
import (
"context"
"log"
empfetcher "github.com/flexera/empfetcher/gen/empfetcher"
mssql "github.com/flexera/empfetcher/services"
guuid "github.com/google/uuid"
)
// empfetcher service example implementation.
// The example methods log the requests and return zero values.
type empfetchersrvc struct {
mssqlc mssql.Client
}
// NewEmpfetcher returns the empfetcher service implementation.
func NewEmpfetcher(mssqlc mssql.Client) empfetcher.Service {
return &empfetchersrvc{mssqlc}
}
// Adds an Employee Details
func (s *empfetchersrvc) Add(ctx context.Context, p *empfetcher.EmployeePayload) (err error) {
log.Print("empfetcher.add")
p.ID = guuid.New().String()
err = s.mssqlc.Add(ctx, p)
if err != nil {
return err
}
return nil
}
// Updates an Employee Details
func (s *empfetchersrvc) Update(ctx context.Context, p *empfetcher.EmployeePayload) (err error) {
log.Print("empfetcher.update")
err = s.mssqlc.Update(ctx, *p)
if err != nil {
return err
}
return nil
}
// List All Employee Details
func (s *empfetchersrvc) List(ctx context.Context) (res []*empfetcher.EmployeePayload, err error) {
log.Print("empfetcher.list")
res, err = s.mssqlc.List(ctx)
if err != nil {
return nil, err
}
return res, nil
}
// Show Employee Details based on ID
func (s *empfetchersrvc) Show(ctx context.Context, p *empfetcher.ShowPayload) (res *empfetcher.EmployeePayload, err error) {
log.Print("empfetcher.show")
res, err = s.mssqlc.Show(ctx, *p)
if err != nil {
return nil, err
}
return res, nil
}
// Delete Employee Details
func (s *empfetchersrvc) Delete(ctx context.Context, p *empfetcher.DeletePayload) (err error) {
log.Print("empfetcher.delete")
err = s.mssqlc.Delete(ctx, *p)
if err != nil {
return err
}
return nil
}
// Restores an Employee Details
func (s *empfetchersrvc) Restore(ctx context.Context, p *empfetcher.RestorePayload) (err error) {
log.Print("empfetcher.restore")
err = s.mssqlc.Restore(ctx, *p)
if err != nil {
return err
}
return nil
}
// View All deactivated Employee Details
func (s *empfetchersrvc) Viewdeleted(ctx context.Context) (res []*empfetcher.EmployeePayload, err error) {
log.Print("empfetcher.viewdeleted")
res, err = s.mssqlc.Viewdeleted(ctx)
if err != nil {
return nil, err
}
return res, nil
}
// Search employees by name
func (s *empfetchersrvc) Search(ctx context.Context, p *empfetcher.SearchPayload) (res []*empfetcher.EmployeePayload, err error) {
log.Print("empfetcher.search")
res, err = s.mssqlc.Search(ctx, *p)
if err != nil {
return nil, err
}
return res, nil
}