diff --git a/docs/docs.go b/docs/docs.go index 9e417f5c..843f5afb 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5999,21 +5999,11 @@ const docTemplate = `{ "name": "coin_gecko_id", "in": "query" }, - { - "type": "integer", - "name": "page", - "in": "query" - }, { "type": "string", "name": "profileID", "in": "query" }, - { - "type": "integer", - "name": "size", - "in": "query" - }, { "type": "string", "description": "profile ID", @@ -6308,12 +6298,12 @@ const docTemplate = `{ { "type": "string", "default": "false", - "name": "noFetchAmount", + "name": "no_fetch_amount", "in": "query" }, { "type": "string", - "name": "vaultId", + "name": "vault_id", "in": "query" } ], @@ -11295,9 +11285,6 @@ const docTemplate = `{ "items": { "$ref": "#/definitions/response.CoinMarketItemData" } - }, - "metadata": { - "$ref": "#/definitions/response.PaginationResponse" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index 98313a78..888a140f 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5991,21 +5991,11 @@ "name": "coin_gecko_id", "in": "query" }, - { - "type": "integer", - "name": "page", - "in": "query" - }, { "type": "string", "name": "profileID", "in": "query" }, - { - "type": "integer", - "name": "size", - "in": "query" - }, { "type": "string", "description": "profile ID", @@ -6300,12 +6290,12 @@ { "type": "string", "default": "false", - "name": "noFetchAmount", + "name": "no_fetch_amount", "in": "query" }, { "type": "string", - "name": "vaultId", + "name": "vault_id", "in": "query" } ], @@ -11287,9 +11277,6 @@ "items": { "$ref": "#/definitions/response.CoinMarketItemData" } - }, - "metadata": { - "$ref": "#/definitions/response.PaginationResponse" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 04282d0f..c8010a7b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3032,14 +3032,14 @@ definitions: type: string usd: type: number - usd_14d_change: - type: number usd_1h_change: type: number usd_1y_change: type: number usd_7d_change: type: number + usd_14d_change: + type: number usd_24h_change: type: number usd_24h_vol: @@ -3125,8 +3125,6 @@ definitions: items: $ref: '#/definitions/response.CoinMarketItemData' type: array - metadata: - $ref: '#/definitions/response.PaginationResponse' type: object response.GetWelcomeChannelConfigResponse: properties: @@ -8253,15 +8251,9 @@ paths: - in: query name: coin_gecko_id type: string - - in: query - name: page - type: integer - in: query name: profileID type: string - - in: query - name: size - type: integer - description: profile ID in: path name: id @@ -8562,10 +8554,10 @@ paths: parameters: - default: "false" in: query - name: noFetchAmount + name: no_fetch_amount type: string - in: query - name: vaultId + name: vault_id type: string produces: - application/json diff --git a/pkg/entities/vault.go b/pkg/entities/vault.go index 2385441f..a906635f 100644 --- a/pkg/entities/vault.go +++ b/pkg/entities/vault.go @@ -106,6 +106,7 @@ func (e *Entity) GetVaults(req request.GetVaultsRequest) ([]model.Vault, error) SolanaWallet: req.SolanaAddress, Threshold: req.Threshold, UserProfileID: req.ProfileID, + VaultIDs: req.VaultIDs, } // query db diff --git a/pkg/handler/vault/vault.go b/pkg/handler/vault/vault.go index 71dc80ec..f70bb6ca 100644 --- a/pkg/handler/vault/vault.go +++ b/pkg/handler/vault/vault.go @@ -1,6 +1,7 @@ package vault import ( + "errors" "net/http" "strconv" "strings" @@ -71,10 +72,22 @@ func (h *Handler) GetVaults(c *gin.Context) { var req request.GetVaultsRequest if err := c.BindQuery(&req); err != nil { h.log.Error(err, "[handler.GetVaults] BindQuery() failed") - c.JSON(http.StatusBadRequest, response.CreateResponse[any](nil, nil, nil, nil)) + c.JSON(http.StatusBadRequest, response.CreateResponse[any](nil, nil, err, nil)) return } + // bind vault IDs + if req.VaultIDsRaw != "" { + req.VaultIDs = strings.Split(req.VaultIDsRaw, ",") + for _, vid := range req.VaultIDs { + if _, err := strconv.Atoi(vid); err != nil { + h.log.Error(err, "[handler.GetVaults] invalid vault_ids") + c.JSON(http.StatusBadRequest, response.CreateResponse[any](nil, nil, errors.New("invalid vault_ids"), nil)) + return + } + } + } + vault, err := h.entities.GetVaults(req) if err != nil { h.log.Fields(logger.Fields{"req": req}).Error(err, "[handler.GetVaults] entity.GetVaults() failed") diff --git a/pkg/repo/vault/pg.go b/pkg/repo/vault/pg.go index 93b63b69..2ba17efa 100644 --- a/pkg/repo/vault/pg.go +++ b/pkg/repo/vault/pg.go @@ -59,5 +59,8 @@ func (pg *pg) List(q ListQuery) (vaults []model.Vault, err error) { if q.Threshold != "" { db = db.Where("vaults.threshold = ?", q.Threshold) } + if len(q.VaultIDs) > 0 { + db = db.Where("vaults.id IN ?", q.VaultIDs) + } return vaults, db.Preload("VaultTreasurers").Preload("DiscordGuild").Find(&vaults).Error } diff --git a/pkg/repo/vault/query.go b/pkg/repo/vault/query.go index 2dfca534..e57d95ec 100644 --- a/pkg/repo/vault/query.go +++ b/pkg/repo/vault/query.go @@ -6,4 +6,5 @@ type ListQuery struct { EvmWallet string SolanaWallet string Threshold string + VaultIDs []string } diff --git a/pkg/request/vault.go b/pkg/request/vault.go index eeafb961..6e50b75f 100644 --- a/pkg/request/vault.go +++ b/pkg/request/vault.go @@ -100,15 +100,17 @@ type MochiPayVaultRequest struct { } type GetVaultsRequest struct { - GuildID string `form:"guild_id"` - ProfileID string `form:"profile_id"` - EvmAddress string `form:"evm_address"` - SolanaAddress string `form:"solana_address"` - Threshold string `form:"threshold"` - NoFetchAmount string `form:"no_fetch_amount" default:"false"` + GuildID string `json:"guild_id" form:"guild_id"` + ProfileID string `json:"profile_id" form:"profile_id"` + EvmAddress string `json:"evm_addres" form:"evm_address"` + SolanaAddress string `json:"solana_address" form:"solana_address"` + Threshold string `json:"threshold" form:"threshold"` + NoFetchAmount string `json:"no_fetch_amount" form:"no_fetch_amount" default:"false"` + VaultIDsRaw string `json:"vault_ids" form:"vault_ids"` + VaultIDs []string `json:"-" form:"-"` } type GetVaultRequest struct { - VaultId string `uri:"vault_id"` - NoFetchAmount string `form:"no_fetch_amount" default:"false"` + VaultId string `json:"vault_id" uri:"vault_id"` + NoFetchAmount string `json:"no_fetch_amount" form:"no_fetch_amount" default:"false"` }