-
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: streamline and use sqlc for SOS condition and SOS post cond…
…ition
- Loading branch information
Showing
17 changed files
with
433 additions
and
257 deletions.
There are no files selected for viewing
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
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
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,25 @@ | ||
package soscondition | ||
|
||
type ViewForSOSPost struct { | ||
ID int `field:"id"` | ||
Name string `field:"name"` | ||
CreatedAt string `field:"created_at"` | ||
UpdatedAt string `field:"update_at"` | ||
DeletedAt string `field:"deleted_at"` | ||
} | ||
|
||
type ViewListForSOSPost []*ViewForSOSPost | ||
|
||
type AvailableName string | ||
|
||
const ( | ||
CCTVPermission AvailableName = "CCTV, 펫캠 촬영 동의" | ||
IDVerification AvailableName = "신분증 인증" | ||
PhonePermission AvailableName = "사전 통화 가능 여부" | ||
) | ||
|
||
func (c AvailableName) String() string { | ||
return string(c) | ||
} | ||
|
||
var AvailableNames = []AvailableName{CCTVPermission, IDVerification, PhonePermission} |
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,73 @@ | ||
package soscondition | ||
|
||
import ( | ||
utils "github.com/pet-sitter/pets-next-door-api/internal/common" | ||
databasegen "github.com/pet-sitter/pets-next-door-api/internal/infra/database/gen" | ||
) | ||
|
||
type DetailView struct { | ||
ID int64 `json:"id"` | ||
Name string `json:"name"` | ||
} | ||
|
||
func ToDetailView(row databasegen.SosCondition) *DetailView { | ||
return &DetailView{ | ||
ID: int64(row.ID), | ||
Name: utils.NullStrToStr(row.Name), | ||
} | ||
} | ||
|
||
func ToDetailViewFromRows(row databasegen.SosCondition) *DetailView { | ||
return &DetailView{ | ||
ID: int64(row.ID), | ||
Name: utils.NullStrToStr(row.Name), | ||
} | ||
} | ||
|
||
func ToDetailViewFromSOSPostCondition(row databasegen.FindSOSPostConditionsRow) *DetailView { | ||
return &DetailView{ | ||
ID: int64(row.ID), | ||
Name: utils.NullStrToStr(row.Name), | ||
} | ||
} | ||
|
||
func ToDetailViewFromViewForSOSPost(view ViewForSOSPost) *DetailView { | ||
return &DetailView{ | ||
ID: int64(view.ID), | ||
Name: view.Name, | ||
} | ||
} | ||
|
||
type ListView []*DetailView | ||
|
||
func ToListView(row []databasegen.SosCondition) ListView { | ||
conditionViews := make(ListView, len(row)) | ||
for i, condition := range row { | ||
conditionViews[i] = ToDetailView(condition) | ||
} | ||
return conditionViews | ||
} | ||
|
||
func ToListViewFromRows(rows []databasegen.SosCondition) ListView { | ||
conditionViews := make(ListView, len(rows)) | ||
for i, row := range rows { | ||
conditionViews[i] = ToDetailViewFromRows(row) | ||
} | ||
return conditionViews | ||
} | ||
|
||
func ToListViewFromSOSPostConditions(rows []databasegen.FindSOSPostConditionsRow) ListView { | ||
conditionViews := make(ListView, len(rows)) | ||
for i, row := range rows { | ||
conditionViews[i] = ToDetailViewFromSOSPostCondition(row) | ||
} | ||
return conditionViews | ||
} | ||
|
||
func ToListViewFromViewForSOSPost(views ViewListForSOSPost) ListView { | ||
conditionViews := make(ListView, len(views)) | ||
for i, view := range views { | ||
conditionViews[i] = ToDetailViewFromViewForSOSPost(*view) | ||
} | ||
return conditionViews | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.