generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
864a530
commit 6b6cb29
Showing
11 changed files
with
400 additions
and
1,253 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package destinations | ||
|
||
import ( | ||
"github.com/bitcoin-sv/spv-wallet/engine" | ||
"github.com/bitcoin-sv/spv-wallet/engine/datastore" | ||
"github.com/bitcoin-sv/spv-wallet/models" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// SearchRequestDestinationParameters is a struct for handling request parameters for search requests | ||
type SearchRequestDestinationParameters struct { | ||
// Custom conditions used for filtering the search results | ||
Conditions models.DestinationFilters `json:"conditions"` | ||
// Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource | ||
Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` | ||
// Pagination and sorting options to streamline data exploration and analysis | ||
QueryParams datastore.QueryParams `json:"params" swaggertype:"object,string" example:"page:1,page_size:10,order_by_field:created_at,order_by_direction:desc"` | ||
} | ||
|
||
// CountRequestDestinationParameters is a struct for handling request parameters for count requests | ||
type CountRequestDestinationParameters struct { | ||
// Custom conditions used for filtering the search results | ||
Conditions map[string]interface{} `json:"conditions" swaggertype:"object,string" example:"testColumn:testValue"` | ||
// Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource | ||
Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` | ||
} | ||
|
||
// GetSearchDestinationQueryParameters get all filtering parameters related to the db query | ||
func GetSearchDestinationQueryParameters(c *gin.Context) (*datastore.QueryParams, *engine.Metadata, *models.DestinationFilters, error) { | ||
var requestParameters SearchRequestDestinationParameters | ||
if err := c.Bind(&requestParameters); err != nil { | ||
return nil, nil, nil, err | ||
} | ||
|
||
conditions := *models.NewDestinationFilters() | ||
|
||
if requestParameters.Conditions == (models.DestinationFilters{}) { | ||
requestParameters.Conditions = conditions | ||
} | ||
|
||
return &requestParameters.QueryParams, &requestParameters.Metadata, &requestParameters.Conditions, nil | ||
} |
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.