Skip to content

Commit

Permalink
chore: godoc for ListDTO
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrMatsko committed Feb 4, 2025
1 parent a1bdca0 commit 4d3017d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/dto/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (*ContactNoisiness) Render(w http.ResponseWriter, r *http.Request) error {
}

// ContactNoisinessList represents list of ContactNoisiness.
type ContactNoisinessList ListDto[*ContactNoisiness]
type ContactNoisinessList ListDTO[*ContactNoisiness]

func (*ContactNoisinessList) Render(w http.ResponseWriter, r *http.Request) error {
return nil
Expand Down
15 changes: 10 additions & 5 deletions api/dto/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import (
"github.com/go-chi/render"
)

type ListDto[T render.Renderer] struct {
List []T `json:"list"`
Page int64 `json:"page" example:"0" format:"int64"`
Size int64 `json:"size" example:"100" format:"int64"`
// ListDTO is a generic struct to create list types dto.
type ListDTO[T render.Renderer] struct {
// List of entities.
List []T `json:"list"`
// Page number.
Page int64 `json:"page" example:"0" format:"int64"`
// Size is the amount of entities per Page.
Size int64 `json:"size" example:"100" format:"int64"`
// Total amount of entities in the database.
Total int64 `json:"total" example:"10" format:"int64"`
}

func (*ListDto[T]) Render(w http.ResponseWriter, r *http.Request) error {
func (*ListDTO[T]) Render(w http.ResponseWriter, r *http.Request) error {
return nil
}
2 changes: 1 addition & 1 deletion api/dto/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func (*TriggerNoisiness) Render(http.ResponseWriter, *http.Request) error {
}

// TriggerNoisinessList represents list of TriggerNoisiness.
type TriggerNoisinessList ListDto[*TriggerNoisiness]
type TriggerNoisinessList ListDTO[*TriggerNoisiness]

func (*TriggerNoisinessList) Render(http.ResponseWriter, *http.Request) error {
return nil
Expand Down

0 comments on commit 4d3017d

Please sign in to comment.