-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FindOrganizationLocationByOrganizationId method and use case for …
…retrieving locations by organization ID
- Loading branch information
1 parent
1a7697d
commit 52913f9
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
internal/usecase/organization_location/find_by_organization_id_usecase.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package usecase | ||
|
||
import ( | ||
"app/go-sso/internal/http/dto" | ||
"app/go-sso/internal/http/response" | ||
"app/go-sso/internal/repository" | ||
|
||
"github.com/google/uuid" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type IFindByOrganizationIdUseCaseRequest struct { | ||
OrganizationID uuid.UUID `json:"organization_id"` | ||
} | ||
|
||
type IFindByOrganizationIdUseCaseResponse struct { | ||
OrganizationLocations *[]response.OrganizationLocationResponse `json:"organization_locations"` | ||
} | ||
|
||
type IFindByOrganizationIdUseCase interface { | ||
Execute(request *IFindByOrganizationIdUseCaseRequest) (*IFindByOrganizationIdUseCaseResponse, error) | ||
} | ||
|
||
type FindByOrganizationIdUseCase struct { | ||
Log *logrus.Logger | ||
Repository repository.IOrganizationLocationRepository | ||
} | ||
|
||
func NewFindByOrganizationIdUseCase( | ||
log *logrus.Logger, | ||
repository repository.IOrganizationLocationRepository, | ||
) IFindByOrganizationIdUseCase { | ||
return &FindByOrganizationIdUseCase{ | ||
Log: log, | ||
Repository: repository, | ||
} | ||
} | ||
|
||
func (uc *FindByOrganizationIdUseCase) Execute(req *IFindByOrganizationIdUseCaseRequest) (*IFindByOrganizationIdUseCaseResponse, error) { | ||
organizationLocations, err := uc.Repository.FindByOrganizationID(req.OrganizationID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &IFindByOrganizationIdUseCaseResponse{ | ||
OrganizationLocations: dto.ConvertToOrganizationLocationResponse(organizationLocations), | ||
}, nil | ||
} | ||
|
||
func FindByOrganizationIdUseCaseFactory(log *logrus.Logger) IFindByOrganizationIdUseCase { | ||
repository := repository.OrganizationLocationRepositoryFactory(log) | ||
return NewFindByOrganizationIdUseCase(log, repository) | ||
} |