From 570d4c6d20180923e69fc7fa827e47eafb54f953 Mon Sep 17 00:00:00 2001 From: GuwandykA Date: Sat, 24 Oct 2026 23:30:11 +0500 Subject: [PATCH] payment-history: drop /payments/{id}/gateway in favour of /{id}/gateway Both routes served the same handler and took an order ID, while /payments/{id} takes a payment ID - so the /payments/ one read as per-payment and showed up twice in Swagger. /payment-history/{id}/gateway is the one to use. Co-Authored-By: Claude Opus 5.5 --- docs/docs.go | 74 ------------------- docs/swagger.json | 74 ------------------- docs/swagger.yaml | 54 -------------- internal/payment/paymenthistory/handler.go | 2 - .../payment/paymenthistory/handler_test.go | 4 +- 5 files changed, 2 insertions(+), 206 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index c2acf6e..1fcb9a7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -6682,80 +6682,6 @@ const docTemplate = `{ } } }, - "/payment-history/payments/{id}/gateway": { - "get": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "Bir sargydyň ähli tölegini her biriniň GBÜS (HALKBANK) soňky jogaby (gatewayResponse) bilen gaýtarýar: tölendimi, haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt), töleg ýyly/aýy, mukdarlary we belgisi (orderNumber). Tertip: iň täzesi birinji. Bellik: GBÜS kart maglumatyny habar berýänçä cardholderName/maskedPan null, GBÜS asla jogap bermedik bolsa gatewayResponse null; tablisadaky ammar nyşany şu endpoint-den işleýär.", - "produces": [ - "application/json" - ], - "tags": [ - "payment-history" - ], - "summary": "Sargydyň tölegleri GBÜS jogaplary bilen", - "parameters": [ - { - "type": "integer", - "description": "Sargyt ID-si", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [ - "tm", - "ru", - "en", - "all" - ], - "type": "string", - "default": "tm", - "description": "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri", - "name": "lang", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/paymenthistory.PaymentGatewayDTO" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - } - } - } - }, "/payment-history/{id}": { "get": { "security": [ diff --git a/docs/swagger.json b/docs/swagger.json index d15cbe5..26f95a2 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6679,80 +6679,6 @@ } } }, - "/payment-history/payments/{id}/gateway": { - "get": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "Bir sargydyň ähli tölegini her biriniň GBÜS (HALKBANK) soňky jogaby (gatewayResponse) bilen gaýtarýar: tölendimi, haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt), töleg ýyly/aýy, mukdarlary we belgisi (orderNumber). Tertip: iň täzesi birinji. Bellik: GBÜS kart maglumatyny habar berýänçä cardholderName/maskedPan null, GBÜS asla jogap bermedik bolsa gatewayResponse null; tablisadaky ammar nyşany şu endpoint-den işleýär.", - "produces": [ - "application/json" - ], - "tags": [ - "payment-history" - ], - "summary": "Sargydyň tölegleri GBÜS jogaplary bilen", - "parameters": [ - { - "type": "integer", - "description": "Sargyt ID-si", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [ - "tm", - "ru", - "en", - "all" - ], - "type": "string", - "default": "tm", - "description": "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri", - "name": "lang", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/paymenthistory.PaymentGatewayDTO" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/appresult.AppError" - } - } - } - } - }, "/payment-history/{id}": { "get": { "security": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 0897708..672aa95 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -6880,60 +6880,6 @@ paths: summary: Bir tölegiň jikme-jikligi tags: - payment-history - /payment-history/payments/{id}/gateway: - get: - description: 'Bir sargydyň ähli tölegini her biriniň GBÜS (HALKBANK) soňky jogaby - (gatewayResponse) bilen gaýtarýar: tölendimi, haýsy kartdan tölendi (cardholderName/maskedPan), - wagty (createdAt), töleg ýyly/aýy, mukdarlary we belgisi (orderNumber). Tertip: - iň täzesi birinji. Bellik: GBÜS kart maglumatyny habar berýänçä cardholderName/maskedPan - null, GBÜS asla jogap bermedik bolsa gatewayResponse null; tablisadaky ammar - nyşany şu endpoint-den işleýär.' - parameters: - - description: Sargyt ID-si - in: path - name: id - required: true - type: integer - - default: tm - description: Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri - enum: - - tm - - ru - - en - - all - in: query - name: lang - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/paymenthistory.PaymentGatewayDTO' - type: array - "400": - description: Bad Request - schema: - $ref: '#/definitions/appresult.AppError' - "403": - description: Forbidden - schema: - $ref: '#/definitions/appresult.AppError' - "404": - description: Not Found - schema: - $ref: '#/definitions/appresult.AppError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/appresult.AppError' - security: - - BearerAuth: [] - summary: Sargydyň tölegleri GBÜS jogaplary bilen - tags: - - payment-history /payment-settings: get: description: Returns the admin-configurable bank and GBÜS commission fees used diff --git a/internal/payment/paymenthistory/handler.go b/internal/payment/paymenthistory/handler.go index 3adc487..9a0a72a 100644 --- a/internal/payment/paymenthistory/handler.go +++ b/internal/payment/paymenthistory/handler.go @@ -31,7 +31,6 @@ func (h *handler) Register(router *gin.RouterGroup) { group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards)) group.GET("", h.list) group.GET("/payments/:id", h.get) - group.GET("/payments/:id/gateway", h.gateway) group.GET("/:id/gateway", h.gateway) group.GET("/:id", h.orderPayments) group.GET("/:id/logs", h.logs) @@ -125,7 +124,6 @@ func (h *handler) get(c *gin.Context) { // @Failure 403 {object} appresult.AppError // @Failure 404 {object} appresult.AppError // @Failure 500 {object} appresult.AppError -// @Router /payment-history/payments/{id}/gateway [get] // @Router /payment-history/{id}/gateway [get] func (h *handler) gateway(c *gin.Context) { orderID, ok := shared.ParseID(c.Param("id")) diff --git a/internal/payment/paymenthistory/handler_test.go b/internal/payment/paymenthistory/handler_test.go index e5d27f4..9572f48 100644 --- a/internal/payment/paymenthistory/handler_test.go +++ b/internal/payment/paymenthistory/handler_test.go @@ -35,10 +35,10 @@ func gatewayRequest(t *testing.T, repo Repository, path string) *httptest.Respon router.Use(func(c *gin.Context) { c.Set("rbacPrincipal", &rbac.Principal{UserID: 1, Scope: rbac.ScopeAll}) }) - router.GET("/payment-history/payments/:id/gateway", h.gateway) + router.GET("/payment-history/:id/gateway", h.gateway) rec := httptest.NewRecorder() - router.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/payment-history/payments/"+path, nil)) + router.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/payment-history/"+path, nil)) return rec }