initial commit 2
This commit is contained in:
49
server/router/eligibilityroute/controller.go
Normal file
49
server/router/eligibilityroute/controller.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package eligibilityroute
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
||||
"bitbucket.org/nemt/nemt-portal-api/application/third/eligibility/bcbsi"
|
||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||
"github.com/labstack/echo"
|
||||
)
|
||||
|
||||
var (
|
||||
instance *controller
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
type controller struct {
|
||||
cfg *config.Config
|
||||
svc *applicationservice.Service
|
||||
bcbsi *bcbsi.Service
|
||||
}
|
||||
|
||||
func controllerInstance(cfg *config.Config, svc *applicationservice.Service) *controller {
|
||||
once.Do(func() {
|
||||
instance = &controller{
|
||||
cfg: cfg,
|
||||
svc: svc,
|
||||
bcbsi: bcbsi.New(cfg),
|
||||
}
|
||||
})
|
||||
return instance
|
||||
}
|
||||
|
||||
func (c *controller) handleEligibility(ctx echo.Context) error {
|
||||
var eligibility viewmodel.Eligibility
|
||||
|
||||
if err := ctx.Bind(&eligibility); err != nil {
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
}
|
||||
|
||||
ret, err := c.bcbsi.BXE.CheckEligibility(eligibility)
|
||||
if err != nil {
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
}
|
||||
|
||||
return routeutils.ResponseAPIOK(ctx, ret)
|
||||
}
|
||||
Reference in New Issue
Block a user