-
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 FindOrganizationStructureByID message handling and implementation
- Loading branch information
1 parent
30ffa90
commit 15a8fe5
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
50 changes: 50 additions & 0 deletions
50
internal/messaging/organization/find_organization_structure_by_id_message.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,50 @@ | ||
package messaging | ||
|
||
import ( | ||
"app/go-sso/internal/repository" | ||
|
||
"github.com/google/uuid" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type IFindOrganizationStructureByIDMessageRequest struct { | ||
OrganizationStructureID uuid.UUID `json:"organization_structure_id"` | ||
} | ||
|
||
type IFindOrganizationStructureByIDMessageResponse struct { | ||
OrganizationStructureID string `json:"organization_structure_id"` | ||
Name string `json:"name"` | ||
} | ||
|
||
type IFindOrganizationStructureByIDMessage interface { | ||
Execute(request IFindOrganizationStructureByIDMessageRequest) (*IFindOrganizationStructureByIDMessageResponse, error) | ||
} | ||
|
||
type FindOrganizationStructureByIDMessage struct { | ||
Log *logrus.Logger | ||
Repository repository.IOrganizationStructureRepository | ||
} | ||
|
||
func NewFindOrganizationStructureByIDMessage(log *logrus.Logger, repository repository.IOrganizationStructureRepository) IFindOrganizationStructureByIDMessage { | ||
return &FindOrganizationStructureByIDMessage{ | ||
Log: log, | ||
Repository: repository, | ||
} | ||
} | ||
|
||
func (m *FindOrganizationStructureByIDMessage) Execute(request IFindOrganizationStructureByIDMessageRequest) (*IFindOrganizationStructureByIDMessageResponse, error) { | ||
organizationStructure, err := m.Repository.FindById(request.OrganizationStructureID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &IFindOrganizationStructureByIDMessageResponse{ | ||
OrganizationStructureID: organizationStructure.ID.String(), | ||
Name: organizationStructure.Name, | ||
}, nil | ||
} | ||
|
||
func FindOrganizationStructureByIDMessageFactory(log *logrus.Logger) IFindOrganizationStructureByIDMessage { | ||
repository := repository.OrganizationStructureRepositoryFactory(log) | ||
return NewFindOrganizationStructureByIDMessage(log, repository) | ||
} |
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