Skip to content

Commit

Permalink
feat(SPV-1377): feat parse query (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolt-4chain authored Jan 16, 2025
1 parent 4c8405d commit 5fe1b5a
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions internal/query/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func ParseSearchParams[T any](c *gin.Context) (*filter.SearchParams[T], error) {
config := mapstructure.DecoderConfig{
DecodeHook: mapstructure.StringToTimeHookFunc(time.RFC3339),
WeaklyTypedInput: true,
Squash: true,
Result: &params,
TagName: "json", // Small hax to reuse json tags which we have already defined
}
Expand Down
3 changes: 1 addition & 2 deletions models/filter/access_key_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package filter
// AccessKeyFilter is a struct for handling request parameters for destination search requests
type AccessKeyFilter struct {
// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`

// RevokedRange specifies the time range when a record was revoked.
RevokedRange *TimeRange `json:"revokedRange,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions models/filter/contact_admin_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package filter

// AdminContactFilter extends ContactFilter for admin-specific use, including xpubId filtering
type AdminContactFilter struct {
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ContactFilter `json:",inline,squash"`
ContactFilter `json:",inline"`
XPubID *string `json:"xpubId,omitempty" example:"623bc25ce1c0fc510dea72b5ee27b2e70384c099f1f3dce9e73dd987198c3486"`
}

Expand Down
3 changes: 1 addition & 2 deletions models/filter/contact_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package filter
// ContactFilter is a struct for handling request parameters for contact search requests
type ContactFilter struct {
// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`
ID *string `json:"id" example:"ffdbe74e-0700-4710-aac5-611a1f877c7f"`
FullName *string `json:"fullName" example:"Alice"`
Paymail *string `json:"paymail" example:"alice@example.com"`
Expand Down
3 changes: 1 addition & 2 deletions models/filter/destination_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package filter
// DestinationFilter is a struct for handling request parameters for destination search requests
type DestinationFilter struct {
// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`
LockingScript *string `json:"lockingScript,omitempty" example:"76a9147b05764a97f3b4b981471492aa703b188e45979b88ac"`
Address *string `json:"address,omitempty" example:"1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65"`
DraftID *string `json:"draftId,omitempty" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"`
Expand Down
6 changes: 2 additions & 4 deletions models/filter/paymail_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package filter
// PaymailFilter is a struct for handling request parameters for paymail_addresses search requests
type PaymailFilter struct {
// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`

ID *string `json:"id,omitempty" example:"ffb86c103d17d87c15aaf080aab6be5415c9fa885309a79b04c9910e39f2b542"`
Alias *string `json:"alias,omitempty" example:"alice"`
Expand All @@ -30,8 +29,7 @@ func (d *PaymailFilter) ToDbConditions() map[string]interface{} {

// AdminPaymailFilter wraps the PaymailFilter providing additional fields for admin paymail search requests
type AdminPaymailFilter struct {
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
PaymailFilter `json:",inline,squash"`
PaymailFilter `json:",inline"`

XpubID *string `json:"xpubId,omitempty" example:"79f90a6bab0a44402fc64828af820e9465645658aea2d138c5205b88e6dabd00"`
}
Expand Down
3 changes: 1 addition & 2 deletions models/filter/transaction_admin_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package filter

// AdminTransactionFilter extends TransactionFilter for admin-specific use, including xpubId filtering
type AdminTransactionFilter struct {
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
TransactionFilter `json:",inline,squash"`
TransactionFilter `json:",inline"`
XPubID *string `json:"xpubId,omitempty" example:"623bc25ce1c0fc510dea72b5ee27b2e70384c099f1f3dce9e73dd987198c3486"`
}

Expand Down
3 changes: 1 addition & 2 deletions models/filter/transaction_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package filter
// TransactionFilter is a struct for handling request parameters for transactions search requests
type TransactionFilter struct {
// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`
Id *string `json:"id,omitempty" example:"d425432e0d10a46af1ec6d00f380e9581ebf7907f3486572b3cd561a4c326e14"`
Hex *string `json:"hex,omitempty"`
BlockHash *string `json:"blockHash,omitempty" example:"0000000000000000031928c28075a82d7a00c2c90b489d1d66dc0afa3f8d26f8"`
Expand Down
3 changes: 1 addition & 2 deletions models/filter/utxo_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ package filter
type UtxoFilter struct {

// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`

TransactionID *string `json:"transactionId,omitempty" example:"5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6"`
OutputIndex *uint32 `json:"outputIndex,omitempty" example:"0"`
Expand Down
3 changes: 1 addition & 2 deletions models/filter/xpub_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package filter
// XpubFilter is a struct for handling request parameters for utxo search requests
type XpubFilter struct {
// ModelFilter is a struct for handling typical request parameters for search requests
//nolint:staticcheck // SA5008 We want to reuse json tags also to mapstructure.
ModelFilter `json:",inline,squash"`
ModelFilter `json:",inline"`

ID *string `json:"id,omitempty" example:"00b953624f78004a4c727cd28557475d5233c15f17aef545106639f4d71b712d"`
CurrentBalance *uint64 `json:"currentBalance,omitempty" example:"1000"`
Expand Down

0 comments on commit 5fe1b5a

Please sign in to comment.