Compare commits
7 Commits
api-lang-l
...
visa-maste
| Author | SHA1 | Date | |
|---|---|---|---|
| 41ae56240a | |||
| 11e1fa4972 | |||
| 742e078090 | |||
| 570d4c6d20 | |||
| d7e5d1f989 | |||
| 78e1976e53 | |||
| f1337706f0 |
19
app.go
19
app.go
@@ -24,9 +24,6 @@ import (
|
|||||||
// @description Online payment system admin API. Localized fields ({en, ru, tm} objects) come back as a plain string in the language of the `lang` query parameter: tm, ru or en (default tm), falling back to tm, ru, en when that translation is empty. lang=all returns the full {en, ru, tm} objects (for edit forms); any other value is 400.
|
// @description Online payment system admin API. Localized fields ({en, ru, tm} objects) come back as a plain string in the language of the `lang` query parameter: tm, ru or en (default tm), falling back to tm, ru, en when that translation is empty. lang=all returns the full {en, ru, tm} objects (for edit forms); any other value is 400.
|
||||||
// @host localhost:5005
|
// @host localhost:5005
|
||||||
// @BasePath /api/admin
|
// @BasePath /api/admin
|
||||||
// @securityDefinitions.apikey BearerAuth
|
|
||||||
// @in header
|
|
||||||
// @name Authorization
|
|
||||||
// @schemes http
|
// @schemes http
|
||||||
// @tag.name auth
|
// @tag.name auth
|
||||||
// @tag.description Authentication
|
// @tag.description Authentication
|
||||||
@@ -50,12 +47,24 @@ import (
|
|||||||
// @tag.description Card rekwizit (card details) orders
|
// @tag.description Card rekwizit (card details) orders
|
||||||
// @tag.name activity-logs
|
// @tag.name activity-logs
|
||||||
// @tag.description User activity audit trail
|
// @tag.description User activity audit trail
|
||||||
// @tag.name visa-master-payment-orders
|
// @tag.name visa-master-orders
|
||||||
// @tag.description Visa/Master student-transfer payment orders
|
// @tag.description Visa/Master and Sber student-transfer orders: list, view, create, edit, delete
|
||||||
|
// @tag.name visa-master-order-actions
|
||||||
|
// @tag.description Visa/Master we Sber sargytlarynyň amallary (Ammallar): kim, haçan, näme goşdy, üýtgetdi ýa-da pozdy. Ulanylyş tertibi: 1) GET /visa-master-payment-orders/{id}/actions - sargydyň amallary; 2) GET /visa-master-payment-orders/{id}/actions/{actionId} - bir amalyň öňki we täze bahalary
|
||||||
|
// @tag.name visa-master-payment
|
||||||
|
// @tag.description Paying a Visa/Master or Sber order through GBÜS (HALKBANK): quote, pay, status re-check, bank callback
|
||||||
|
// @tag.name payment-history
|
||||||
|
// @tag.description Visa/Master we Sber töleg synanyşyklarynyň taryhy. Ulanylyş tertibi: 1) GET /payment-history - ähli tölegler; 2) GET /payment-history/{id} - bir sargydyň tölegleri; 3) GET /payment-history/payments/{id} - bir tölegiň jikme-jikligi; 4) GET /payment-history/{id}/gateway - sargydyň tölegleri GBÜS jogaplary bilen; 5) GET /payment-history/{id}/logs - sargydyň ädimme-ädim töleg loglary
|
||||||
// @tag.name backups
|
// @tag.name backups
|
||||||
// @tag.description Database SQL backups
|
// @tag.description Database SQL backups
|
||||||
// @tag.name currencies
|
// @tag.name currencies
|
||||||
// @tag.description Currency exchange rates
|
// @tag.description Currency exchange rates
|
||||||
|
//
|
||||||
|
// Security definitions go last: swag reads every line after one as its
|
||||||
|
// attributes, so anything declared below it (tags, schemes) is dropped.
|
||||||
|
// @securityDefinitions.apikey BearerAuth
|
||||||
|
// @in header
|
||||||
|
// @name Authorization
|
||||||
func main() {
|
func main() {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
logger := logging.GetLogger()
|
logger := logging.GetLogger()
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE IF EXISTS visa_master_order_actions;
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
-- Every create/update/delete of a visa/master or sber order, for the
|
||||||
|
-- order page's "Ammallar" table: who did it, whether it went through, and
|
||||||
|
-- for an update only the columns that changed - original holds their
|
||||||
|
-- values before, changes after. A create has no original and a delete no
|
||||||
|
-- changes. Failed actions are kept too, with exception set and changes
|
||||||
|
-- holding what was attempted. created_by is null when no user started it
|
||||||
|
-- (the GBÜS callback finalizing a payment).
|
||||||
|
CREATE TABLE IF NOT EXISTS visa_master_order_actions (
|
||||||
|
id bigserial PRIMARY KEY,
|
||||||
|
order_id bigint NOT NULL,
|
||||||
|
name character varying(20) NOT NULL,
|
||||||
|
status character varying(20) NOT NULL,
|
||||||
|
original jsonb,
|
||||||
|
changes jsonb,
|
||||||
|
exception text,
|
||||||
|
created_by bigint,
|
||||||
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
|
CONSTRAINT visa_master_order_actions_order_id_fkey
|
||||||
|
FOREIGN KEY (order_id) REFERENCES visa_master_payment_orders(id),
|
||||||
|
CONSTRAINT visa_master_order_actions_created_by_fkey
|
||||||
|
FOREIGN KEY (created_by) REFERENCES users(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS visa_master_order_actions_order_id_idx
|
||||||
|
ON visa_master_order_actions (order_id, id DESC);
|
||||||
2355
docs/docs.go
2355
docs/docs.go
File diff suppressed because it is too large
Load Diff
2356
docs/swagger.json
2356
docs/swagger.json
File diff suppressed because it is too large
Load Diff
1964
docs/swagger.yaml
1964
docs/swagger.yaml
File diff suppressed because it is too large
Load Diff
@@ -52,6 +52,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -86,6 +87,7 @@ func (h *handler) finance(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -111,6 +113,7 @@ func (h *handler) backlog(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -136,6 +139,7 @@ func (h *handler) branches(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -161,6 +165,7 @@ func (h *handler) products(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -187,6 +192,7 @@ func (h *handler) customers(c *gin.Context) {
|
|||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
// @Param operator_limit query int false "Number of operators to return" default(10)
|
// @Param operator_limit query int false "Number of operators to return" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param status query string false "Filter by status (pending, completed, failed)"
|
// @Param status query string false "Filter by status (pending, completed, failed)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Backup ID"
|
// @Param id path int true "Backup ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -106,6 +108,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Tags backups
|
// @Tags backups
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /backups [post]
|
// @Router /backups [post]
|
||||||
@@ -127,6 +130,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Produce application/sql
|
// @Produce application/sql
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Backup ID"
|
// @Param id path int true "Backup ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {file} file
|
// @Success 200 {file} file
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -168,6 +172,7 @@ func (h *handler) download(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Backup ID"
|
// @Param id path int true "Backup ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param created_by query int false "Filter by creator user ID"
|
// @Param created_by query int false "Filter by creator user ID"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card balance ID"
|
// @Param id path int true "Card balance ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -111,6 +113,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardBalanceDTO true "Card balance payload"
|
// @Param body body CreateCardBalanceDTO true "Card balance payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -141,6 +144,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card balance ID"
|
// @Param id path int true "Card balance ID"
|
||||||
// @Param body body UpdateCardBalanceDTO true "Card balance payload"
|
// @Param body body UpdateCardBalanceDTO true "Card balance payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -184,6 +188,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card balance ID"
|
// @Param id path int true "Card balance ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -77,6 +78,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card order ID"
|
// @Param id path int true "Card order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -114,6 +116,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardOrderDTO true "Card order payload"
|
// @Param body body CreateCardOrderDTO true "Card order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -145,6 +148,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card order ID"
|
// @Param id path int true "Card order ID"
|
||||||
// @Param body body UpdateCardOrderDTO true "Card order payload"
|
// @Param body body UpdateCardOrderDTO true "Card order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -189,6 +193,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card order ID"
|
// @Param id path int true "Card order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card pin order ID"
|
// @Param id path int true "Card pin order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -113,6 +115,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardPinOrderDTO true "Card pin order payload"
|
// @Param body body CreateCardPinOrderDTO true "Card pin order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -143,6 +146,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card pin order ID"
|
// @Param id path int true "Card pin order ID"
|
||||||
// @Param body body UpdateCardPinOrderDTO true "Card pin order payload"
|
// @Param body body UpdateCardPinOrderDTO true "Card pin order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -186,6 +190,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card pin order ID"
|
// @Param id path int true "Card pin order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card rekwizit order ID"
|
// @Param id path int true "Card rekwizit order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -113,6 +115,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
// @Param body body CreateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -143,6 +146,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card rekwizit order ID"
|
// @Param id path int true "Card rekwizit order ID"
|
||||||
// @Param body body UpdateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
// @Param body body UpdateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -186,6 +190,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card rekwizit order ID"
|
// @Param id path int true "Card rekwizit order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param type query string false "Filter by card type"
|
// @Param type query string false "Filter by card type"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -73,6 +74,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card ID"
|
// @Param id path int true "Card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -117,6 +119,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardDTO true "Card payload"
|
// @Param body body CreateCardDTO true "Card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -147,6 +150,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card ID"
|
// @Param id path int true "Card ID"
|
||||||
// @Param body body UpdateCardDTO true "Card payload"
|
// @Param body body UpdateCardDTO true "Card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -190,6 +194,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card ID"
|
// @Param id path int true "Card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param active query bool false "Filter by active"
|
// @Param active query bool false "Filter by active"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -75,6 +76,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -109,6 +111,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreatePaymentCardDTO true "Payment card payload"
|
// @Param body body CreatePaymentCardDTO true "Payment card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -139,6 +142,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
// @Param body body UpdatePaymentCardDTO true "Payment card payload"
|
// @Param body body UpdatePaymentCardDTO true "Payment card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -180,6 +184,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
// @Param body body UpdatePaymentCardActiveDTO true "Active payload"
|
// @Param body body UpdatePaymentCardActiveDTO true "Active payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -219,6 +224,7 @@ func (h *handler) updateActive(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param reason_name query string false "Filter by title (en, ru, tm)"
|
// @Param reason_name query string false "Filter by title (en, ru, tm)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -72,6 +73,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Reason card ID"
|
// @Param id path int true "Reason card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -106,6 +108,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateReasonCardDTO true "Reason card payload"
|
// @Param body body CreateReasonCardDTO true "Reason card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -136,6 +139,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Reason card ID"
|
// @Param id path int true "Reason card ID"
|
||||||
// @Param body body UpdateReasonCardDTO true "Reason card payload"
|
// @Param body body UpdateReasonCardDTO true "Reason card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -175,6 +179,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Reason card ID"
|
// @Param id path int true "Reason card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import (
|
|||||||
reasonscarddb "online-back/internal/cards/reasonscard/db"
|
reasonscarddb "online-back/internal/cards/reasonscard/db"
|
||||||
"online-back/internal/cards/visamaster"
|
"online-back/internal/cards/visamaster"
|
||||||
visamasterdb "online-back/internal/cards/visamaster/db"
|
visamasterdb "online-back/internal/cards/visamaster/db"
|
||||||
|
"online-back/internal/cards/visamasteractions"
|
||||||
|
visamasteractionsdb "online-back/internal/cards/visamasteractions/db"
|
||||||
"online-back/internal/handlers"
|
"online-back/internal/handlers"
|
||||||
"online-back/pkg/client/postgresql"
|
"online-back/pkg/client/postgresql"
|
||||||
"online-back/pkg/logging"
|
"online-back/pkg/logging"
|
||||||
@@ -45,5 +47,6 @@ func Handlers(client postgresql.Client, logger *logging.Logger) []handlers.Handl
|
|||||||
paymentcard.NewHandler(logger, paymentcarddb.NewRepository(client, logger)),
|
paymentcard.NewHandler(logger, paymentcarddb.NewRepository(client, logger)),
|
||||||
reasonscard.NewHandler(logger, reasonscarddb.NewRepository(client, logger)),
|
reasonscard.NewHandler(logger, reasonscarddb.NewRepository(client, logger)),
|
||||||
visamaster.NewHandler(logger, visamasterdb.NewRepository(client, logger)),
|
visamaster.NewHandler(logger, visamasterdb.NewRepository(client, logger)),
|
||||||
|
visamasteractions.NewHandler(logger, visamasteractionsdb.NewRepository(client, logger)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"online-back/internal/cards/visamaster"
|
"online-back/internal/cards/visamaster"
|
||||||
|
"online-back/internal/cards/visamasteractions"
|
||||||
|
actionsdb "online-back/internal/cards/visamasteractions/db"
|
||||||
"online-back/internal/identity/rbac"
|
"online-back/internal/identity/rbac"
|
||||||
"online-back/internal/shared"
|
"online-back/internal/shared"
|
||||||
"online-back/pkg/client/postgresql"
|
"online-back/pkg/client/postgresql"
|
||||||
@@ -214,7 +216,34 @@ func (r *repository) Create(ctx context.Context, dto visamaster.CreateVisaMaster
|
|||||||
orderColumnsSQL, orderSelectColumns,
|
orderColumnsSQL, orderSelectColumns,
|
||||||
)
|
)
|
||||||
|
|
||||||
return scanOrder(r.client.QueryRow(ctx, query, args...))
|
// A failed create has no order to attach an action to, so only the
|
||||||
|
// successful one is recorded - in the same transaction as the insert.
|
||||||
|
tx, err := r.client.Begin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
|
||||||
|
item, err := scanOrder(tx.QueryRow(ctx, query, args...))
|
||||||
|
if err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
created, err := actionsdb.Snapshot(ctx, tx, item.Id)
|
||||||
|
if err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
if err := actionsdb.Insert(ctx, tx, visamasteractions.CreateOrderActionDTO{
|
||||||
|
OrderId: item.Id, Name: visamasteractions.NameCreate, Status: visamasteractions.StatusFinished,
|
||||||
|
Changes: created, CreatedBy: dto.CreatedBy,
|
||||||
|
}); err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Commit(ctx); err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repository) Update(ctx context.Context, id int64, dto visamaster.UpdateVisaMasterPaymentOrderDTO) (visamaster.VisaMasterPaymentOrderDTO, error) {
|
func (r *repository) Update(ctx context.Context, id int64, dto visamaster.UpdateVisaMasterPaymentOrderDTO) (visamaster.VisaMasterPaymentOrderDTO, error) {
|
||||||
@@ -240,15 +269,124 @@ func (r *repository) Update(ctx context.Context, id int64, dto visamaster.Update
|
|||||||
strings.Join(assignments, ", "), len(args), orderColumnsSQL, orderSelectColumns,
|
strings.Join(assignments, ", "), len(args), orderColumnsSQL, orderSelectColumns,
|
||||||
)
|
)
|
||||||
|
|
||||||
item, err := scanOrder(r.client.QueryRow(ctx, query, args...))
|
tx, err := r.client.Begin(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
}
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
|
||||||
|
before, err := actionsdb.Snapshot(ctx, tx, id)
|
||||||
|
if err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// fail rolls the update back and records it as failed, with the
|
||||||
|
// values it attempted.
|
||||||
|
fail := func(err error) (visamaster.VisaMasterPaymentOrderDTO, error) {
|
||||||
|
tx.Rollback(ctx)
|
||||||
|
original, changes := r.attemptedChanges(before, args)
|
||||||
|
r.recordFailure(ctx, id, visamasteractions.NameUpdate, dto.UpdatedBy, original, changes, err)
|
||||||
|
return visamaster.VisaMasterPaymentOrderDTO{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
item, err := scanOrder(tx.QueryRow(ctx, query, args...))
|
||||||
|
if err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
after, err := actionsdb.Snapshot(ctx, tx, id)
|
||||||
|
if err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
|
// An update that changed nothing (the form saved as-is) is not an action.
|
||||||
|
if original, changes := visamasteractions.Diff(before, after); changes != nil {
|
||||||
|
if err := actionsdb.Insert(ctx, tx, visamasteractions.CreateOrderActionDTO{
|
||||||
|
OrderId: id, Name: visamasteractions.NameUpdate, Status: visamasteractions.StatusFinished,
|
||||||
|
Original: original, Changes: changes, CreatedBy: dto.UpdatedBy,
|
||||||
|
}); err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Commit(ctx); err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
return item, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repository) Delete(ctx context.Context, id int64) error {
|
func (r *repository) Delete(ctx context.Context, id int64, deletedBy *int64) error {
|
||||||
return r.generic.Delete(ctx, id)
|
tx, err := r.client.Begin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tx.Rollback(ctx)
|
||||||
|
|
||||||
|
before, err := actionsdb.Snapshot(ctx, tx, id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fail := func(err error) error {
|
||||||
|
tx.Rollback(ctx)
|
||||||
|
r.recordFailure(ctx, id, visamasteractions.NameDelete, deletedBy, before, nil, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same soft delete as genericrepo.Delete, inside the transaction.
|
||||||
|
if _, err := tx.Exec(ctx, `UPDATE visa_master_payment_orders SET deleted_at = now() WHERE id = $1 AND deleted_at IS NULL`, id); err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
|
if err := actionsdb.Insert(ctx, tx, visamasteractions.CreateOrderActionDTO{
|
||||||
|
OrderId: id, Name: visamasteractions.NameDelete, Status: visamasteractions.StatusFinished,
|
||||||
|
Original: before, CreatedBy: deletedBy,
|
||||||
|
}); err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Commit(ctx); err != nil {
|
||||||
|
return fail(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// attemptedChanges is what a failed update tried to change: the writable
|
||||||
|
// columns whose attempted value (args, in orderWritableColumns order)
|
||||||
|
// differs from before.
|
||||||
|
func (r *repository) attemptedChanges(before map[string]interface{}, args []interface{}) (original, changes map[string]interface{}) {
|
||||||
|
values := make(map[string]interface{}, len(orderWritableColumns))
|
||||||
|
current := make(map[string]interface{}, len(orderWritableColumns))
|
||||||
|
for i, column := range orderWritableColumns {
|
||||||
|
value := args[i]
|
||||||
|
// jsonArg's bytes are JSON, not a byte string to base64-encode.
|
||||||
|
if raw, ok := value.([]byte); ok {
|
||||||
|
value = json.RawMessage(raw)
|
||||||
|
}
|
||||||
|
values[column] = value
|
||||||
|
current[column] = before[column]
|
||||||
|
}
|
||||||
|
attempted, err := visamasteractions.Normalize(values)
|
||||||
|
if err != nil {
|
||||||
|
// Unencodable (e.g. invalid JSON in senderDatas): record the failure
|
||||||
|
// without the attempted values rather than not at all.
|
||||||
|
r.logger.Errorf("visa master order action: encode attempted values failed: %v", err)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return visamasteractions.Diff(current, attempted)
|
||||||
|
}
|
||||||
|
|
||||||
|
// recordFailure records a failed action through the plain client, after
|
||||||
|
// its transaction rolled back. Best-effort: a write failure here is
|
||||||
|
// logged, not propagated over the action's own error.
|
||||||
|
func (r *repository) recordFailure(ctx context.Context, orderID int64, name string, createdBy *int64, original, changes map[string]interface{}, cause error) {
|
||||||
|
exception := cause.Error()
|
||||||
|
// Detached from cancellation: a client dropping the request must not
|
||||||
|
// cost us the record of what it tried.
|
||||||
|
if err := actionsdb.Insert(context.WithoutCancel(ctx), r.client, visamasteractions.CreateOrderActionDTO{
|
||||||
|
OrderId: orderID, Name: name, Status: visamasteractions.StatusFailed,
|
||||||
|
Original: original, Changes: changes, Exception: &exception, CreatedBy: createdBy,
|
||||||
|
}); err != nil {
|
||||||
|
r.logger.Errorf("record failed visa master order action (order %d, %s) failed: %v", orderID, name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanOrder(row genericrepo.Scanner) (visamaster.VisaMasterPaymentOrderDTO, error) {
|
func scanOrder(row genericrepo.Scanner) (visamaster.VisaMasterPaymentOrderDTO, error) {
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ type CreateVisaMasterPaymentOrderDTO struct {
|
|||||||
RecieverDepositAccount *string `json:"recieverDepositAccount"`
|
RecieverDepositAccount *string `json:"recieverDepositAccount"`
|
||||||
AmountUsd float64 `json:"amountUsd"`
|
AmountUsd float64 `json:"amountUsd"`
|
||||||
Paid *bool `json:"paid"`
|
Paid *bool `json:"paid"`
|
||||||
|
// CreatedBy is the caller, recorded on the order's create action.
|
||||||
|
CreatedBy *int64 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateVisaMasterPaymentOrderDTO struct {
|
type UpdateVisaMasterPaymentOrderDTO struct {
|
||||||
@@ -104,6 +106,8 @@ type UpdateVisaMasterPaymentOrderDTO struct {
|
|||||||
RecieverDepositAccount *string `json:"recieverDepositAccount"`
|
RecieverDepositAccount *string `json:"recieverDepositAccount"`
|
||||||
AmountUsd float64 `json:"amountUsd"`
|
AmountUsd float64 `json:"amountUsd"`
|
||||||
Paid bool `json:"paid"`
|
Paid bool `json:"paid"`
|
||||||
|
// UpdatedBy is the caller, recorded on the order's update action.
|
||||||
|
UpdatedBy *int64 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListFilter struct {
|
type ListFilter struct {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// list godoc
|
// list godoc
|
||||||
// @Summary List visa/master payment orders
|
// @Summary List visa/master payment orders
|
||||||
// @Description Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)
|
// @Description Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param name query string false "Filter by passport name or surname"
|
// @Param name query string false "Filter by passport name or surname"
|
||||||
@@ -54,6 +54,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -71,7 +72,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// listSber godoc
|
// listSber godoc
|
||||||
// @Summary List sber payment orders
|
// @Summary List sber payment orders
|
||||||
// @Description Returns paginated payment orders of type sber
|
// @Description Returns paginated payment orders of type sber
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param name query string false "Filter by passport name or surname"
|
// @Param name query string false "Filter by passport name or surname"
|
||||||
@@ -81,6 +82,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -109,10 +111,11 @@ func (h *handler) respondList(c *gin.Context, filter ListFilter) {
|
|||||||
// getByID godoc
|
// getByID godoc
|
||||||
// @Summary Get visa/master payment order by ID
|
// @Summary Get visa/master payment order by ID
|
||||||
// @Description Returns a single visa/master payment order with branch and user details
|
// @Description Returns a single visa/master payment order with branch and user details
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -145,11 +148,12 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// create godoc
|
// create godoc
|
||||||
// @Summary Create visa/master payment order
|
// @Summary Create visa/master payment order
|
||||||
// @Description Creates a new visa/master payment order
|
// @Description Creates a new visa/master payment order
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
// @Param body body CreateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -160,6 +164,9 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if userID, ok := rbac.CurrentUserID(c); ok {
|
||||||
|
dto.CreatedBy = &userID
|
||||||
|
}
|
||||||
|
|
||||||
item, err := h.repository.Create(c.Request.Context(), dto)
|
item, err := h.repository.Create(c.Request.Context(), dto)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -174,12 +181,13 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// update godoc
|
// update godoc
|
||||||
// @Summary Update visa/master payment order
|
// @Summary Update visa/master payment order
|
||||||
// @Description Updates an existing visa/master payment order
|
// @Description Updates an existing visa/master payment order
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
// @Param body body UpdateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
// @Param body body UpdateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -201,6 +209,9 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if userID, ok := rbac.CurrentUserID(c); ok {
|
||||||
|
dto.UpdatedBy = &userID
|
||||||
|
}
|
||||||
|
|
||||||
item, err := h.repository.Update(c.Request.Context(), id, dto)
|
item, err := h.repository.Update(c.Request.Context(), id, dto)
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
@@ -219,10 +230,11 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// delete godoc
|
// delete godoc
|
||||||
// @Summary Delete visa/master payment order
|
// @Summary Delete visa/master payment order
|
||||||
// @Description Deletes a visa/master payment order
|
// @Description Deletes a visa/master payment order
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -239,7 +251,12 @@ func (h *handler) delete(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.repository.Delete(c.Request.Context(), id); errors.Is(err, pgx.ErrNoRows) {
|
var deletedBy *int64
|
||||||
|
if userID, ok := rbac.CurrentUserID(c); ok {
|
||||||
|
deletedBy = &userID
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.repository.Delete(c.Request.Context(), id, deletedBy); errors.Is(err, pgx.ErrNoRows) {
|
||||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||||
return
|
return
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|||||||
@@ -7,5 +7,7 @@ type Repository interface {
|
|||||||
GetByID(ctx context.Context, id int64) (VisaMasterPaymentOrderDTO, error)
|
GetByID(ctx context.Context, id int64) (VisaMasterPaymentOrderDTO, error)
|
||||||
Create(ctx context.Context, dto CreateVisaMasterPaymentOrderDTO) (VisaMasterPaymentOrderDTO, error)
|
Create(ctx context.Context, dto CreateVisaMasterPaymentOrderDTO) (VisaMasterPaymentOrderDTO, error)
|
||||||
Update(ctx context.Context, id int64, dto UpdateVisaMasterPaymentOrderDTO) (VisaMasterPaymentOrderDTO, error)
|
Update(ctx context.Context, id int64, dto UpdateVisaMasterPaymentOrderDTO) (VisaMasterPaymentOrderDTO, error)
|
||||||
Delete(ctx context.Context, id int64) error
|
// Delete soft-deletes the order; deletedBy is the caller, recorded on
|
||||||
|
// its delete action.
|
||||||
|
Delete(ctx context.Context, id int64, deletedBy *int64) error
|
||||||
}
|
}
|
||||||
|
|||||||
166
internal/cards/visamasteractions/db/postgresql.go
Normal file
166
internal/cards/visamasteractions/db/postgresql.go
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"online-back/internal/cards/visamasteractions"
|
||||||
|
"online-back/internal/shared"
|
||||||
|
"online-back/pkg/client/postgresql"
|
||||||
|
"online-back/pkg/logging"
|
||||||
|
|
||||||
|
"github.com/jackc/pgconn"
|
||||||
|
"github.com/jackc/pgx/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
type repository struct {
|
||||||
|
client postgresql.Client
|
||||||
|
logger *logging.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRepository(client postgresql.Client, logger *logging.Logger) visamasteractions.Repository {
|
||||||
|
return &repository{client: client, logger: logger}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Querier is satisfied by both postgresql.Client and pgx.Tx, so the order
|
||||||
|
// repositories can snapshot and record inside the transaction that changes
|
||||||
|
// the order - an action is on record exactly when its change is.
|
||||||
|
type Querier interface {
|
||||||
|
QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
|
||||||
|
Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snapshot locks orderID's row (FOR UPDATE) and returns its columns as
|
||||||
|
// recorded on an action - everything but id and the timestamps, which
|
||||||
|
// change on every write. pgx.ErrNoRows if the order doesn't exist or is
|
||||||
|
// deleted.
|
||||||
|
func Snapshot(ctx context.Context, q Querier, orderID int64) (map[string]interface{}, error) {
|
||||||
|
var raw []byte
|
||||||
|
err := q.QueryRow(ctx,
|
||||||
|
`SELECT to_jsonb(o) - 'id' - 'created_at' - 'updated_at' - 'deleted_at'
|
||||||
|
FROM visa_master_payment_orders o WHERE o.id = $1 AND o.deleted_at IS NULL FOR UPDATE`,
|
||||||
|
orderID,
|
||||||
|
).Scan(&raw)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var row map[string]interface{}
|
||||||
|
if err := json.Unmarshal(raw, &row); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return row, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert records one action. A failed action must be recorded through the
|
||||||
|
// plain client after its transaction rolled back, or it is rolled back too.
|
||||||
|
func Insert(ctx context.Context, q Querier, dto visamasteractions.CreateOrderActionDTO) error {
|
||||||
|
original, err := jsonOrNull(dto.Original)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
changes, err := jsonOrNull(dto.Changes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = q.Exec(ctx,
|
||||||
|
`INSERT INTO visa_master_order_actions (order_id, name, status, original, changes, exception, created_by)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7)`,
|
||||||
|
dto.OrderId, dto.Name, dto.Status, original, changes, dto.Exception, dto.CreatedBy,
|
||||||
|
)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func jsonOrNull(values map[string]interface{}) ([]byte, error) {
|
||||||
|
if values == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return json.Marshal(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error) {
|
||||||
|
var userID *int64
|
||||||
|
var branchID int64
|
||||||
|
err := r.client.QueryRow(ctx,
|
||||||
|
`SELECT user_id, branch_id FROM visa_master_payment_orders WHERE id = $1`, orderID,
|
||||||
|
).Scan(&userID, &branchID)
|
||||||
|
return userID, branchID, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionSelectColumns = `a.id, a.order_id, a.name, a.status, o.unique_id, o.type,
|
||||||
|
a.created_by, ` + shared.UserDisplaySQL + `, a.created_at`
|
||||||
|
|
||||||
|
const actionFromClause = ` FROM visa_master_order_actions a
|
||||||
|
JOIN visa_master_payment_orders o ON o.id = a.order_id
|
||||||
|
LEFT JOIN users u ON u.id = a.created_by`
|
||||||
|
|
||||||
|
func (r *repository) List(ctx context.Context, filter visamasteractions.ListFilter) (visamasteractions.ListOrderActionDTO, error) {
|
||||||
|
result := visamasteractions.ListOrderActionDTO{Actions: []visamasteractions.OrderActionDTO{}}
|
||||||
|
|
||||||
|
if err := r.client.QueryRow(ctx,
|
||||||
|
`SELECT COUNT(*) FROM visa_master_order_actions WHERE order_id = $1`, filter.OrderId,
|
||||||
|
).Scan(&result.Count); err != nil {
|
||||||
|
return visamasteractions.ListOrderActionDTO{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
rows, err := r.client.Query(ctx,
|
||||||
|
`SELECT `+actionSelectColumns+actionFromClause+` WHERE a.order_id = $1 ORDER BY a.id DESC LIMIT $2 OFFSET $3`,
|
||||||
|
filter.OrderId, filter.Limit, (filter.Page-1)*filter.Limit,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return visamasteractions.ListOrderActionDTO{}, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
item, err := scanAction(rows)
|
||||||
|
if err != nil {
|
||||||
|
return visamasteractions.ListOrderActionDTO{}, err
|
||||||
|
}
|
||||||
|
result.Actions = append(result.Actions, item)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return visamasteractions.ListOrderActionDTO{}, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *repository) GetByID(ctx context.Context, orderID, actionID int64) (visamasteractions.OrderActionDetailDTO, error) {
|
||||||
|
var detail visamasteractions.OrderActionDetailDTO
|
||||||
|
var original, changes []byte
|
||||||
|
row := r.client.QueryRow(ctx,
|
||||||
|
`SELECT `+actionSelectColumns+`, a.original, a.changes, a.exception`+actionFromClause+` WHERE a.id = $1 AND a.order_id = $2`,
|
||||||
|
actionID, orderID,
|
||||||
|
)
|
||||||
|
item, err := scanAction(row, &original, &changes, &detail.Exception)
|
||||||
|
if err != nil {
|
||||||
|
return visamasteractions.OrderActionDetailDTO{}, err
|
||||||
|
}
|
||||||
|
detail.OrderActionDTO = item
|
||||||
|
detail.Original = rawOrNull(original)
|
||||||
|
detail.Changes = rawOrNull(changes)
|
||||||
|
return detail, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanAction reads actionSelectColumns, followed by any extra columns into
|
||||||
|
// extra.
|
||||||
|
func scanAction(row pgx.Row, extra ...interface{}) (visamasteractions.OrderActionDTO, error) {
|
||||||
|
var item visamasteractions.OrderActionDTO
|
||||||
|
dest := append([]interface{}{
|
||||||
|
&item.Id, &item.OrderId, &item.Name, &item.Status, &item.Target.UniqueId, &item.Target.Type,
|
||||||
|
&item.CreatedById, &item.CreatedByName, &item.CreatedAt,
|
||||||
|
}, extra...)
|
||||||
|
if err := row.Scan(dest...); err != nil {
|
||||||
|
return visamasteractions.OrderActionDTO{}, err
|
||||||
|
}
|
||||||
|
item.NameLabel = visamasteractions.NameLabel(item.Name)
|
||||||
|
item.Target.Id = item.OrderId
|
||||||
|
item.Target.Label = visamasteractions.TargetLabel(item.Target.Type)
|
||||||
|
return item, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func rawOrNull(raw []byte) json.RawMessage {
|
||||||
|
if len(raw) == 0 {
|
||||||
|
return json.RawMessage("null")
|
||||||
|
}
|
||||||
|
return json.RawMessage(raw)
|
||||||
|
}
|
||||||
52
internal/cards/visamasteractions/diff.go
Normal file
52
internal/cards/visamasteractions/diff.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package visamasteractions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Normalize round-trips values through JSON, so Go values (pointers, raw
|
||||||
|
// JSON bytes, float64s) compare equal to the same values read back from a
|
||||||
|
// jsonb snapshot of the row.
|
||||||
|
func Normalize(values map[string]interface{}) (map[string]interface{}, error) {
|
||||||
|
if values == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(values)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var normalized map[string]interface{}
|
||||||
|
if err := json.Unmarshal(data, &normalized); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return normalized, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Diff keeps only the columns whose value differs between before and
|
||||||
|
// after: original gets their before values and changes their after
|
||||||
|
// values. A column missing on one side counts as null there. Both are nil
|
||||||
|
// when nothing changed.
|
||||||
|
func Diff(before, after map[string]interface{}) (original, changes map[string]interface{}) {
|
||||||
|
for key, value := range after {
|
||||||
|
if old, ok := before[key]; ok && reflect.DeepEqual(old, value) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if original == nil {
|
||||||
|
original, changes = map[string]interface{}{}, map[string]interface{}{}
|
||||||
|
}
|
||||||
|
original[key] = before[key]
|
||||||
|
changes[key] = value
|
||||||
|
}
|
||||||
|
for key, old := range before {
|
||||||
|
if _, ok := after[key]; ok || old == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if original == nil {
|
||||||
|
original, changes = map[string]interface{}{}, map[string]interface{}{}
|
||||||
|
}
|
||||||
|
original[key] = old
|
||||||
|
changes[key] = nil
|
||||||
|
}
|
||||||
|
return original, changes
|
||||||
|
}
|
||||||
64
internal/cards/visamasteractions/diff_test.go
Normal file
64
internal/cards/visamasteractions/diff_test.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package visamasteractions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDiffKeepsOnlyChangedColumns(t *testing.T) {
|
||||||
|
before := map[string]interface{}{"status": "pending", "paid": false, "amount_usd": 250.0, "notes": nil}
|
||||||
|
after := map[string]interface{}{"status": "completed", "paid": false, "amount_usd": 250.0, "notes": nil}
|
||||||
|
|
||||||
|
original, changes := Diff(before, after)
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(original, map[string]interface{}{"status": "pending"}) {
|
||||||
|
t.Errorf("original = %v, want only status: pending", original)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(changes, map[string]interface{}{"status": "completed"}) {
|
||||||
|
t.Errorf("changes = %v, want only status: completed", changes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDiffNothingChanged(t *testing.T) {
|
||||||
|
row := map[string]interface{}{"status": "pending", "sender_datas": map[string]interface{}{"a": 1.0}}
|
||||||
|
if original, changes := Diff(row, row); original != nil || changes != nil {
|
||||||
|
t.Errorf("Diff of equal rows = %v, %v, want nil, nil", original, changes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDiffMissingColumnCountsAsNull(t *testing.T) {
|
||||||
|
before := map[string]interface{}{"status": "pending", "notes": "old"}
|
||||||
|
after := map[string]interface{}{"status": "pending", "email": "a@b.tm"}
|
||||||
|
|
||||||
|
original, changes := Diff(before, after)
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(original, map[string]interface{}{"notes": "old", "email": nil}) {
|
||||||
|
t.Errorf("original = %v", original)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(changes, map[string]interface{}{"notes": nil, "email": "a@b.tm"}) {
|
||||||
|
t.Errorf("changes = %v", changes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNormalizeMatchesJSONBSnapshot(t *testing.T) {
|
||||||
|
status := "pending"
|
||||||
|
attempted, err := Normalize(map[string]interface{}{
|
||||||
|
"status": &status,
|
||||||
|
"amount_usd": 250.0,
|
||||||
|
"sender_datas": json.RawMessage(`{"a": 1}`),
|
||||||
|
"notes": (*string)(nil),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var snapshot map[string]interface{}
|
||||||
|
if err := json.Unmarshal([]byte(`{"status": "pending", "amount_usd": 250, "sender_datas": {"a": 1}, "notes": null}`), &snapshot); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if original, changes := Diff(snapshot, attempted); original != nil || changes != nil {
|
||||||
|
t.Errorf("normalized values differ from the snapshot: %v -> %v", original, changes)
|
||||||
|
}
|
||||||
|
}
|
||||||
117
internal/cards/visamasteractions/dto.go
Normal file
117
internal/cards/visamasteractions/dto.go
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package visamasteractions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"online-back/internal/shared"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Action names, as the "Ammallar" table's Amalyň ady column shows them.
|
||||||
|
const (
|
||||||
|
NameCreate = "create"
|
||||||
|
NameUpdate = "update"
|
||||||
|
NameDelete = "delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Action statuses: finished once the change is committed, failed (with
|
||||||
|
// Exception) when it was attempted but rolled back.
|
||||||
|
const (
|
||||||
|
StatusFinished = "finished"
|
||||||
|
StatusFailed = "failed"
|
||||||
|
)
|
||||||
|
|
||||||
|
// orderTypeSber is the type value of Sber orders, matched case-insensitively
|
||||||
|
// like visamaster and visamasterpay do.
|
||||||
|
const orderTypeSber = "sber"
|
||||||
|
|
||||||
|
var nameLabels = map[string]shared.LocalizedText{
|
||||||
|
NameCreate: {Tm: "Goşmak", Ru: "Создание", En: "Create"},
|
||||||
|
NameUpdate: {Tm: "Üýtgetmek", Ru: "Изменение", En: "Update"},
|
||||||
|
NameDelete: {Tm: "Pozmak", Ru: "Удаление", En: "Delete"},
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
sberTargetLabel = shared.LocalizedText{Tm: "Sber töleg (talyplar üçin)", Ru: "Оплата Sber (для студентов)", En: "Sber payment (for students)"}
|
||||||
|
visaMasterTargetLabel = shared.LocalizedText{Tm: "Visa/Master töleg (talyplar üçin)", Ru: "Оплата Visa/Master (для студентов)", En: "Visa/Master payment (for students)"}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NameLabel is the display name of an action name; unknown names fall
|
||||||
|
// back to the name itself.
|
||||||
|
func NameLabel(name string) shared.LocalizedText {
|
||||||
|
if label, ok := nameLabels[name]; ok {
|
||||||
|
return label
|
||||||
|
}
|
||||||
|
return shared.LocalizedText{Tm: name, Ru: name, En: name}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TargetLabel is the display name of the order an action was done to,
|
||||||
|
// by the order's (current) type.
|
||||||
|
func TargetLabel(orderType *string) shared.LocalizedText {
|
||||||
|
if orderType != nil && strings.EqualFold(strings.TrimSpace(*orderType), orderTypeSber) {
|
||||||
|
return sberTargetLabel
|
||||||
|
}
|
||||||
|
return visaMasterTargetLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderActionTargetDTO is the order an action was done to - Amalyň
|
||||||
|
// nyşany (targedi), e.g. "TB6312-14083 (Sber töleg (talyplar üçin))".
|
||||||
|
type OrderActionTargetDTO struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
UniqueId *string `json:"uniqueId"`
|
||||||
|
Type *string `json:"type"`
|
||||||
|
Label shared.LocalizedText `json:"label"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderActionDTO is one row of an order's "Ammallar" table. CreatedById is
|
||||||
|
// null (and CreatedByName empty) when no user started the action - the
|
||||||
|
// GBÜS callback finalizing a payment.
|
||||||
|
type OrderActionDTO struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
OrderId int64 `json:"orderId"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
NameLabel shared.LocalizedText `json:"nameLabel"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Target OrderActionTargetDTO `json:"target"`
|
||||||
|
CreatedById *int64 `json:"createdById"`
|
||||||
|
CreatedByName string `json:"createdByName"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderActionDetailDTO is a single action with what it changed - the list
|
||||||
|
// leaves these out so pages stay small. Original holds the changed
|
||||||
|
// columns' values before the action and Changes their values after (or,
|
||||||
|
// for a failed action, the values it attempted); either is null when
|
||||||
|
// there's nothing on that side (Original for a create, Changes for a
|
||||||
|
// delete).
|
||||||
|
type OrderActionDetailDTO struct {
|
||||||
|
OrderActionDTO
|
||||||
|
Original json.RawMessage `json:"original" swaggertype:"object"`
|
||||||
|
Changes json.RawMessage `json:"changes" swaggertype:"object"`
|
||||||
|
Exception *string `json:"exception"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListOrderActionDTO struct {
|
||||||
|
Count int64 `json:"count"`
|
||||||
|
Actions []OrderActionDTO `json:"actions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrderActionDTO is one action to record, written by the
|
||||||
|
// repositories that change orders (cards/visamaster, payment/visamasterpay)
|
||||||
|
// - never through the API.
|
||||||
|
type CreateOrderActionDTO struct {
|
||||||
|
OrderId int64
|
||||||
|
Name string
|
||||||
|
Status string
|
||||||
|
Original map[string]interface{}
|
||||||
|
Changes map[string]interface{}
|
||||||
|
Exception *string
|
||||||
|
CreatedBy *int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListFilter struct {
|
||||||
|
OrderId int64
|
||||||
|
Page int
|
||||||
|
Limit int
|
||||||
|
}
|
||||||
141
internal/cards/visamasteractions/handler.go
Normal file
141
internal/cards/visamasteractions/handler.go
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
package visamasteractions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"online-back/internal/appresult"
|
||||||
|
"online-back/internal/handlers"
|
||||||
|
"online-back/internal/identity/rbac"
|
||||||
|
"online-back/internal/identity/rbac/perm"
|
||||||
|
"online-back/internal/shared"
|
||||||
|
"online-back/pkg/logging"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/jackc/pgx/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
const baseURL = "/visa-master-payment-orders"
|
||||||
|
|
||||||
|
type handler struct {
|
||||||
|
logger *logging.Logger
|
||||||
|
repository Repository
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler {
|
||||||
|
return &handler{logger: logger, repository: repository}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register only wires read endpoints: actions are recorded by the
|
||||||
|
// repositories that change orders, never through the API. The group is
|
||||||
|
// its own /:id/actions prefix because rbac allows one policy per prefix
|
||||||
|
// and cards/visamaster already declares require:cards for baseURL.
|
||||||
|
func (h *handler) Register(router *gin.RouterGroup) {
|
||||||
|
group := rbac.Group(router, baseURL+"/:id/actions", rbac.RequireStaff(perm.Cards))
|
||||||
|
group.GET("", h.list)
|
||||||
|
group.GET("/:actionId", h.get)
|
||||||
|
}
|
||||||
|
|
||||||
|
// list godoc
|
||||||
|
// @Summary Sargydyň amallary (Ammallar)
|
||||||
|
// @Description Bir Visa/Master ýa-da Sber sargydynyň ähli amallaryny gaýtarýar: goşmak, üýtgetmek, pozmak (name/nameLabel), kim tarapyndan (createdByName), haýsy sargyt (target: uniqueId we label, mysal üçin "Sber töleg (talyplar üçin)"), statusy (finished ýa-da failed) we senesi. Tertip: iň täzesi birinji. Bellik: näme üýtgändigi (original/changes) we ýalňyşlyk (exception) /visa-master-payment-orders/{id}/actions/{actionId} salgysynda; töleg tamamlananda sargydyň status/paid üýtgemegi hem şu ýere ýazylýar, GBÜS callback-dan gelse createdById null.
|
||||||
|
// @Tags visa-master-order-actions
|
||||||
|
// @Produce json
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param page query int false "Sahypa belgisi" default(1)
|
||||||
|
// @Param limit query int false "Bir sahypadaky ýazgy sany" default(10)
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
|
// @Success 200 {object} ListOrderActionDTO
|
||||||
|
// @Failure 400 {object} appresult.AppError
|
||||||
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
// @Router /visa-master-payment-orders/{id}/actions [get]
|
||||||
|
func (h *handler) list(c *gin.Context) {
|
||||||
|
orderID, ok := shared.ParseID(c.Param("id"))
|
||||||
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
page, limit, ok := shared.ParsePageLimit(c)
|
||||||
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !h.guardOrder(c, orderID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := h.repository.List(c.Request.Context(), ListFilter{OrderId: orderID, Page: page, Limit: limit})
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Errorf("list visa master order actions failed (order %d): %v", orderID, err)
|
||||||
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
// get godoc
|
||||||
|
// @Summary Sargydyň bir amaly
|
||||||
|
// @Description Sargydyň bir amalyny näme üýtgändigi bilen gaýtarýar: original - üýtgän meýdanlaryň öňki bahalary (Asyl), changes - täze bahalary (Üýtgeşmeler), exception - şowsuz amalyň ýalňyşlygy. Tertip: ýeke ýazgy. Bellik: goşmakda original null we changes ähli meýdanlar, pozmakda original ähli meýdanlar we changes null; şowsuz amalda changes synanyşylan bahalar.
|
||||||
|
// @Tags visa-master-order-actions
|
||||||
|
// @Produce json
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param actionId path int true "Amalyň ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
|
// @Success 200 {object} OrderActionDetailDTO
|
||||||
|
// @Failure 400 {object} appresult.AppError
|
||||||
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
// @Router /visa-master-payment-orders/{id}/actions/{actionId} [get]
|
||||||
|
func (h *handler) get(c *gin.Context) {
|
||||||
|
orderID, ok := shared.ParseID(c.Param("id"))
|
||||||
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
actionID, ok := shared.ParseID(c.Param("actionId"))
|
||||||
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !h.guardOrder(c, orderID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
item, err := h.repository.GetByID(c.Request.Context(), orderID, actionID)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
|
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Errorf("get visa master order action failed (order %d, action %d): %v", orderID, actionID, err)
|
||||||
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, appresult.SuccessWithData(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *handler) guardOrder(c *gin.Context, orderID int64) bool {
|
||||||
|
if rbac.SkipRecordGuard(c) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
userID, branchID, err := h.repository.OwnerInfo(c.Request.Context(), orderID)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
|
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Errorf("visa master order actions owner lookup failed (order %d): %v", orderID, err)
|
||||||
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return rbac.GuardOrder(c, userID, branchID)
|
||||||
|
}
|
||||||
14
internal/cards/visamasteractions/storage.go
Normal file
14
internal/cards/visamasteractions/storage.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package visamasteractions
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
type Repository interface {
|
||||||
|
// OwnerInfo returns the order's owner/branch so the handler can run
|
||||||
|
// rbac.GuardOrder without importing cards/visamaster. Deleted orders
|
||||||
|
// are included: their actions stay readable.
|
||||||
|
OwnerInfo(ctx context.Context, orderID int64) (userID *int64, branchID int64, err error)
|
||||||
|
List(ctx context.Context, filter ListFilter) (ListOrderActionDTO, error)
|
||||||
|
// GetByID returns orderID's action actionID - pgx.ErrNoRows if it
|
||||||
|
// belongs to another order.
|
||||||
|
GetByID(ctx context.Context, orderID, actionID int64) (OrderActionDetailDTO, error)
|
||||||
|
}
|
||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param currency_to query string false "Filter by target currency"
|
// @Param currency_to query string false "Filter by target currency"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} ListCurrencyDTO
|
// @Success 200 {object} ListCurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Currency ID"
|
// @Param id path int true "Currency ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} CurrencyDTO
|
// @Success 200 {object} CurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -110,6 +112,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCurrencyDTO true "Currency rate payload"
|
// @Param body body CreateCurrencyDTO true "Currency rate payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} CurrencyDTO
|
// @Success 201 {object} CurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 409 {object} appresult.AppError
|
// @Failure 409 {object} appresult.AppError
|
||||||
@@ -147,6 +150,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Currency ID"
|
// @Param id path int true "Currency ID"
|
||||||
// @Param body body UpdateCurrencyDTO true "Currency rate payload"
|
// @Param body body UpdateCurrencyDTO true "Currency rate payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} CurrencyDTO
|
// @Success 200 {object} CurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -193,6 +197,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Currency ID"
|
// @Param id path int true "Currency ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param year query int false "Year for the monthly trend chart" default(current year)
|
// @Param year query int false "Year for the monthly trend chart" default(current year)
|
||||||
// @Param recent_limit query int false "Number of recent activity items to return" default(10)
|
// @Param recent_limit query int false "Number of recent activity items to return" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -75,6 +76,7 @@ func (h *handler) overview(c *gin.Context) {
|
|||||||
// @Tags dashboard
|
// @Tags dashboard
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess{data=sysstats.Stats}
|
// @Success 200 {object} appresult.AppSuccess{data=sysstats.Stats}
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /dashboard/server-stats [get]
|
// @Router /dashboard/server-stats [get]
|
||||||
|
|||||||
@@ -74,6 +74,19 @@ func New(cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) *gin.
|
|||||||
}
|
}
|
||||||
adminGroup.Use(rbac.Guard(rbac.NewService(client)))
|
adminGroup.Use(rbac.Guard(rbac.NewService(client)))
|
||||||
|
|
||||||
|
registerRoutes(router, adminGroup, cfg, client, logger)
|
||||||
|
|
||||||
|
// Deny by default: every admin route must declare its policy via rbac.Group.
|
||||||
|
if err := rbac.VerifyRoutes(router.Routes(), adminAPIPrefix); err != nil {
|
||||||
|
logger.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerRoutes has every bounded context register its handlers. rbac
|
||||||
|
// panics here if two groups declare different policies for one prefix.
|
||||||
|
func registerRoutes(router *gin.Engine, adminGroup *gin.RouterGroup, cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) {
|
||||||
// Each bounded context registers its own modules' handlers.
|
// Each bounded context registers its own modules' handlers.
|
||||||
// Add new modules inside the relevant context's router.go rather than here.
|
// Add new modules inside the relevant context's router.go rather than here.
|
||||||
identity.Register(adminGroup, router, client, logger)
|
identity.Register(adminGroup, router, client, logger)
|
||||||
@@ -94,13 +107,6 @@ func New(cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) *gin.
|
|||||||
logger,
|
logger,
|
||||||
)
|
)
|
||||||
backup.NewHandler(logger, backupSvc).Register(adminGroup)
|
backup.NewHandler(logger, backupSvc).Register(adminGroup)
|
||||||
|
|
||||||
// Deny by default: every admin route must declare its policy via rbac.Group.
|
|
||||||
if err := rbac.VerifyRoutes(router.Routes(), adminAPIPrefix); err != nil {
|
|
||||||
logger.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return router
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// paymentGatewayClient picks the real GBÜS client outside debug mode, and
|
// paymentGatewayClient picks the real GBÜS client outside debug mode, and
|
||||||
|
|||||||
29
internal/handlers/manager/manager_test.go
Normal file
29
internal/handlers/manager/manager_test.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package handlermanager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"online-back/internal/config"
|
||||||
|
"online-back/internal/identity/rbac"
|
||||||
|
"online-back/pkg/logging"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestRegisterRoutes registers every handler the way New does (no database:
|
||||||
|
// handlers only touch it per request), so a startup panic such as two
|
||||||
|
// groups declaring different policies for one prefix fails here instead
|
||||||
|
// of on the server.
|
||||||
|
func TestRegisterRoutes(t *testing.T) {
|
||||||
|
gin.SetMode(gin.TestMode)
|
||||||
|
debug := true
|
||||||
|
cfg := &config.Config{IsDebug: &debug}
|
||||||
|
|
||||||
|
router := gin.New()
|
||||||
|
adminGroup := router.Group(adminAPIPrefix)
|
||||||
|
registerRoutes(router, adminGroup, cfg, nil, logging.GetLogger())
|
||||||
|
|
||||||
|
if err := rbac.VerifyRoutes(router.Routes(), adminAPIPrefix); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param action query string false "Filter by action (create, update, delete)"
|
// @Param action query string false "Filter by action (create, update, delete)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -75,6 +76,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Activity log ID"
|
// @Param id path int true "Activity log ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body LoginDTO true "Login payload"
|
// @Param body body LoginDTO true "Login payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
@@ -91,6 +92,7 @@ func (h *handler) login(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body RegisterDTO true "Registration payload"
|
// @Param body body RegisterDTO true "Registration payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 409 {object} appresult.AppError
|
// @Failure 409 {object} appresult.AppError
|
||||||
@@ -118,6 +120,7 @@ func (h *handler) register(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body VerifyDTO true "Verification payload"
|
// @Param body body VerifyDTO true "Verification payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 409 {object} appresult.AppError
|
// @Failure 409 {object} appresult.AppError
|
||||||
@@ -145,6 +148,7 @@ func (h *handler) verify(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body ForgotPasswordDTO true "Forgot password payload"
|
// @Param body body ForgotPasswordDTO true "Forgot password payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -172,6 +176,7 @@ func (h *handler) forgotPassword(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body ResetPasswordDTO true "Reset password payload"
|
// @Param body body ResetPasswordDTO true "Reset password payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -217,6 +222,7 @@ func (h *handler) respondRegisterError(c *gin.Context, err error) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body RefreshTokenDTO true "Refresh token payload"
|
// @Param body body RefreshTokenDTO true "Refresh token payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
@@ -247,6 +253,7 @@ func (h *handler) refreshToken(c *gin.Context) {
|
|||||||
// @Tags auth
|
// @Tags auth
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
@@ -277,6 +284,7 @@ func (h *handler) getProfile(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body UpdateProfileDTO true "Profile payload"
|
// @Param body body UpdateProfileDTO true "Profile payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Tags permission
|
// @Tags permission
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Router /permissions [get]
|
// @Router /permissions [get]
|
||||||
func (h *handler) list(c *gin.Context) {
|
func (h *handler) list(c *gin.Context) {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param role_name query string false "Filter by name or code"
|
// @Param role_name query string false "Filter by name or code"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Role ID"
|
// @Param id path int true "Role ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -108,6 +110,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateRoleDTO true "Role payload"
|
// @Param body body CreateRoleDTO true "Role payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -151,6 +154,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Role ID"
|
// @Param id path int true "Role ID"
|
||||||
// @Param body body UpdateRoleDTO true "Role payload"
|
// @Param body body UpdateRoleDTO true "Role payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -202,6 +206,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Role ID"
|
// @Param id path int true "Role ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ func (h *handler) RegisterPublic(engine *gin.Engine) {
|
|||||||
// @Param username query string false "Alias for search"
|
// @Param username query string false "Alias for search"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -106,6 +107,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Param username query string false "Alias for search"
|
// @Param username query string false "Alias for search"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -137,6 +139,7 @@ func (h *handler) listClients(c *gin.Context) {
|
|||||||
// @Param username query string false "Alias for search"
|
// @Param username query string false "Alias for search"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -166,6 +169,7 @@ func (h *handler) listStaff(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -203,6 +207,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateUserDTO true "User payload"
|
// @Param body body CreateUserDTO true "User payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -242,6 +247,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
// @Param body body UpdateUserDTO true "User payload"
|
// @Param body body UpdateUserDTO true "User payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -303,6 +309,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
// @Param body body SetUserRoleDTO true "Role"
|
// @Param body body SetUserRoleDTO true "Role"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -364,6 +371,7 @@ func (h *handler) setRole(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -547,6 +555,7 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
|||||||
// @Param file formData file true "this is a test file"
|
// @Param file formData file true "this is a test file"
|
||||||
//
|
//
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -589,6 +598,7 @@ func (h *handler) fileUpload(c *gin.Context) {
|
|||||||
// @Tags file-upload
|
// @Tags file-upload
|
||||||
// @Produce octet-stream
|
// @Produce octet-stream
|
||||||
// @Param file_name path string true "object name"
|
// @Param file_name path string true "object name"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {file} binary
|
// @Success 200 {file} binary
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -631,6 +641,7 @@ func (h *handler) getFile(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id path string true "object name"
|
// @Param id path string true "object name"
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /file/{id} [delete]
|
// @Router /file/{id} [delete]
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateUserBranchDTO true "Branch-user payload"
|
// @Param body body CreateUserBranchDTO true "Branch-user payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -72,6 +73,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch-user ID"
|
// @Param id path int true "Branch-user ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -108,6 +110,7 @@ func (h *handler) respondList(c *gin.Context, filter ListFilter) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan order ID"
|
// @Param id path int true "Loan order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -145,6 +148,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanOrderDTO true "Loan order payload"
|
// @Param body body CreateLoanOrderDTO true "Loan order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -179,6 +183,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan order ID"
|
// @Param id path int true "Loan order ID"
|
||||||
// @Param body body UpdateLoanOrderDTO true "Loan order payload"
|
// @Param body body UpdateLoanOrderDTO true "Loan order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -222,6 +227,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan order ID"
|
// @Param id path int true "Loan order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -80,6 +81,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param province_id query int true "Province ID"
|
// @Param province_id query int true "Province ID"
|
||||||
// @Param active query bool false "Only active branches" default(true)
|
// @Param active query bool false "Only active branches" default(true)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -118,6 +120,7 @@ func (h *handler) listBranchesByProvince(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan paid off letter ID"
|
// @Param id path int true "Loan paid off letter ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -155,6 +158,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanPaidLetterDTO true "Loan paid off letter payload"
|
// @Param body body CreateLoanPaidLetterDTO true "Loan paid off letter payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -185,6 +189,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan paid off letter ID"
|
// @Param id path int true "Loan paid off letter ID"
|
||||||
// @Param body body UpdateLoanPaidLetterDTO true "Loan paid off letter payload"
|
// @Param body body UpdateLoanPaidLetterDTO true "Loan paid off letter payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -228,6 +233,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan paid off letter ID"
|
// @Param id path int true "Loan paid off letter ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param active query bool false "Filter by active"
|
// @Param active query bool false "Filter by active"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -110,6 +112,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanDocumentDTO true "Loan document payload"
|
// @Param body body CreateLoanDocumentDTO true "Loan document payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -140,6 +143,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
// @Param body body UpdateLoanDocumentDTO true "Loan document payload"
|
// @Param body body UpdateLoanDocumentDTO true "Loan document payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -181,6 +185,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
// @Param body body UpdateLoanDocumentActiveDTO true "Active payload"
|
// @Param body body UpdateLoanDocumentActiveDTO true "Active payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -220,6 +225,7 @@ func (h *handler) updateActive(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param passport_id query string false "Filter by passport ID"
|
// @Param passport_id query string false "Filter by passport ID"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan repayment ID"
|
// @Param id path int true "Loan repayment ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -111,6 +113,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanRepaymentDTO true "Loan repayment payload"
|
// @Param body body CreateLoanRepaymentDTO true "Loan repayment payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -141,6 +144,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan repayment ID"
|
// @Param id path int true "Loan repayment ID"
|
||||||
// @Param body body UpdateLoanRepaymentDTO true "Loan repayment payload"
|
// @Param body body UpdateLoanRepaymentDTO true "Loan repayment payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -184,6 +188,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan repayment ID"
|
// @Param id path int true "Loan repayment ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param loan_type_name query string false "Filter by title (en, ru, tm)"
|
// @Param loan_type_name query string false "Filter by title (en, ru, tm)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan type ID"
|
// @Param id path int true "Loan type ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -108,6 +110,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanTypeDTO true "Loan type payload"
|
// @Param body body CreateLoanTypeDTO true "Loan type payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -138,6 +141,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan type ID"
|
// @Param id path int true "Loan type ID"
|
||||||
// @Param body body UpdateLoanTypeDTO true "Loan type payload"
|
// @Param body body UpdateLoanTypeDTO true "Loan type payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -177,6 +181,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan type ID"
|
// @Param id path int true "Loan type ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param unique_code query string false "Filter by unique code"
|
// @Param unique_code query string false "Filter by unique code"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -81,6 +82,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param active query bool false "Only active provinces" default(true)
|
// @Param active query bool false "Only active provinces" default(true)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -110,6 +112,7 @@ func (h *handler) listRegions(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param region query string true "Region name (en, ru or tm)"
|
// @Param region query string true "Region name (en, ru or tm)"
|
||||||
// @Param active query bool false "Only active etraps" default(true)
|
// @Param active query bool false "Only active etraps" default(true)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -144,6 +147,7 @@ func (h *handler) listEtraps(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch ID"
|
// @Param id path int true "Branch ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -184,6 +188,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateBranchDTO true "Branch payload"
|
// @Param body body CreateBranchDTO true "Branch payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -218,6 +223,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch ID"
|
// @Param id path int true "Branch ID"
|
||||||
// @Param body body UpdateBranchDTO true "Branch payload"
|
// @Param body body UpdateBranchDTO true "Branch payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -261,6 +267,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch ID"
|
// @Param id path int true "Branch ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param active query bool false "Filter by active status"
|
// @Param active query bool false "Filter by active status"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -79,6 +80,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Province ID"
|
// @Param id path int true "Province ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -113,6 +115,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateProvinceDTO true "Province payload"
|
// @Param body body CreateProvinceDTO true "Province payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -143,6 +146,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Province ID"
|
// @Param id path int true "Province ID"
|
||||||
// @Param body body UpdateProvinceDTO true "Province payload"
|
// @Param body body UpdateProvinceDTO true "Province payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -182,6 +186,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Province ID"
|
// @Param id path int true "Province ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -31,27 +31,27 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
|
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
|
||||||
group.GET("", h.list)
|
group.GET("", h.list)
|
||||||
group.GET("/payments/:id", h.get)
|
group.GET("/payments/:id", h.get)
|
||||||
group.GET("/payments/:id/gateway", h.gateway)
|
|
||||||
group.GET("/:id/gateway", h.gateway)
|
group.GET("/:id/gateway", h.gateway)
|
||||||
group.GET("/:id", h.orderPayments)
|
group.GET("/:id", h.orderPayments)
|
||||||
group.GET("/:id/logs", h.logs)
|
group.GET("/:id/logs", h.logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// list godoc
|
// list godoc
|
||||||
// @Summary List payment history
|
// @Summary Tölegleriň taryhy
|
||||||
// @Description Returns a paginated, branch-scoped audit trail of visa/master/sber payout attempts (paid, failed, or pending), across orders
|
// @Description Ähli sargytlaryň Visa/Master we Sber töleg synanyşyklaryny (tölenen, şowsuz, garaşylýan) sahypalap gaýtarýar. Tertip: sort/order boýunça (adaty ýagdaýda iň täzesi birinji). Bellik: diňe ulanyjynyň öz şahamçasynyň tölegleri görünýär.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param order_id query int false "Filter by order ID"
|
// @Param order_id query int false "Sargyt ID-si boýunça süzmek"
|
||||||
// @Param branch_id query int false "Filter by branch ID"
|
// @Param branch_id query int false "Şahamça ID-si boýunça süzmek"
|
||||||
// @Param user_id query int false "Filter by order owner (client) user ID"
|
// @Param user_id query int false "Sargyt eýesiniň (müşderiniň) ulanyjy ID-si boýunça süzmek"
|
||||||
// @Param status query string false "Filter by gateway status (pending, success, failed)"
|
// @Param status query string false "GBÜS statusy boýunça süzmek (pending, success, failed)"
|
||||||
// @Param search query string false "Filter by passport name/surname or order unique ID"
|
// @Param search query string false "Pasport ady/familiýasy ýa-da sargydyň unique ID-si boýunça gözlemek"
|
||||||
// @Param sort query string false "Sort column" Enums(id, created_at, status, amount) default(id)
|
// @Param sort query string false "Tertiplenýän sütün" Enums(id, created_at, status, amount) default(id)
|
||||||
// @Param order query string false "Sort direction" Enums(asc, desc) default(desc)
|
// @Param order query string false "Tertip ugry" Enums(asc, desc) default(desc)
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Sahypa belgisi" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Bir sahypadaky ýazgy sany" default(10)
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} ListPaymentHistoryDTO
|
// @Success 200 {object} ListPaymentHistoryDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,12 +74,13 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get godoc
|
// get godoc
|
||||||
// @Summary Get a single payment attempt
|
// @Summary Bir tölegiň jikme-jikligi
|
||||||
// @Description Returns one visa/master/sber payout attempt by its payment ID, with the raw GBÜS response - the detail view behind a payment-history list row
|
// @Description Töleg ID-si boýunça bir Visa/Master ýa-da Sber töleg synanyşygyny GBÜS-iň soňky jogaby (gatewayResponse) bilen gaýtarýar. Tertip: ýeke ýazgy. Bellik: taryh sanawyndaky bir setiriň jikme-jik görnüşi.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment ID"
|
// @Param id path int true "Töleg ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentHistoryDetailDTO
|
// @Success 200 {object} PaymentHistoryDetailDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -111,18 +112,18 @@ func (h *handler) get(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gateway godoc
|
// gateway godoc
|
||||||
// @Summary List an order's payments with their HALKBANK responses
|
// @Summary Sargydyň tölegleri GBÜS jogaplary bilen
|
||||||
// @Description Returns every payment of one order, newest first, the way the per-order payment table shows them - paid or not, the card it was paid from (cardholderName/maskedPan, null until GBÜS reports them), its time (createdAt), payment year/month, amounts and reference (orderNumber) - each together with the last GBÜS (HALKBANK) response stored for it (gatewayResponse, null if GBÜS never answered). Backs the table's storage icon.
|
// @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.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Order ID"
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {array} PaymentGatewayDTO
|
// @Success 200 {array} PaymentGatewayDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-history/payments/{id}/gateway [get]
|
|
||||||
// @Router /payment-history/{id}/gateway [get]
|
// @Router /payment-history/{id}/gateway [get]
|
||||||
func (h *handler) gateway(c *gin.Context) {
|
func (h *handler) gateway(c *gin.Context) {
|
||||||
orderID, ok := shared.ParseID(c.Param("id"))
|
orderID, ok := shared.ParseID(c.Param("id"))
|
||||||
@@ -150,12 +151,13 @@ func (h *handler) gateway(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// orderPayments godoc
|
// orderPayments godoc
|
||||||
// @Summary List an order's payments
|
// @Summary Sargydyň tölegleri
|
||||||
// @Description Returns every visa/master/sber payout attempt of one order, newest first - one row per payment with whether it was paid (paid/gatewayStatus), the card it was paid from (cardholderName/maskedPan, once GBÜS reports them), its time (createdAt) and period (paymentPeriod). The raw GBÜS response of a row is at /payment-history/payments/{id}, of every row at once at /payment-history/{id}/gateway; the step-by-step logs are at /payment-history/{id}/logs.
|
// @Description Bir sargydyň ähli Visa/Master we Sber töleg synanyşyklaryny gaýtarýar: her töleg üçin bir setir - tölendimi (paid/gatewayStatus), haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt) we döwri (paymentPeriod). Tertip: iň täzesi birinji. Bellik: bir tölegiň GBÜS jogaby /payment-history/payments/{id}, ähli tölegleriňki /payment-history/{id}/gateway, ädimme-ädim loglar /payment-history/{id}/logs salgysynda.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Order ID"
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {array} PaymentHistoryItemDTO
|
// @Success 200 {array} PaymentHistoryItemDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -184,12 +186,13 @@ func (h *handler) orderPayments(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// logs godoc
|
// logs godoc
|
||||||
// @Summary Get payment logs for an order
|
// @Summary Sargydyň töleg loglary
|
||||||
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout, newest first - evidence of what actually happened, independent of the summary rows returned by /payment-history/{id}
|
// @Description Sargydyň tölegi işlenende ýazylan ähli ädimleri (visa_master_payment_logs) gaýtarýar. Tertip: iň täzesi birinji. Bellik: /payment-history/{id} setirlerinden garaşsyz, hakykatda näme bolandygynyň subutnamasy.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Order ID"
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {array} PaymentLogDTO
|
// @Success 200 {array} PaymentLogDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ func gatewayRequest(t *testing.T, repo Repository, path string) *httptest.Respon
|
|||||||
router.Use(func(c *gin.Context) {
|
router.Use(func(c *gin.Context) {
|
||||||
c.Set("rbacPrincipal", &rbac.Principal{UserID: 1, Scope: rbac.ScopeAll})
|
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()
|
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
|
return rec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Tags payment-settings
|
// @Tags payment-settings
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentSettingsDTO
|
// @Success 200 {object} PaymentSettingsDTO
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-settings [get]
|
// @Router /payment-settings [get]
|
||||||
@@ -58,6 +59,7 @@ func (h *handler) get(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body UpdatePaymentSettingsDTO true "Payment settings payload"
|
// @Param body body UpdatePaymentSettingsDTO true "Payment settings payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentSettingsDTO
|
// @Success 200 {object} PaymentSettingsDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param search query string false "Filter by code, name or text"
|
// @Param search query string false "Filter by code, name or text"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} ListPaymentTextDTO
|
// @Success 200 {object} ListPaymentTextDTO
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-texts [get]
|
// @Router /payment-texts [get]
|
||||||
@@ -77,6 +78,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param code path string true "Text code"
|
// @Param code path string true "Text code"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentTextDTO
|
// @Success 200 {object} PaymentTextDTO
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -119,6 +121,7 @@ func (h *handler) getByCode(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param code path string true "Text code"
|
// @Param code path string true "Text code"
|
||||||
// @Param body body UpdatePaymentTextDTO true "Payment text payload"
|
// @Param body body UpdatePaymentTextDTO true "Payment text payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentTextDTO
|
// @Success 200 {object} PaymentTextDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -156,6 +159,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param code path string true "Text code"
|
// @Param code path string true "Text code"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"online-back/internal/cards/visamasteractions"
|
||||||
|
actionsdb "online-back/internal/cards/visamasteractions/db"
|
||||||
"online-back/internal/currency"
|
"online-back/internal/currency"
|
||||||
"online-back/internal/payment/paymentsettings"
|
"online-back/internal/payment/paymentsettings"
|
||||||
"online-back/internal/payment/visamasterpay"
|
"online-back/internal/payment/visamasterpay"
|
||||||
@@ -30,7 +32,7 @@ const orderTypeSber = "sber"
|
|||||||
|
|
||||||
const paymentReturningColumns = `id, order_id, order_number, payment_period, exchange_rate_usd, exchange_rate_rub, amount_tmt,
|
const paymentReturningColumns = `id, order_id, order_number, payment_period, exchange_rate_usd, exchange_rate_rub, amount_tmt,
|
||||||
bank_fee_tmt, gbus_fee_tmt, tveb_fee_usd, tveb_fee_tmt, total_amount_tmt,
|
bank_fee_tmt, gbus_fee_tmt, tveb_fee_usd, tveb_fee_tmt, total_amount_tmt,
|
||||||
gateway_status, gateway_reference, created_at, updated_at`
|
gateway_status, gateway_reference, gateway_response, created_at, updated_at`
|
||||||
|
|
||||||
type repository struct {
|
type repository struct {
|
||||||
client postgresql.Client
|
client postgresql.Client
|
||||||
@@ -306,10 +308,17 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
var gatewayStatus string
|
var gatewayStatus string
|
||||||
var gatewayReference *string
|
var gatewayReference *string
|
||||||
var createdBy *int64
|
var createdBy *int64
|
||||||
|
// staleFailure flags a row finalized as failed while GBÜS still reported
|
||||||
|
// it in progress (checked before the card was even entered, by code
|
||||||
|
// predating StatusResult.InProgress) - it is re-checked like a pending one.
|
||||||
|
var staleFailure bool
|
||||||
err := r.client.QueryRow(ctx,
|
err := r.client.QueryRow(ctx,
|
||||||
`SELECT order_id, gateway_status, gateway_reference, created_by FROM visa_master_order_payments WHERE id = $1 AND deleted_at IS NULL`,
|
`SELECT order_id, gateway_status, gateway_reference, created_by,
|
||||||
|
COALESCE(gateway_status = 'failed' AND gateway_response->>'orderStatus' IN ('0', '1', '5')
|
||||||
|
AND COALESCE(gateway_response->>'errorCode', '0') IN ('', '0'), false)
|
||||||
|
FROM visa_master_order_payments WHERE id = $1 AND deleted_at IS NULL`,
|
||||||
paymentID,
|
paymentID,
|
||||||
).Scan(&orderID, &gatewayStatus, &gatewayReference, &createdBy)
|
).Scan(&orderID, &gatewayStatus, &gatewayReference, &createdBy, &staleFailure)
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
// Unknown payment id: there's no order to attach a log row to.
|
// Unknown payment id: there's no order to attach a log row to.
|
||||||
return visamasterpay.PaymentResultDTO{}, visamasterpay.ErrPaymentNotFound
|
return visamasterpay.PaymentResultDTO{}, visamasterpay.ErrPaymentNotFound
|
||||||
@@ -354,7 +363,7 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
if gatewayStatus != "pending" {
|
if gatewayStatus != "pending" && !staleFailure {
|
||||||
item, err := fetchPaymentByID(ctx, r.client, paymentID)
|
item, err := fetchPaymentByID(ctx, r.client, paymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail("load_payment", err)
|
fail("load_payment", err)
|
||||||
@@ -402,32 +411,68 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
defer tx.Rollback(ctx)
|
defer tx.Rollback(ctx)
|
||||||
|
|
||||||
var lockedPaid bool
|
var lockedPaid bool
|
||||||
if err := tx.QueryRow(ctx, `SELECT paid FROM visa_master_payment_orders WHERE id = $1 FOR UPDATE`, orderID).Scan(&lockedPaid); err != nil {
|
var lockedStatus *string
|
||||||
|
if err := tx.QueryRow(ctx, `SELECT paid, status FROM visa_master_payment_orders WHERE id = $1 FOR UPDATE`, orderID).Scan(&lockedPaid, &lockedStatus); err != nil {
|
||||||
fail("finalize_lock_order", err)
|
fail("finalize_lock_order", err)
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
|
// orderAction is the order's update action once it is marked paid,
|
||||||
|
// recorded only after the commit (or as failed if it never lands):
|
||||||
|
// recording it must never hold up finalizing a payment GBÜS has
|
||||||
|
// already taken.
|
||||||
|
var orderAction *visamasteractions.CreateOrderActionDTO
|
||||||
|
failFinalize := func(stage string, err error) {
|
||||||
|
fail(stage, err)
|
||||||
|
if orderAction != nil {
|
||||||
|
exception := err.Error()
|
||||||
|
orderAction.Status, orderAction.Exception = visamasteractions.StatusFailed, &exception
|
||||||
|
r.recordOrderAction(ctx, *orderAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
if lockedPaid {
|
if lockedPaid {
|
||||||
step("order_already_marked_paid", nil)
|
step("order_already_marked_paid", nil)
|
||||||
} else {
|
} else {
|
||||||
|
original, changes := visamasteractions.Diff(
|
||||||
|
map[string]interface{}{"paid": false, "status": derefOrNil(lockedStatus)},
|
||||||
|
map[string]interface{}{"paid": true, "status": "completed"},
|
||||||
|
)
|
||||||
|
orderAction = &visamasteractions.CreateOrderActionDTO{
|
||||||
|
OrderId: orderID, Name: visamasteractions.NameUpdate, Status: visamasteractions.StatusFinished,
|
||||||
|
Original: original, Changes: changes, CreatedBy: requestedBy,
|
||||||
|
}
|
||||||
if _, err := tx.Exec(ctx,
|
if _, err := tx.Exec(ctx,
|
||||||
`UPDATE visa_master_payment_orders SET paid = true, status = 'completed', updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') WHERE id = $1`,
|
`UPDATE visa_master_payment_orders SET paid = true, status = 'completed', updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') WHERE id = $1`,
|
||||||
orderID,
|
orderID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
fail("finalize_mark_order_paid", err)
|
failFinalize("finalize_mark_order_paid", err)
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item, err = updatePaymentStatus(ctx, tx, paymentID, "success", status.RawResponse)
|
item, err = updatePaymentStatus(ctx, tx, paymentID, "success", status.RawResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail("finalize_save_payment_status", err)
|
failFinalize("finalize_save_payment_status", err)
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tx.Commit(ctx); err != nil {
|
if err := tx.Commit(ctx); err != nil {
|
||||||
fail("finalize_commit", err)
|
failFinalize("finalize_commit", err)
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
|
if orderAction != nil {
|
||||||
|
r.recordOrderAction(ctx, *orderAction)
|
||||||
|
}
|
||||||
|
} else if status.InProgress() {
|
||||||
|
// Not paid yet but not over either (e.g. checked before the card was
|
||||||
|
// entered): keep it pending so a later callback/Status re-checks it,
|
||||||
|
// storing the response so the card shows up once GBÜS reports it.
|
||||||
|
item, err = updatePaymentStatus(ctx, r.client, paymentID, "pending", status.RawResponse)
|
||||||
|
if err != nil {
|
||||||
|
fail("save_payment_status", err)
|
||||||
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
|
}
|
||||||
|
step("payment_still_pending", map[string]interface{}{"orderStatus": status.OrderStatus, "actionCode": status.ActionCode})
|
||||||
|
return finish(item), nil
|
||||||
} else {
|
} else {
|
||||||
item, err = updatePaymentStatus(ctx, r.client, paymentID, "failed", status.RawResponse)
|
item, err = updatePaymentStatus(ctx, r.client, paymentID, "failed", status.RawResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -446,7 +491,8 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
// HandleCallback does - for when the frontend can't rely on GBÜS's redirect
|
// HandleCallback does - for when the frontend can't rely on GBÜS's redirect
|
||||||
// having reached the callback (e.g. the user closed the hosted payment page
|
// having reached the callback (e.g. the user closed the hosted payment page
|
||||||
// first). Safe to call repeatedly: it only hits GBÜS while the attempt is
|
// first). Safe to call repeatedly: it only hits GBÜS while the attempt is
|
||||||
// still "pending" and otherwise just returns the already-finalized row.
|
// still "pending" (or a stale failure, see verifyPayment) and otherwise
|
||||||
|
// just returns the already-finalized row.
|
||||||
func (r *repository) Status(ctx context.Context, orderID int64, requestedBy *int64) (visamasterpay.PaymentResultDTO, error) {
|
func (r *repository) Status(ctx context.Context, orderID int64, requestedBy *int64) (visamasterpay.PaymentResultDTO, error) {
|
||||||
var paymentID int64
|
var paymentID int64
|
||||||
err := r.client.QueryRow(ctx,
|
err := r.client.QueryRow(ctx,
|
||||||
@@ -464,6 +510,15 @@ func (r *repository) Status(ctx context.Context, orderID int64, requestedBy *int
|
|||||||
return r.verifyPayment(ctx, paymentID, "status", requestedBy)
|
return r.verifyPayment(ctx, paymentID, "status", requestedBy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// recordOrderAction records an order action ("Ammallar") of finalizing a
|
||||||
|
// payment through the plain client. Best-effort, like logStep: a write
|
||||||
|
// failure is logged, not propagated.
|
||||||
|
func (r *repository) recordOrderAction(ctx context.Context, dto visamasteractions.CreateOrderActionDTO) {
|
||||||
|
if err := actionsdb.Insert(context.WithoutCancel(ctx), r.client, dto); err != nil && r.logger != nil {
|
||||||
|
r.logger.Errorf("visa master order action write failed (order %d, %s %s): %v", dto.OrderId, dto.Name, dto.Status, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// branchCredentials picks the sber or visa/master MPI merchant credentials
|
// branchCredentials picks the sber or visa/master MPI merchant credentials
|
||||||
// for a branch, matching the type of order being paid.
|
// for a branch, matching the type of order being paid.
|
||||||
func (r *repository) branchCredentials(ctx context.Context, branchID int64, sber bool) (username, password string, err error) {
|
func (r *repository) branchCredentials(ctx context.Context, branchID int64, sber bool) (username, password string, err error) {
|
||||||
@@ -508,6 +563,15 @@ func isSber(orderType *string) bool {
|
|||||||
return orderType != nil && strings.EqualFold(strings.TrimSpace(*orderType), orderTypeSber)
|
return orderType != nil && strings.EqualFold(strings.TrimSpace(*orderType), orderTypeSber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// derefOrNil keeps a null column null in an action's original values
|
||||||
|
// rather than turning it into a typed nil pointer.
|
||||||
|
func derefOrNil(s *string) interface{} {
|
||||||
|
if s == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return *s
|
||||||
|
}
|
||||||
|
|
||||||
func derefOrEmpty(s *string) string {
|
func derefOrEmpty(s *string) string {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return ""
|
return ""
|
||||||
@@ -643,8 +707,9 @@ func updatePaymentGatewayResult(ctx context.Context, q execer, paymentID int64,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// updatePaymentStatus records the verified final outcome (from
|
// updatePaymentStatus records a verified getOrderStatusExtended.do outcome
|
||||||
// HandleCallback) and returns the updated row.
|
// (from HandleCallback/Status) - final, or still pending - and returns the
|
||||||
|
// updated row.
|
||||||
func updatePaymentStatus(ctx context.Context, q querier, paymentID int64, status string, response []byte) (visamasterpay.PaymentResultDTO, error) {
|
func updatePaymentStatus(ctx context.Context, q querier, paymentID int64, status string, response []byte) (visamasterpay.PaymentResultDTO, error) {
|
||||||
query := `
|
query := `
|
||||||
UPDATE visa_master_order_payments SET gateway_status = $1, gateway_response = $2,
|
UPDATE visa_master_order_payments SET gateway_status = $1, gateway_response = $2,
|
||||||
@@ -665,10 +730,13 @@ func scanPayment(row pgx.Row) (visamasterpay.PaymentResultDTO, error) {
|
|||||||
if err := row.Scan(
|
if err := row.Scan(
|
||||||
&item.Id, &item.OrderId, &item.OrderNumber, &item.PaymentPeriod, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.AmountTmt,
|
&item.Id, &item.OrderId, &item.OrderNumber, &item.PaymentPeriod, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.AmountTmt,
|
||||||
&item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
|
&item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
|
||||||
&item.GatewayStatus, &item.GatewayReference, &item.CreatedAt, &item.UpdatedAt,
|
&item.GatewayStatus, &item.GatewayReference, &item.GatewayResponse, &item.CreatedAt, &item.UpdatedAt,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
|
if len(item.GatewayResponse) == 0 {
|
||||||
|
item.GatewayResponse = json.RawMessage("null")
|
||||||
|
}
|
||||||
return item, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package visamasterpay
|
package visamasterpay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"online-back/internal/shared"
|
"online-back/internal/shared"
|
||||||
@@ -69,25 +70,28 @@ type CallbackResultDTO struct {
|
|||||||
// as its own row in visa_master_order_payments (a full audit trail -
|
// as its own row in visa_master_order_payments (a full audit trail -
|
||||||
// failed attempts are kept, not overwritten by a retry) - deliberately not
|
// failed attempts are kept, not overwritten by a retry) - deliberately not
|
||||||
// the full order+branch+user DTO owned by cards/visamaster (fetch that
|
// the full order+branch+user DTO owned by cards/visamaster (fetch that
|
||||||
// separately via GET /visa-master-payment-orders/:id).
|
// separately via GET /visa-master-payment-orders/:id). GatewayResponse is
|
||||||
|
// the last GBÜS response stored for the attempt (null if GBÜS never
|
||||||
|
// answered).
|
||||||
type PaymentResultDTO struct {
|
type PaymentResultDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
OrderId int64 `json:"orderId"`
|
OrderId int64 `json:"orderId"`
|
||||||
OrderNumber string `json:"orderNumber"`
|
OrderNumber string `json:"orderNumber"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Paid bool `json:"paid"`
|
Paid bool `json:"paid"`
|
||||||
AmountUsd float64 `json:"amountUsd"`
|
AmountUsd float64 `json:"amountUsd"`
|
||||||
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
||||||
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
||||||
AmountTmt float64 `json:"amountTmt"`
|
AmountTmt float64 `json:"amountTmt"`
|
||||||
BankFeeTmt float64 `json:"bankFeeTmt"`
|
BankFeeTmt float64 `json:"bankFeeTmt"`
|
||||||
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
||||||
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
||||||
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
||||||
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
||||||
PaymentPeriod time.Time `json:"paymentPeriod"`
|
PaymentPeriod time.Time `json:"paymentPeriod"`
|
||||||
GatewayStatus string `json:"gatewayStatus"`
|
GatewayStatus string `json:"gatewayStatus"`
|
||||||
GatewayReference *string `json:"gatewayReference,omitempty"`
|
GatewayReference *string `json:"gatewayReference,omitempty"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// quote godoc
|
// quote godoc
|
||||||
// @Summary Quote a visa/master/sber payment
|
// @Summary Quote a visa/master/sber payment
|
||||||
// @Description Returns the current rate, configured fees, and max payable amount for an order's payout
|
// @Description Returns the current rate, configured fees, and max payable amount for an order's payout
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentQuoteDTO
|
// @Success 200 {object} PaymentQuoteDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -71,12 +72,13 @@ func (h *handler) quote(c *gin.Context) {
|
|||||||
// pay godoc
|
// pay godoc
|
||||||
// @Summary Start a visa/master/sber payout
|
// @Summary Start a visa/master/sber payout
|
||||||
// @Description Registers the payment with GBÜS and returns the hosted-payment-page URL to complete it on. The final outcome is only known once GBÜS redirects back to the callback, which verifies and finalizes it.
|
// @Description Registers the payment with GBÜS and returns the hosted-payment-page URL to complete it on. The final outcome is only known once GBÜS redirects back to the callback, which verifies and finalizes it.
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
// @Param body body PayOrderDTO true "Payment payload"
|
// @Param body body PayOrderDTO true "Payment payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentInitResultDTO
|
// @Success 200 {object} PaymentInitResultDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -112,11 +114,12 @@ func (h *handler) pay(c *gin.Context) {
|
|||||||
|
|
||||||
// status godoc
|
// status godoc
|
||||||
// @Summary Re-check a visa/master/sber order's latest payment attempt
|
// @Summary Re-check a visa/master/sber order's latest payment attempt
|
||||||
// @Description For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. Safe to call repeatedly.
|
// @Description For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. gatewayResponse is GBÜS's last stored response for the attempt (null if GBÜS never answered). Safe to call repeatedly.
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentResultDTO
|
// @Success 200 {object} PaymentResultDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -149,9 +152,10 @@ func (h *handler) status(c *gin.Context) {
|
|||||||
// callback godoc
|
// callback godoc
|
||||||
// @Summary GBÜS payment callback
|
// @Summary GBÜS payment callback
|
||||||
// @Description GBÜS redirects the browser here after payment; the real outcome is verified server-to-server before anything is finalized
|
// @Description GBÜS redirects the browser here after payment; the real outcome is verified server-to-server before anything is finalized
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param paymentId query int true "Payment attempt ID"
|
// @Param paymentId query int true "Payment attempt ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} CallbackResultDTO
|
// @Success 200 {object} CallbackResultDTO
|
||||||
// @Router /visa-master-payment-orders/callback [get]
|
// @Router /visa-master-payment-orders/callback [get]
|
||||||
func (h *handler) callback(c *gin.Context) {
|
func (h *handler) callback(c *gin.Context) {
|
||||||
|
|||||||
@@ -58,6 +58,17 @@ type StatusResult struct {
|
|||||||
RawResponse []byte
|
RawResponse []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InProgress reports an unpaid order GBÜS may still complete - registered
|
||||||
|
// but not attempted yet (0), pre-authorized (1) or in 3-D Secure (5) - so
|
||||||
|
// it must stay re-checkable instead of being finalized as failed. Reversed
|
||||||
|
// (3), refunded (4), declined (6) or any gateway error are final.
|
||||||
|
func (r StatusResult) InProgress() bool {
|
||||||
|
if r.ErrorCode != "" && r.ErrorCode != "0" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return r.OrderStatus == 0 || r.OrderStatus == 1 || r.OrderStatus == 5
|
||||||
|
}
|
||||||
|
|
||||||
// Client is the gateway contract. Plug a real HTTPClient in once
|
// Client is the gateway contract. Plug a real HTTPClient in once
|
||||||
// credentials are configured; LogClient is a stand-in for local/dev use.
|
// credentials are configured; LogClient is a stand-in for local/dev use.
|
||||||
type Client interface {
|
type Client interface {
|
||||||
|
|||||||
@@ -27,6 +27,27 @@ func TestRegisterResultSuccess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStatusResultInProgress(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
r StatusResult
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"registered, not attempted", StatusResult{OrderStatus: 0, ErrorCode: "0"}, true},
|
||||||
|
{"pre-authorized", StatusResult{OrderStatus: 1}, true},
|
||||||
|
{"3-D Secure", StatusResult{OrderStatus: 5, ErrorCode: "0"}, true},
|
||||||
|
{"paid", StatusResult{Paid: true, OrderStatus: 2}, false},
|
||||||
|
{"reversed", StatusResult{OrderStatus: 3}, false},
|
||||||
|
{"declined", StatusResult{OrderStatus: 6, ErrorCode: "0"}, false},
|
||||||
|
{"gateway error", StatusResult{OrderStatus: 0, ErrorCode: "6"}, false},
|
||||||
|
}
|
||||||
|
for _, c := range cases {
|
||||||
|
if got := c.r.InProgress(); got != c.want {
|
||||||
|
t.Errorf("%s: InProgress()=%v want %v", c.name, got, c.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLogClientAlwaysPaid(t *testing.T) {
|
func TestLogClientAlwaysPaid(t *testing.T) {
|
||||||
c := NewLogClient(nil)
|
c := NewLogClient(nil)
|
||||||
reg, err := c.Register(context.Background(), RegisterRequest{OrderNumber: "vmo-1-2", ReturnURL: "https://x/cb"})
|
reg, err := c.Register(context.Background(), RegisterRequest{OrderNumber: "vmo-1-2", ReturnURL: "https://x/cb"})
|
||||||
@@ -74,8 +95,8 @@ func TestHTTPClientCheckStatusPaidMapping(t *testing.T) {
|
|||||||
body string
|
body string
|
||||||
paid bool
|
paid bool
|
||||||
}{
|
}{
|
||||||
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
|
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
|
||||||
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
|
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
|
||||||
{`{"orderStatus":6,"actionCode":"declined"}`, false},
|
{`{"orderStatus":6,"actionCode":"declined"}`, false},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|||||||
Reference in New Issue
Block a user