-
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.
Refactor organization location handling: add DTOs for responses and i…
…mplement FindByOrganizationID method
- Loading branch information
1 parent
24a26f1
commit 1a7697d
Showing
9 changed files
with
95 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package dto | ||
|
||
import ( | ||
"app/go-sso/internal/entity" | ||
"app/go-sso/internal/http/response" | ||
) | ||
|
||
func ConvertToOrganizationLocationResponse(orgLocations *[]entity.OrganizationLocation) *[]response.OrganizationLocationResponse { | ||
var responseLocations []response.OrganizationLocationResponse | ||
for _, orgLocation := range *orgLocations { | ||
responseLocations = append(responseLocations, response.OrganizationLocationResponse{ | ||
ID: orgLocation.ID, | ||
OrganizationID: orgLocation.OrganizationID, | ||
Name: orgLocation.Name, | ||
CreatedAt: orgLocation.CreatedAt, | ||
UpdatedAt: orgLocation.UpdatedAt, | ||
}) | ||
} | ||
return &responseLocations | ||
} | ||
|
||
func ConvertToSingleOrganizationLocationResponse(orgLocation *entity.OrganizationLocation) *response.OrganizationLocationResponse { | ||
return &response.OrganizationLocationResponse{ | ||
ID: orgLocation.ID, | ||
OrganizationID: orgLocation.OrganizationID, | ||
Name: orgLocation.Name, | ||
CreatedAt: orgLocation.CreatedAt, | ||
UpdatedAt: orgLocation.UpdatedAt, | ||
} | ||
} |
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,9 @@ | ||
package response | ||
|
||
import "github.com/google/uuid" | ||
|
||
type JobLevelResponse struct { | ||
ID uuid.UUID `json:"id"` | ||
Name string `json:"name"` | ||
Level string `json:"level"` | ||
} |
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,17 @@ | ||
package response | ||
|
||
import "github.com/google/uuid" | ||
|
||
type OrganizationStructureResponse struct { | ||
ID uuid.UUID `json:"id"` | ||
OrganizationID uuid.UUID `json:"organization_id"` | ||
Name string `json:"name"` | ||
JobLevelID uuid.UUID `json:"job_level_id"` | ||
ParentID *uuid.UUID `json:"parent_id,omitempty"` | ||
Level int `json:"level"` | ||
Path string `json:"path"` | ||
Organization OrganizationResponse `json:"organization"` | ||
JobLevel JobLevelResponse `json:"job_level"` | ||
Parent *OrganizationStructureResponse `json:"parent,omitempty"` | ||
Children []OrganizationStructureResponse `json:"children,omitempty"` | ||
} |
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,15 @@ | ||
package response | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
type OrganizationLocationResponse struct { | ||
ID uuid.UUID `json:"id"` | ||
OrganizationID uuid.UUID `json:"organization_id"` | ||
Name string `json:"name"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package response | ||
|
||
import "github.com/google/uuid" | ||
|
||
type OrganizationTypeResponse struct { | ||
ID uuid.UUID `json:"id"` | ||
Name string `json:"name"` | ||
} |
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