Skip to content

Commit 5b4738c

Browse files
committed
refactor(golang): simplify generated code by re-using dto by multiple endpoints
1 parent ca96c1f commit 5b4738c

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

examples/go/chi/mysql/routes.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ type CreateCategoryDto struct {
2929
UserId *int `json:"user_id" db:"user_id"`
3030
}
3131

32-
type CategoryInfoDto struct {
33-
Id *int `json:"id" db:"id"`
34-
Name *string `json:"name" db:"name"`
35-
NameRu *string `json:"name_ru" db:"name_ru"`
36-
Slug *string `json:"slug" db:"slug"`
37-
Hidden *bool `json:"hidden" db:"hidden"`
38-
}
39-
4032
func registerRoutes(r chi.Router, db *sqlx.DB) {
4133

4234
r.Get("/v1/categories/count", func(w http.ResponseWriter, r *http.Request) {
@@ -126,7 +118,7 @@ func registerRoutes(r chi.Router, db *sqlx.DB) {
126118
return
127119
}
128120

129-
var result CategoryInfoDto
121+
var result CategoryDto
130122
args := map[string]interface{}{
131123
"categoryId": chi.URLParam(r, "categoryId"),
132124
}

examples/js/express/mysql/endpoints.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
FROM categories
8989
WHERE id = :p.categoryId
9090
dto:
91-
name: CategoryInfoDto
9291
fields:
9392
id:
9493
type: integer

0 commit comments

Comments
 (0)