@@ -14,44 +14,44 @@ const ResourceTypeFeature = "feature"
14
14
15
15
type FeatureService struct {
16
16
service.BaseService
17
- repo FeatureRepository
18
- eventSvc event.EventService
19
- objectSvc object.ObjectService
17
+ Repository FeatureRepository
18
+ EventSvc event.EventService
19
+ ObjectSvc object.ObjectService
20
20
}
21
21
22
- func NewService (env service.Env , repo FeatureRepository , eventSvc event.EventService , objectSvc object.ObjectService ) FeatureService {
22
+ func NewService (env service.Env , repository FeatureRepository , eventSvc event.EventService , objectSvc object.ObjectService ) FeatureService {
23
23
return FeatureService {
24
24
BaseService : service .NewBaseService (env ),
25
- repo : repo ,
26
- eventSvc : eventSvc ,
27
- objectSvc : objectSvc ,
25
+ Repository : repository ,
26
+ EventSvc : eventSvc ,
27
+ ObjectSvc : objectSvc ,
28
28
}
29
29
}
30
30
31
31
func (svc FeatureService ) Create (ctx context.Context , featureSpec FeatureSpec ) (* FeatureSpec , error ) {
32
32
var newFeature Model
33
33
err := svc .Env ().DB ().WithinTransaction (ctx , func (txCtx context.Context ) error {
34
- createdObject , err := svc .objectSvc .Create (txCtx , * featureSpec .ToObjectSpec ())
34
+ createdObject , err := svc .ObjectSvc .Create (txCtx , * featureSpec .ToObjectSpec ())
35
35
if err != nil {
36
36
return err
37
37
}
38
38
39
- _ , err = svc .repo .GetByFeatureId (txCtx , featureSpec .FeatureId )
39
+ _ , err = svc .Repository .GetByFeatureId (txCtx , featureSpec .FeatureId )
40
40
if err == nil {
41
41
return service .NewDuplicateRecordError ("Feature" , featureSpec .FeatureId , "A feature with the given featureId already exists" )
42
42
}
43
43
44
- newFeatureId , err := svc .repo .Create (txCtx , featureSpec .ToFeature (createdObject .ID ))
44
+ newFeatureId , err := svc .Repository .Create (txCtx , featureSpec .ToFeature (createdObject .ID ))
45
45
if err != nil {
46
46
return err
47
47
}
48
48
49
- newFeature , err = svc .repo .GetById (txCtx , newFeatureId )
49
+ newFeature , err = svc .Repository .GetById (txCtx , newFeatureId )
50
50
if err != nil {
51
51
return err
52
52
}
53
53
54
- err = svc .eventSvc .TrackResourceCreated (ctx , ResourceTypeFeature , newFeature .GetFeatureId (), newFeature .ToFeatureSpec ())
54
+ err = svc .EventSvc .TrackResourceCreated (ctx , ResourceTypeFeature , newFeature .GetFeatureId (), newFeature .ToFeatureSpec ())
55
55
if err != nil {
56
56
return err
57
57
}
@@ -67,7 +67,7 @@ func (svc FeatureService) Create(ctx context.Context, featureSpec FeatureSpec) (
67
67
}
68
68
69
69
func (svc FeatureService ) GetByFeatureId (ctx context.Context , featureId string ) (* FeatureSpec , error ) {
70
- feature , err := svc .repo .GetByFeatureId (ctx , featureId )
70
+ feature , err := svc .Repository .GetByFeatureId (ctx , featureId )
71
71
if err != nil {
72
72
return nil , err
73
73
}
@@ -77,7 +77,7 @@ func (svc FeatureService) GetByFeatureId(ctx context.Context, featureId string)
77
77
78
78
func (svc FeatureService ) List (ctx context.Context , listParams middleware.ListParams ) ([]FeatureSpec , error ) {
79
79
featureSpecs := make ([]FeatureSpec , 0 )
80
- features , err := svc .repo .List (ctx , listParams )
80
+ features , err := svc .Repository .List (ctx , listParams )
81
81
if err != nil {
82
82
return featureSpecs , nil
83
83
}
@@ -90,25 +90,25 @@ func (svc FeatureService) List(ctx context.Context, listParams middleware.ListPa
90
90
}
91
91
92
92
func (svc FeatureService ) UpdateByFeatureId (ctx context.Context , featureId string , featureSpec UpdateFeatureSpec ) (* FeatureSpec , error ) {
93
- currentFeature , err := svc .repo .GetByFeatureId (ctx , featureId )
93
+ currentFeature , err := svc .Repository .GetByFeatureId (ctx , featureId )
94
94
if err != nil {
95
95
return nil , err
96
96
}
97
97
98
98
currentFeature .SetName (featureSpec .Name )
99
99
currentFeature .SetDescription (featureSpec .Description )
100
- err = svc .repo .UpdateByFeatureId (ctx , featureId , currentFeature )
100
+ err = svc .Repository .UpdateByFeatureId (ctx , featureId , currentFeature )
101
101
if err != nil {
102
102
return nil , err
103
103
}
104
104
105
- updatedFeature , err := svc .repo .GetByFeatureId (ctx , featureId )
105
+ updatedFeature , err := svc .Repository .GetByFeatureId (ctx , featureId )
106
106
if err != nil {
107
107
return nil , err
108
108
}
109
109
110
110
updatedFeatureSpec := updatedFeature .ToFeatureSpec ()
111
- err = svc .eventSvc .TrackResourceUpdated (ctx , ResourceTypeFeature , updatedFeature .GetFeatureId (), updatedFeatureSpec )
111
+ err = svc .EventSvc .TrackResourceUpdated (ctx , ResourceTypeFeature , updatedFeature .GetFeatureId (), updatedFeatureSpec )
112
112
if err != nil {
113
113
return nil , err
114
114
}
@@ -118,17 +118,17 @@ func (svc FeatureService) UpdateByFeatureId(ctx context.Context, featureId strin
118
118
119
119
func (svc FeatureService ) DeleteByFeatureId (ctx context.Context , featureId string ) error {
120
120
err := svc .Env ().DB ().WithinTransaction (ctx , func (txCtx context.Context ) error {
121
- err := svc .repo .DeleteByFeatureId (txCtx , featureId )
121
+ err := svc .Repository .DeleteByFeatureId (txCtx , featureId )
122
122
if err != nil {
123
123
return err
124
124
}
125
125
126
- err = svc .objectSvc .DeleteByObjectTypeAndId (txCtx , objecttype .ObjectTypeFeature , featureId )
126
+ err = svc .ObjectSvc .DeleteByObjectTypeAndId (txCtx , objecttype .ObjectTypeFeature , featureId )
127
127
if err != nil {
128
128
return err
129
129
}
130
130
131
- err = svc .eventSvc .TrackResourceDeleted (ctx , ResourceTypeFeature , featureId , nil )
131
+ err = svc .EventSvc .TrackResourceDeleted (ctx , ResourceTypeFeature , featureId , nil )
132
132
if err != nil {
133
133
return err
134
134
}
0 commit comments