change table column name

This commit is contained in:
guwandyk committed 2026-07-07 15:16:40 +05:00
1 parent ef56625321
commit 41471694d5
11 files changed
+318 -334

No files matched your search

+2 -2
View File
@@ -1,7 +1,7 @@
DROP TABLE IF EXISTS loan_order_required_docs; DROP TABLE IF EXISTS loan_order_required_docs;
DROP TABLE IF EXISTS loan_types; DROP TABLE IF EXISTS loan_types;
DROP TABLE IF EXISTS reasons_cards; DROP TABLE IF EXISTS card_states;
DROP TABLE IF EXISTS payment_cards; DROP TABLE IF EXISTS card_types;
DROP TABLE IF EXISTS branches; DROP TABLE IF EXISTS branches;
DROP TABLE IF EXISTS provinces; DROP TABLE IF EXISTS provinces;
DROP TABLE IF EXISTS users; DROP TABLE IF EXISTS users;
+9 -8
View File
@@ -54,21 +54,22 @@ CREATE TABLE IF NOT EXISTS branches (
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL "created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
); );
CREATE TABLE IF NOT EXISTS payment_cards ( CREATE TABLE IF NOT EXISTS card_types (
id bigserial PRIMARY KEY, id bigserial PRIMARY KEY,
price numeric(12, 2) NOT NULL DEFAULT 0, name json NOT NULL DEFAULT '{}'::json,
title json NOT NULL DEFAULT '{}'::json, price character varying(255) NOT NULL DEFAULT '',
content json NOT NULL DEFAULT '{}'::json, notes character varying(255) NOT NULL DEFAULT '',
active boolean NOT NULL DEFAULT true, active boolean NOT NULL DEFAULT true,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL, "updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL "created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
); );
CREATE TABLE IF NOT EXISTS reasons_cards ( CREATE TABLE IF NOT EXISTS card_states (
id bigserial PRIMARY KEY, id bigserial PRIMARY KEY,
title json NOT NULL DEFAULT '{}'::json, name json NOT NULL DEFAULT '{}'::json,
price numeric(12, 2) NOT NULL DEFAULT 0, price character varying(255) NOT NULL DEFAULT '',
content json NOT NULL DEFAULT '{}'::json, notes character varying(255) NOT NULL DEFAULT '',
active boolean NOT NULL DEFAULT true,
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL, created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
); );
@@ -1,4 +1,4 @@
ALTER TABLE loan_order_required_docs RENAME COLUMN active TO status; ALTER TABLE loan_order_required_docs RENAME COLUMN active TO status;
ALTER TABLE payment_cards RENAME COLUMN active TO status; ALTER TABLE card_types RENAME COLUMN active TO status;
ALTER TABLE provinces RENAME COLUMN active TO status; ALTER TABLE provinces RENAME COLUMN active TO status;
ALTER TABLE users RENAME COLUMN active TO status; ALTER TABLE users RENAME COLUMN active TO status;
@@ -1,4 +1,4 @@
ALTER TABLE users RENAME COLUMN status TO active; ALTER TABLE users RENAME COLUMN status TO active;
ALTER TABLE provinces RENAME COLUMN status TO active; ALTER TABLE provinces RENAME COLUMN status TO active;
ALTER TABLE payment_cards RENAME COLUMN status TO active; ALTER TABLE card_types RENAME COLUMN status TO active;
ALTER TABLE loan_order_required_docs RENAME COLUMN status TO active; ALTER TABLE loan_order_required_docs RENAME COLUMN status TO active;
+83 -83
View File
@@ -51,8 +51,8 @@ const docTemplate = `{
}, },
{ {
"type": "string", "type": "string",
"description": "Filter by unique number", "description": "Filter by unique code",
"name": "unikal_nomer", "name": "unique_code",
"in": "query" "in": "query"
}, },
{ {
@@ -595,7 +595,7 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"description": "Filter by title (en, ru, tm)", "description": "Filter by name",
"name": "document_name", "name": "document_name",
"in": "query" "in": "query"
}, },
@@ -1979,45 +1979,56 @@ const docTemplate = `{
"type": "object", "type": "object",
"required": [ "required": [
"address", "address",
"provinceId", "name",
"title", "region"
"unikalNomer"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/branches.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSber": { "billingSberPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSwift": { "billingSberUsername": {
"type": "string" "type": "string"
}, },
"billingPasswordVisa": { "billingSwiftPassword": {
"type": "string"
},
"billingSwiftUsername": {
"type": "string" "type": "string"
}, },
"billingUsername": { "billingUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameSber": { "billingVisaMasterPassword": {
"type": "string" "type": "string"
}, },
"billingUsernameSwift": { "billingVisaMasterUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameVisa": { "name": {
"type": "string" "$ref": "#/definitions/branches.LocalizedText"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "string"
}
}, },
"provinceId": { "provinceId": {
"type": "integer" "type": "integer"
}, },
"title": { "region": {
"$ref": "#/definitions/branches.LocalizedText" "type": "string"
}, },
"unikalNomer": { "uniqueCode": {
"type": "string" "type": "string"
} }
} }
@@ -2040,45 +2051,56 @@ const docTemplate = `{
"type": "object", "type": "object",
"required": [ "required": [
"address", "address",
"provinceId", "name",
"title", "region"
"unikalNomer"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/branches.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSber": { "billingSberPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSwift": { "billingSberUsername": {
"type": "string" "type": "string"
}, },
"billingPasswordVisa": { "billingSwiftPassword": {
"type": "string"
},
"billingSwiftUsername": {
"type": "string" "type": "string"
}, },
"billingUsername": { "billingUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameSber": { "billingVisaMasterPassword": {
"type": "string" "type": "string"
}, },
"billingUsernameSwift": { "billingVisaMasterUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameVisa": { "name": {
"type": "string" "$ref": "#/definitions/branches.LocalizedText"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "string"
}
}, },
"provinceId": { "provinceId": {
"type": "integer" "type": "integer"
}, },
"title": { "region": {
"$ref": "#/definitions/branches.LocalizedText" "type": "string"
}, },
"unikalNomer": { "uniqueCode": {
"type": "string" "type": "string"
} }
} }
@@ -2086,39 +2108,17 @@ const docTemplate = `{
"loansdocument.CreateLoanDocumentDTO": { "loansdocument.CreateLoanDocumentDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"contentEn", "name",
"contentRu", "value"
"contentTm",
"title"
], ],
"properties": { "properties": {
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"contentEn": { "name": {
"type": "string" "type": "string"
}, },
"contentRu": { "value": {
"type": "string"
},
"contentTm": {
"type": "string"
},
"title": {
"$ref": "#/definitions/loansdocument.LocalizedTitle"
}
}
},
"loansdocument.LocalizedTitle": {
"type": "object",
"properties": {
"en": {
"type": "string"
},
"ru": {
"type": "string"
},
"tm": {
"type": "string" "type": "string"
} }
} }
@@ -2134,26 +2134,18 @@ const docTemplate = `{
"loansdocument.UpdateLoanDocumentDTO": { "loansdocument.UpdateLoanDocumentDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"contentEn", "name",
"contentRu", "value"
"contentTm",
"title"
], ],
"properties": { "properties": {
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"contentEn": { "name": {
"type": "string" "type": "string"
}, },
"contentRu": { "value": {
"type": "string" "type": "string"
},
"contentTm": {
"type": "string"
},
"title": {
"$ref": "#/definitions/loansdocument.LocalizedTitle"
} }
} }
}, },
@@ -2166,6 +2158,9 @@ const docTemplate = `{
"title" "title"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"content": { "content": {
"$ref": "#/definitions/loantype.LocalizedTitle" "$ref": "#/definitions/loantype.LocalizedTitle"
}, },
@@ -2203,6 +2198,9 @@ const docTemplate = `{
"title" "title"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"content": { "content": {
"$ref": "#/definitions/loantype.LocalizedTitle" "$ref": "#/definitions/loantype.LocalizedTitle"
}, },
@@ -2220,7 +2218,6 @@ const docTemplate = `{
"paymentcard.CreatePaymentCardDTO": { "paymentcard.CreatePaymentCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
@@ -2228,11 +2225,11 @@ const docTemplate = `{
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"content": { "notes": {
"$ref": "#/definitions/paymentcard.LocalizedText" "type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/paymentcard.LocalizedText" "$ref": "#/definitions/paymentcard.LocalizedText"
@@ -2264,7 +2261,6 @@ const docTemplate = `{
"paymentcard.UpdatePaymentCardDTO": { "paymentcard.UpdatePaymentCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
@@ -2272,11 +2268,11 @@ const docTemplate = `{
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"content": { "notes": {
"$ref": "#/definitions/paymentcard.LocalizedText" "type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/paymentcard.LocalizedText" "$ref": "#/definitions/paymentcard.LocalizedText"
@@ -2336,16 +2332,18 @@ const docTemplate = `{
"reasonscard.CreateReasonCardDTO": { "reasonscard.CreateReasonCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
"properties": { "properties": {
"content": { "active": {
"$ref": "#/definitions/reasonscard.LocalizedText" "type": "boolean"
},
"notes": {
"type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/reasonscard.LocalizedText" "$ref": "#/definitions/reasonscard.LocalizedText"
@@ -2369,16 +2367,18 @@ const docTemplate = `{
"reasonscard.UpdateReasonCardDTO": { "reasonscard.UpdateReasonCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
"properties": { "properties": {
"content": { "active": {
"$ref": "#/definitions/reasonscard.LocalizedText" "type": "boolean"
},
"notes": {
"type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/reasonscard.LocalizedText" "$ref": "#/definitions/reasonscard.LocalizedText"
+83 -83
View File
@@ -45,8 +45,8 @@
}, },
{ {
"type": "string", "type": "string",
"description": "Filter by unique number", "description": "Filter by unique code",
"name": "unikal_nomer", "name": "unique_code",
"in": "query" "in": "query"
}, },
{ {
@@ -589,7 +589,7 @@
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"description": "Filter by title (en, ru, tm)", "description": "Filter by name",
"name": "document_name", "name": "document_name",
"in": "query" "in": "query"
}, },
@@ -1973,45 +1973,56 @@
"type": "object", "type": "object",
"required": [ "required": [
"address", "address",
"provinceId", "name",
"title", "region"
"unikalNomer"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/branches.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSber": { "billingSberPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSwift": { "billingSberUsername": {
"type": "string" "type": "string"
}, },
"billingPasswordVisa": { "billingSwiftPassword": {
"type": "string"
},
"billingSwiftUsername": {
"type": "string" "type": "string"
}, },
"billingUsername": { "billingUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameSber": { "billingVisaMasterPassword": {
"type": "string" "type": "string"
}, },
"billingUsernameSwift": { "billingVisaMasterUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameVisa": { "name": {
"type": "string" "$ref": "#/definitions/branches.LocalizedText"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "string"
}
}, },
"provinceId": { "provinceId": {
"type": "integer" "type": "integer"
}, },
"title": { "region": {
"$ref": "#/definitions/branches.LocalizedText" "type": "string"
}, },
"unikalNomer": { "uniqueCode": {
"type": "string" "type": "string"
} }
} }
@@ -2034,45 +2045,56 @@
"type": "object", "type": "object",
"required": [ "required": [
"address", "address",
"provinceId", "name",
"title", "region"
"unikalNomer"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/branches.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSber": { "billingSberPassword": {
"type": "string" "type": "string"
}, },
"billingPasswordSwift": { "billingSberUsername": {
"type": "string" "type": "string"
}, },
"billingPasswordVisa": { "billingSwiftPassword": {
"type": "string"
},
"billingSwiftUsername": {
"type": "string" "type": "string"
}, },
"billingUsername": { "billingUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameSber": { "billingVisaMasterPassword": {
"type": "string" "type": "string"
}, },
"billingUsernameSwift": { "billingVisaMasterUsername": {
"type": "string" "type": "string"
}, },
"billingUsernameVisa": { "name": {
"type": "string" "$ref": "#/definitions/branches.LocalizedText"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "string"
}
}, },
"provinceId": { "provinceId": {
"type": "integer" "type": "integer"
}, },
"title": { "region": {
"$ref": "#/definitions/branches.LocalizedText" "type": "string"
}, },
"unikalNomer": { "uniqueCode": {
"type": "string" "type": "string"
} }
} }
@@ -2080,39 +2102,17 @@
"loansdocument.CreateLoanDocumentDTO": { "loansdocument.CreateLoanDocumentDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"contentEn", "name",
"contentRu", "value"
"contentTm",
"title"
], ],
"properties": { "properties": {
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"contentEn": { "name": {
"type": "string" "type": "string"
}, },
"contentRu": { "value": {
"type": "string"
},
"contentTm": {
"type": "string"
},
"title": {
"$ref": "#/definitions/loansdocument.LocalizedTitle"
}
}
},
"loansdocument.LocalizedTitle": {
"type": "object",
"properties": {
"en": {
"type": "string"
},
"ru": {
"type": "string"
},
"tm": {
"type": "string" "type": "string"
} }
} }
@@ -2128,26 +2128,18 @@
"loansdocument.UpdateLoanDocumentDTO": { "loansdocument.UpdateLoanDocumentDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"contentEn", "name",
"contentRu", "value"
"contentTm",
"title"
], ],
"properties": { "properties": {
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"contentEn": { "name": {
"type": "string" "type": "string"
}, },
"contentRu": { "value": {
"type": "string" "type": "string"
},
"contentTm": {
"type": "string"
},
"title": {
"$ref": "#/definitions/loansdocument.LocalizedTitle"
} }
} }
}, },
@@ -2160,6 +2152,9 @@
"title" "title"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"content": { "content": {
"$ref": "#/definitions/loantype.LocalizedTitle" "$ref": "#/definitions/loantype.LocalizedTitle"
}, },
@@ -2197,6 +2192,9 @@
"title" "title"
], ],
"properties": { "properties": {
"active": {
"type": "boolean"
},
"content": { "content": {
"$ref": "#/definitions/loantype.LocalizedTitle" "$ref": "#/definitions/loantype.LocalizedTitle"
}, },
@@ -2214,7 +2212,6 @@
"paymentcard.CreatePaymentCardDTO": { "paymentcard.CreatePaymentCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
@@ -2222,11 +2219,11 @@
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"content": { "notes": {
"$ref": "#/definitions/paymentcard.LocalizedText" "type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/paymentcard.LocalizedText" "$ref": "#/definitions/paymentcard.LocalizedText"
@@ -2258,7 +2255,6 @@
"paymentcard.UpdatePaymentCardDTO": { "paymentcard.UpdatePaymentCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
@@ -2266,11 +2262,11 @@
"active": { "active": {
"type": "boolean" "type": "boolean"
}, },
"content": { "notes": {
"$ref": "#/definitions/paymentcard.LocalizedText" "type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/paymentcard.LocalizedText" "$ref": "#/definitions/paymentcard.LocalizedText"
@@ -2330,16 +2326,18 @@
"reasonscard.CreateReasonCardDTO": { "reasonscard.CreateReasonCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
"properties": { "properties": {
"content": { "active": {
"$ref": "#/definitions/reasonscard.LocalizedText" "type": "boolean"
},
"notes": {
"type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/reasonscard.LocalizedText" "$ref": "#/definitions/reasonscard.LocalizedText"
@@ -2363,16 +2361,18 @@
"reasonscard.UpdateReasonCardDTO": { "reasonscard.UpdateReasonCardDTO": {
"type": "object", "type": "object",
"required": [ "required": [
"content",
"price", "price",
"title" "title"
], ],
"properties": { "properties": {
"content": { "active": {
"$ref": "#/definitions/reasonscard.LocalizedText" "type": "boolean"
},
"notes": {
"type": "string"
}, },
"price": { "price": {
"type": "number" "type": "string"
}, },
"title": { "title": {
"$ref": "#/definitions/reasonscard.LocalizedText" "$ref": "#/definitions/reasonscard.LocalizedText"
+71 -74
View File
@@ -38,35 +38,42 @@ definitions:
type: object type: object
branches.CreateBranchDTO: branches.CreateBranchDTO:
properties: properties:
active:
type: boolean
address: address:
$ref: '#/definitions/branches.LocalizedText' $ref: '#/definitions/branches.LocalizedText'
billingPassword: billingPassword:
type: string type: string
billingPasswordSber: billingSberPassword:
type: string type: string
billingPasswordSwift: billingSberUsername:
type: string type: string
billingPasswordVisa: billingSwiftPassword:
type: string
billingSwiftUsername:
type: string type: string
billingUsername: billingUsername:
type: string type: string
billingUsernameSber: billingVisaMasterPassword:
type: string type: string
billingUsernameSwift: billingVisaMasterUsername:
type: string
billingUsernameVisa:
type: string type: string
name:
$ref: '#/definitions/branches.LocalizedText'
phoneNumbers:
items:
type: string
type: array
provinceId: provinceId:
type: integer type: integer
title: region:
$ref: '#/definitions/branches.LocalizedText' type: string
unikalNomer: uniqueCode:
type: string type: string
required: required:
- address - address
- provinceId - name
- title - region
- unikalNomer
type: object type: object
branches.LocalizedText: branches.LocalizedText:
properties: properties:
@@ -79,62 +86,54 @@ definitions:
type: object type: object
branches.UpdateBranchDTO: branches.UpdateBranchDTO:
properties: properties:
active:
type: boolean
address: address:
$ref: '#/definitions/branches.LocalizedText' $ref: '#/definitions/branches.LocalizedText'
billingPassword: billingPassword:
type: string type: string
billingPasswordSber: billingSberPassword:
type: string type: string
billingPasswordSwift: billingSberUsername:
type: string type: string
billingPasswordVisa: billingSwiftPassword:
type: string
billingSwiftUsername:
type: string type: string
billingUsername: billingUsername:
type: string type: string
billingUsernameSber: billingVisaMasterPassword:
type: string type: string
billingUsernameSwift: billingVisaMasterUsername:
type: string
billingUsernameVisa:
type: string type: string
name:
$ref: '#/definitions/branches.LocalizedText'
phoneNumbers:
items:
type: string
type: array
provinceId: provinceId:
type: integer type: integer
title: region:
$ref: '#/definitions/branches.LocalizedText' type: string
unikalNomer: uniqueCode:
type: string type: string
required: required:
- address - address
- provinceId - name
- title - region
- unikalNomer
type: object type: object
loansdocument.CreateLoanDocumentDTO: loansdocument.CreateLoanDocumentDTO:
properties: properties:
active: active:
type: boolean type: boolean
contentEn: name:
type: string type: string
contentRu: value:
type: string type: string
contentTm:
type: string
title:
$ref: '#/definitions/loansdocument.LocalizedTitle'
required: required:
- contentEn - name
- contentRu - value
- contentTm
- title
type: object
loansdocument.LocalizedTitle:
properties:
en:
type: string
ru:
type: string
tm:
type: string
type: object type: object
loansdocument.UpdateLoanDocumentActiveDTO: loansdocument.UpdateLoanDocumentActiveDTO:
properties: properties:
@@ -145,22 +144,18 @@ definitions:
properties: properties:
active: active:
type: boolean type: boolean
contentEn: name:
type: string type: string
contentRu: value:
type: string type: string
contentTm:
type: string
title:
$ref: '#/definitions/loansdocument.LocalizedTitle'
required: required:
- contentEn - name
- contentRu - value
- contentTm
- title
type: object type: object
loantype.CreateLoanTypeDTO: loantype.CreateLoanTypeDTO:
properties: properties:
active:
type: boolean
content: content:
$ref: '#/definitions/loantype.LocalizedTitle' $ref: '#/definitions/loantype.LocalizedTitle'
loanTerm: loanTerm:
@@ -186,6 +181,8 @@ definitions:
type: object type: object
loantype.UpdateLoanTypeDTO: loantype.UpdateLoanTypeDTO:
properties: properties:
active:
type: boolean
content: content:
$ref: '#/definitions/loantype.LocalizedTitle' $ref: '#/definitions/loantype.LocalizedTitle'
loanTerm: loanTerm:
@@ -204,14 +201,13 @@ definitions:
properties: properties:
active: active:
type: boolean type: boolean
content: notes:
$ref: '#/definitions/paymentcard.LocalizedText' type: string
price: price:
type: number type: string
title: title:
$ref: '#/definitions/paymentcard.LocalizedText' $ref: '#/definitions/paymentcard.LocalizedText'
required: required:
- content
- price - price
- title - title
type: object type: object
@@ -233,14 +229,13 @@ definitions:
properties: properties:
active: active:
type: boolean type: boolean
content: notes:
$ref: '#/definitions/paymentcard.LocalizedText' type: string
price: price:
type: number type: string
title: title:
$ref: '#/definitions/paymentcard.LocalizedText' $ref: '#/definitions/paymentcard.LocalizedText'
required: required:
- content
- price - price
- title - title
type: object type: object
@@ -279,14 +274,15 @@ definitions:
type: object type: object
reasonscard.CreateReasonCardDTO: reasonscard.CreateReasonCardDTO:
properties: properties:
content: active:
$ref: '#/definitions/reasonscard.LocalizedText' type: boolean
notes:
type: string
price: price:
type: number type: string
title: title:
$ref: '#/definitions/reasonscard.LocalizedText' $ref: '#/definitions/reasonscard.LocalizedText'
required: required:
- content
- price - price
- title - title
type: object type: object
@@ -301,14 +297,15 @@ definitions:
type: object type: object
reasonscard.UpdateReasonCardDTO: reasonscard.UpdateReasonCardDTO:
properties: properties:
content: active:
$ref: '#/definitions/reasonscard.LocalizedText' type: boolean
notes:
type: string
price: price:
type: number type: string
title: title:
$ref: '#/definitions/reasonscard.LocalizedText' $ref: '#/definitions/reasonscard.LocalizedText'
required: required:
- content
- price - price
- title - title
type: object type: object
@@ -335,9 +332,9 @@ paths:
in: query in: query
name: branch_name name: branch_name
type: string type: string
- description: Filter by unique number - description: Filter by unique code
in: query in: query
name: unikal_nomer name: unique_code
type: string type: string
- default: 1 - default: 1
description: Page number description: Page number
@@ -683,7 +680,7 @@ paths:
get: get:
description: Returns paginated loan documents with optional filters description: Returns paginated loan documents with optional filters
parameters: parameters:
- description: Filter by title (en, ru, tm) - description: Filter by name
in: query in: query
name: document_name name: document_name
type: string type: string
+19 -30
View File
@@ -23,9 +23,9 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) paymentcard
return &repository{client: client, logger: logger} return &repository{client: client, logger: logger}
} }
const cardColumns = `c.id, c.price, c.title, c.content, c.active` const cardColumns = `c.id, c.price, c.name, c.notes, c.active`
const cardReturningColumns = `id, price, title, content, active` const cardReturningColumns = `id, price, name, notes, active`
func (r *repository) List(ctx context.Context, filter paymentcard.ListFilter) (paymentcard.ListPaymentCardDTO, error) { func (r *repository) List(ctx context.Context, filter paymentcard.ListFilter) (paymentcard.ListPaymentCardDTO, error) {
fromClause, whereClause, args := buildListQuery(filter) fromClause, whereClause, args := buildListQuery(filter)
@@ -65,7 +65,7 @@ func (r *repository) List(ctx context.Context, filter paymentcard.ListFilter) (p
} }
func buildListQuery(filter paymentcard.ListFilter) (fromClause, whereClause string, args []interface{}) { func buildListQuery(filter paymentcard.ListFilter) (fromClause, whereClause string, args []interface{}) {
fromClause = ` FROM payment_cards c` fromClause = ` FROM card_types c`
var conditions []string var conditions []string
@@ -73,7 +73,7 @@ func buildListQuery(filter paymentcard.ListFilter) (fromClause, whereClause stri
args = append(args, likePattern(filter.CardName)) args = append(args, likePattern(filter.CardName))
n := len(args) n := len(args)
conditions = append(conditions, fmt.Sprintf(`( conditions = append(conditions, fmt.Sprintf(`(
c.title->>'en' ILIKE $%[1]d OR c.title->>'ru' ILIKE $%[1]d OR c.title->>'tm' ILIKE $%[1]d c.name->>'en' ILIKE $%[1]d OR c.name->>'ru' ILIKE $%[1]d OR c.name->>'tm' ILIKE $%[1]d
)`, n)) )`, n))
} }
@@ -97,7 +97,7 @@ func likePattern(term string) string {
} }
func (r *repository) GetByID(ctx context.Context, id int64) (paymentcard.PaymentCardDTO, error) { func (r *repository) GetByID(ctx context.Context, id int64) (paymentcard.PaymentCardDTO, error) {
query := fmt.Sprintf(`SELECT %s FROM payment_cards c WHERE c.id = $1`, cardColumns) query := fmt.Sprintf(`SELECT %s FROM card_types c WHERE c.id = $1`, cardColumns)
item, err := scanPaymentCard(r.client.QueryRow(ctx, query, id)) item, err := scanPaymentCard(r.client.QueryRow(ctx, query, id))
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return paymentcard.PaymentCardDTO{}, err return paymentcard.PaymentCardDTO{}, err
@@ -106,7 +106,7 @@ func (r *repository) GetByID(ctx context.Context, id int64) (paymentcard.Payment
} }
func (r *repository) Create(ctx context.Context, dto paymentcard.CreatePaymentCardDTO) (paymentcard.PaymentCardDTO, error) { func (r *repository) Create(ctx context.Context, dto paymentcard.CreatePaymentCardDTO) (paymentcard.PaymentCardDTO, error) {
title, content, err := marshalJSON(dto.Title, dto.Content) name, err := marshalName(dto.Title)
if err != nil { if err != nil {
return paymentcard.PaymentCardDTO{}, err return paymentcard.PaymentCardDTO{}, err
} }
@@ -117,26 +117,26 @@ func (r *repository) Create(ctx context.Context, dto paymentcard.CreatePaymentCa
} }
query := fmt.Sprintf(` query := fmt.Sprintf(`
INSERT INTO payment_cards (price, title, content, active) INSERT INTO card_types (price, name, notes, active)
VALUES ($1, $2, $3, $4) VALUES ($1, $2, $3, $4)
RETURNING %s`, cardReturningColumns) RETURNING %s`, cardReturningColumns)
return scanPaymentCard(r.client.QueryRow(ctx, query, dto.Price, title, content, active)) return scanPaymentCard(r.client.QueryRow(ctx, query, dto.Price, name, dto.Notes, active))
} }
func (r *repository) Update(ctx context.Context, id int64, dto paymentcard.UpdatePaymentCardDTO) (paymentcard.PaymentCardDTO, error) { func (r *repository) Update(ctx context.Context, id int64, dto paymentcard.UpdatePaymentCardDTO) (paymentcard.PaymentCardDTO, error) {
title, content, err := marshalJSON(dto.Title, dto.Content) name, err := marshalName(dto.Title)
if err != nil { if err != nil {
return paymentcard.PaymentCardDTO{}, err return paymentcard.PaymentCardDTO{}, err
} }
query := fmt.Sprintf(` query := fmt.Sprintf(`
UPDATE payment_cards SET UPDATE card_types SET
price = $1, title = $2, content = $3, active = $4 price = $1, name = $2, notes = $3, active = $4
WHERE id = $5 WHERE id = $5
RETURNING %s`, cardReturningColumns) RETURNING %s`, cardReturningColumns)
item, err := scanPaymentCard(r.client.QueryRow(ctx, query, dto.Price, title, content, dto.Active, id)) item, err := scanPaymentCard(r.client.QueryRow(ctx, query, dto.Price, name, dto.Notes, dto.Active, id))
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return paymentcard.PaymentCardDTO{}, err return paymentcard.PaymentCardDTO{}, err
} }
@@ -145,7 +145,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto paymentcard.Updat
func (r *repository) UpdateActive(ctx context.Context, id int64, active bool) (paymentcard.PaymentCardDTO, error) { func (r *repository) UpdateActive(ctx context.Context, id int64, active bool) (paymentcard.PaymentCardDTO, error) {
query := fmt.Sprintf(` query := fmt.Sprintf(`
UPDATE payment_cards SET active = $1 UPDATE card_types SET active = $1
WHERE id = $2 WHERE id = $2
RETURNING %s`, cardReturningColumns) RETURNING %s`, cardReturningColumns)
@@ -157,7 +157,7 @@ func (r *repository) UpdateActive(ctx context.Context, id int64, active bool) (p
} }
func (r *repository) Delete(ctx context.Context, id int64) error { func (r *repository) Delete(ctx context.Context, id int64) error {
tag, err := r.client.Exec(ctx, `DELETE FROM payment_cards WHERE id = $1`, id) tag, err := r.client.Exec(ctx, `DELETE FROM card_types WHERE id = $1`, id)
if err != nil { if err != nil {
return err return err
} }
@@ -167,16 +167,8 @@ func (r *repository) Delete(ctx context.Context, id int64) error {
return nil return nil
} }
func marshalJSON(title, content paymentcard.LocalizedText) ([]byte, []byte, error) { func marshalName(title paymentcard.LocalizedText) ([]byte, error) {
titleJSON, err := json.Marshal(title) return json.Marshal(title)
if err != nil {
return nil, nil, err
}
contentJSON, err := json.Marshal(content)
if err != nil {
return nil, nil, err
}
return titleJSON, contentJSON, nil
} }
type scannable interface { type scannable interface {
@@ -185,17 +177,14 @@ type scannable interface {
func scanPaymentCard(row scannable) (paymentcard.PaymentCardDTO, error) { func scanPaymentCard(row scannable) (paymentcard.PaymentCardDTO, error) {
var item paymentcard.PaymentCardDTO var item paymentcard.PaymentCardDTO
var titleJSON, contentJSON []byte var nameJSON []byte
if err := row.Scan( if err := row.Scan(
&item.Id, &item.Price, &titleJSON, &contentJSON, &item.Active, &item.Id, &item.Price, &nameJSON, &item.Notes, &item.Active,
); err != nil { ); err != nil {
return paymentcard.PaymentCardDTO{}, err return paymentcard.PaymentCardDTO{}, err
} }
if err := json.Unmarshal(titleJSON, &item.Title); err != nil { if err := json.Unmarshal(nameJSON, &item.Title); err != nil {
return paymentcard.PaymentCardDTO{}, err
}
if err := json.Unmarshal(contentJSON, &item.Content); err != nil {
return paymentcard.PaymentCardDTO{}, err return paymentcard.PaymentCardDTO{}, err
} }
return item, nil return item, nil
+13 -13
View File
@@ -7,25 +7,25 @@ type LocalizedText struct {
} }
type PaymentCardDTO struct { type PaymentCardDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Price float64 `json:"price"` Price string `json:"price"`
Title LocalizedText `json:"title"` Title LocalizedText `json:"title"`
Content LocalizedText `json:"content"` Notes string `json:"notes"`
Active bool `json:"active"` Active bool `json:"active"`
} }
type CreatePaymentCardDTO struct { type CreatePaymentCardDTO struct {
Price float64 `json:"price" binding:"required"` Price string `json:"price" binding:"required"`
Title LocalizedText `json:"title" binding:"required"` Title LocalizedText `json:"title" binding:"required"`
Content LocalizedText `json:"content" binding:"required"` Notes string `json:"notes"`
Active *bool `json:"active"` Active *bool `json:"active"`
} }
type UpdatePaymentCardDTO struct { type UpdatePaymentCardDTO struct {
Price float64 `json:"price" binding:"required"` Price string `json:"price" binding:"required"`
Title LocalizedText `json:"title" binding:"required"` Title LocalizedText `json:"title" binding:"required"`
Content LocalizedText `json:"content" binding:"required"` Notes string `json:"notes"`
Active bool `json:"active"` Active bool `json:"active"`
} }
type UpdatePaymentCardActiveDTO struct { type UpdatePaymentCardActiveDTO struct {
+25 -31
View File
@@ -23,9 +23,9 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) reasonscard
return &repository{client: client, logger: logger} return &repository{client: client, logger: logger}
} }
const reasonColumns = `r.id, r.title, r.price, r.content, r.created_at, r.updated_at` const reasonColumns = `r.id, r.price, r.name, r.notes, r.active, r.created_at, r.updated_at`
const reasonReturningColumns = `id, title, price, content, created_at, updated_at` const reasonReturningColumns = `id, price, name, notes, active, created_at, updated_at`
func (r *repository) List(ctx context.Context, filter reasonscard.ListFilter) (reasonscard.ListReasonCardDTO, error) { func (r *repository) List(ctx context.Context, filter reasonscard.ListFilter) (reasonscard.ListReasonCardDTO, error) {
fromClause, whereClause, args := buildListQuery(filter) fromClause, whereClause, args := buildListQuery(filter)
@@ -65,14 +65,14 @@ func (r *repository) List(ctx context.Context, filter reasonscard.ListFilter) (r
} }
func buildListQuery(filter reasonscard.ListFilter) (fromClause, whereClause string, args []interface{}) { func buildListQuery(filter reasonscard.ListFilter) (fromClause, whereClause string, args []interface{}) {
fromClause = ` FROM reasons_cards r` fromClause = ` FROM card_states r`
var conditions []string var conditions []string
if filter.ReasonName != "" { if filter.ReasonName != "" {
args = append(args, likePattern(filter.ReasonName)) args = append(args, likePattern(filter.ReasonName))
n := len(args) n := len(args)
conditions = append(conditions, fmt.Sprintf(`( conditions = append(conditions, fmt.Sprintf(`(
r.title->>'en' ILIKE $%[1]d OR r.title->>'ru' ILIKE $%[1]d OR r.title->>'tm' ILIKE $%[1]d r.name->>'en' ILIKE $%[1]d OR r.name->>'ru' ILIKE $%[1]d OR r.name->>'tm' ILIKE $%[1]d
)`, n)) )`, n))
} }
@@ -91,7 +91,7 @@ func likePattern(term string) string {
} }
func (r *repository) GetByID(ctx context.Context, id int64) (reasonscard.ReasonCardDTO, error) { func (r *repository) GetByID(ctx context.Context, id int64) (reasonscard.ReasonCardDTO, error) {
query := fmt.Sprintf(`SELECT %s FROM reasons_cards r WHERE r.id = $1`, reasonColumns) query := fmt.Sprintf(`SELECT %s FROM card_states r WHERE r.id = $1`, reasonColumns)
item, err := scanReasonCard(r.client.QueryRow(ctx, query, id)) item, err := scanReasonCard(r.client.QueryRow(ctx, query, id))
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return reasonscard.ReasonCardDTO{}, err return reasonscard.ReasonCardDTO{}, err
@@ -100,33 +100,38 @@ func (r *repository) GetByID(ctx context.Context, id int64) (reasonscard.ReasonC
} }
func (r *repository) Create(ctx context.Context, dto reasonscard.CreateReasonCardDTO) (reasonscard.ReasonCardDTO, error) { func (r *repository) Create(ctx context.Context, dto reasonscard.CreateReasonCardDTO) (reasonscard.ReasonCardDTO, error) {
title, content, err := marshalJSON(dto.Title, dto.Content) name, err := marshalName(dto.Title)
if err != nil { if err != nil {
return reasonscard.ReasonCardDTO{}, err return reasonscard.ReasonCardDTO{}, err
} }
active := true
if dto.Active != nil {
active = *dto.Active
}
query := fmt.Sprintf(` query := fmt.Sprintf(`
INSERT INTO reasons_cards (title, price, content) INSERT INTO card_states (price, name, notes, active)
VALUES ($1, $2, $3) VALUES ($1, $2, $3, $4)
RETURNING %s`, reasonReturningColumns) RETURNING %s`, reasonReturningColumns)
return scanReasonCard(r.client.QueryRow(ctx, query, title, dto.Price, content)) return scanReasonCard(r.client.QueryRow(ctx, query, dto.Price, name, dto.Notes, active))
} }
func (r *repository) Update(ctx context.Context, id int64, dto reasonscard.UpdateReasonCardDTO) (reasonscard.ReasonCardDTO, error) { func (r *repository) Update(ctx context.Context, id int64, dto reasonscard.UpdateReasonCardDTO) (reasonscard.ReasonCardDTO, error) {
title, content, err := marshalJSON(dto.Title, dto.Content) name, err := marshalName(dto.Title)
if err != nil { if err != nil {
return reasonscard.ReasonCardDTO{}, err return reasonscard.ReasonCardDTO{}, err
} }
query := fmt.Sprintf(` query := fmt.Sprintf(`
UPDATE reasons_cards SET UPDATE card_states SET
title = $1, price = $2, content = $3, price = $1, name = $2, notes = $3, active = $4,
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
WHERE id = $4 WHERE id = $5
RETURNING %s`, reasonReturningColumns) RETURNING %s`, reasonReturningColumns)
item, err := scanReasonCard(r.client.QueryRow(ctx, query, title, dto.Price, content, id)) item, err := scanReasonCard(r.client.QueryRow(ctx, query, dto.Price, name, dto.Notes, dto.Active, id))
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return reasonscard.ReasonCardDTO{}, err return reasonscard.ReasonCardDTO{}, err
} }
@@ -134,7 +139,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto reasonscard.Updat
} }
func (r *repository) Delete(ctx context.Context, id int64) error { func (r *repository) Delete(ctx context.Context, id int64) error {
tag, err := r.client.Exec(ctx, `DELETE FROM reasons_cards WHERE id = $1`, id) tag, err := r.client.Exec(ctx, `DELETE FROM card_states WHERE id = $1`, id)
if err != nil { if err != nil {
return err return err
} }
@@ -144,16 +149,8 @@ func (r *repository) Delete(ctx context.Context, id int64) error {
return nil return nil
} }
func marshalJSON(title, content reasonscard.LocalizedText) ([]byte, []byte, error) { func marshalName(title reasonscard.LocalizedText) ([]byte, error) {
titleJSON, err := json.Marshal(title) return json.Marshal(title)
if err != nil {
return nil, nil, err
}
contentJSON, err := json.Marshal(content)
if err != nil {
return nil, nil, err
}
return titleJSON, contentJSON, nil
} }
type scannable interface { type scannable interface {
@@ -162,17 +159,14 @@ type scannable interface {
func scanReasonCard(row scannable) (reasonscard.ReasonCardDTO, error) { func scanReasonCard(row scannable) (reasonscard.ReasonCardDTO, error) {
var item reasonscard.ReasonCardDTO var item reasonscard.ReasonCardDTO
var titleJSON, contentJSON []byte var nameJSON []byte
if err := row.Scan( if err := row.Scan(
&item.Id, &titleJSON, &item.Price, &contentJSON, &item.CreatedAt, &item.UpdatedAt, &item.Id, &item.Price, &nameJSON, &item.Notes, &item.Active, &item.CreatedAt, &item.UpdatedAt,
); err != nil { ); err != nil {
return reasonscard.ReasonCardDTO{}, err return reasonscard.ReasonCardDTO{}, err
} }
if err := json.Unmarshal(titleJSON, &item.Title); err != nil { if err := json.Unmarshal(nameJSON, &item.Title); err != nil {
return reasonscard.ReasonCardDTO{}, err
}
if err := json.Unmarshal(contentJSON, &item.Content); err != nil {
return reasonscard.ReasonCardDTO{}, err return reasonscard.ReasonCardDTO{}, err
} }
return item, nil return item, nil
+11 -8
View File
@@ -11,22 +11,25 @@ type LocalizedText struct {
type ReasonCardDTO struct { type ReasonCardDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Title LocalizedText `json:"title"` Title LocalizedText `json:"title"`
Price float64 `json:"price"` Price string `json:"price"`
Content LocalizedText `json:"content"` Notes string `json:"notes"`
Active bool `json:"active"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }
type CreateReasonCardDTO struct { type CreateReasonCardDTO struct {
Title LocalizedText `json:"title" binding:"required"` Title LocalizedText `json:"title" binding:"required"`
Price float64 `json:"price" binding:"required"` Price string `json:"price" binding:"required"`
Content LocalizedText `json:"content" binding:"required"` Notes string `json:"notes"`
Active *bool `json:"active"`
} }
type UpdateReasonCardDTO struct { type UpdateReasonCardDTO struct {
Title LocalizedText `json:"title" binding:"required"` Title LocalizedText `json:"title" binding:"required"`
Price float64 `json:"price" binding:"required"` Price string `json:"price" binding:"required"`
Content LocalizedText `json:"content" binding:"required"` Notes string `json:"notes"`
Active bool `json:"active"`
} }
type ListFilter struct { type ListFilter struct {