@dascompany/database 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SQL.json +35 -3
- package/dist/TableConnection.d.ts +8 -2
- package/dist/TableConnection.js +14 -2
- package/dist/index.d.ts +21 -1
- package/dist/index.js +16 -1
- package/dist/mappers/CompanyDataMapper.d.ts +9 -0
- package/dist/mappers/CompanyDataMapper.js +17 -0
- package/dist/mappers/DeliveryMethodsMapper.d.ts +9 -0
- package/dist/mappers/DeliveryMethodsMapper.js +17 -0
- package/dist/mappers/FileConnectionMapper.d.ts +9 -0
- package/dist/mappers/FileConnectionMapper.js +17 -0
- package/dist/mappers/PaymentMethodsMapper.d.ts +9 -0
- package/dist/mappers/PaymentMethodsMapper.js +17 -0
- package/dist/query/QueryOptions.d.ts +6 -0
- package/dist/query/QueryOptions.js +25 -0
- package/dist/reader/ClientAccountReader.d.ts +6 -0
- package/dist/reader/ClientAccountReader.js +27 -10
- package/dist/reader/CompanyDataReader.d.ts +4 -0
- package/dist/reader/CompanyDataReader.js +27 -0
- package/dist/reader/DeliveryMethodReader.d.ts +1 -0
- package/dist/reader/DeliveryMethodReader.js +5 -0
- package/dist/reader/FileConnectionsReader.d.ts +6 -0
- package/dist/reader/FileConnectionsReader.js +25 -0
- package/dist/reader/ProductReader.d.ts +2 -0
- package/dist/reader/ProductReader.js +21 -0
- package/dist/reader/StatusTypesReader.d.ts +3 -0
- package/dist/reader/StatusTypesReader.js +8 -0
- package/dist/reader/payment/PaymentMethodReader.d.ts +1 -0
- package/dist/reader/payment/PaymentMethodReader.js +5 -0
- package/dist/repo/AdminRepo.d.ts +12 -0
- package/dist/repo/AdminRepo.js +32 -0
- package/dist/repo/ClientAccountRepo.d.ts +2 -0
- package/dist/repo/ClientAccountRepo.js +10 -0
- package/dist/repo/CompanyDataRepo.d.ts +4 -0
- package/dist/repo/CompanyDataRepo.js +11 -0
- package/dist/repo/ContactDetailsRepo.d.ts +1 -0
- package/dist/repo/ContactDetailsRepo.js +8 -3
- package/dist/repo/DeliveryMethodRepo.d.ts +4 -0
- package/dist/repo/DeliveryMethodRepo.js +11 -0
- package/dist/repo/FileConnectionsRepo.d.ts +7 -0
- package/dist/repo/FileConnectionsRepo.js +25 -0
- package/dist/repo/PaymentMethodRepo.d.ts +4 -0
- package/dist/repo/PaymentMethodRepo.js +11 -0
- package/dist/repo/ProductRepo.d.ts +1 -0
- package/dist/repo/ProductRepo.js +5 -0
- package/dist/stockObjects/CompanyData.d.ts +21 -0
- package/dist/stockObjects/CompanyData.js +51 -0
- package/dist/stockObjects/DeliveryDetails.d.ts +1 -0
- package/dist/stockObjects/DeliveryDetails.js +3 -0
- package/dist/stockObjects/DeliveryMethods.d.ts +12 -0
- package/dist/stockObjects/DeliveryMethods.js +26 -0
- package/dist/stockObjects/FileConnection.d.ts +18 -0
- package/dist/stockObjects/FileConnection.js +42 -0
- package/dist/stockObjects/Order.d.ts +1 -1
- package/dist/stockObjects/PaymentDetails.d.ts +1 -1
- package/dist/stockObjects/PaymentDetails.js +1 -1
- package/dist/stockObjects/PaymentMethods.d.ts +12 -0
- package/dist/stockObjects/PaymentMethods.js +26 -0
- package/dist/stockObjects/Product.d.ts +1 -1
- package/dist/stockObjects/Product.js +5 -2
- package/dist/tables/ClientAccountsTable.d.ts +5 -2
- package/dist/tables/ClientAccountsTable.js +16 -4
- package/dist/tables/ProductsTable.d.ts +10 -0
- package/dist/tables/ProductsTable.js +72 -0
- package/dist/tables/files/FileConnectionsTable.d.ts +12 -0
- package/dist/tables/files/FileConnectionsTable.js +41 -0
- package/dist/tables/personalInformation/ContactDetailsTable.d.ts +1 -1
- package/dist/tables/settings/CompanyDataTable.d.ts +10 -0
- package/dist/tables/settings/CompanyDataTable.js +37 -0
- package/dist/tables/settings/DeliveryMethodsTable.d.ts +12 -0
- package/dist/tables/settings/DeliveryMethodsTable.js +43 -0
- package/dist/tables/settings/PaymentMethodsTable.d.ts +12 -0
- package/dist/tables/settings/PaymentMethodsTable.js +43 -0
- package/dist/types/CompanyDataI.d.ts +8 -0
- package/dist/types/CompanyDataI.js +1 -0
- package/dist/types/FileConnectionI.d.ts +6 -0
- package/dist/types/FileConnectionI.js +1 -0
- package/dist/types/FileConnectionTypeE.d.ts +4 -0
- package/dist/types/FileConnectionTypeE.js +5 -0
- package/dist/types/PersonalDataI.d.ts +1 -1
- package/dist/types/QueryOptionsI.d.ts +2 -1
- package/dist/types/parameters/ParameterType.d.ts +12 -9
- package/dist/types/parameters/ParameterType.js +12 -9
- package/dist/types/rows/CompanyDataRow.d.ts +8 -0
- package/dist/types/rows/CompanyDataRow.js +1 -0
- package/dist/types/rows/DeliveryMethodRow.d.ts +5 -0
- package/dist/types/rows/DeliveryMethodRow.js +1 -0
- package/dist/types/rows/FileConnectionRow.d.ts +6 -0
- package/dist/types/rows/FileConnectionRow.js +1 -0
- package/dist/types/rows/PaymentMethodRow.d.ts +5 -0
- package/dist/types/rows/PaymentMethodRow.js +1 -0
- package/dist/utils/Filters.d.ts +6 -0
- package/dist/utils/Filters.js +31 -0
- package/dist/utils/OrderByI.d.ts +4 -0
- package/dist/utils/OrderByI.js +1 -0
- package/dist/utils/Parameters.d.ts +5 -0
- package/dist/utils/Parameters.js +23 -0
- package/dist/utils/parameters/ParameterConversionSystem.d.ts +5 -0
- package/dist/utils/parameters/ParameterConversionSystem.js +28 -0
- package/dist/utils/parameters/ParameterFilterSystem.d.ts +4 -0
- package/dist/utils/parameters/ParameterFilterSystem.js +11 -0
- package/dist/utils/parameters/ParameterRulesSystem.d.ts +3 -0
- package/dist/utils/parameters/ParameterRulesSystem.js +8 -0
- package/package.json +1 -1
- package/dist/tables/store-settings/DeliveryMethodsTable.d.ts +0 -6
- package/dist/tables/store-settings/DeliveryMethodsTable.js +0 -15
- package/dist/tables/store-settings/PaymentMethodsTable.d.ts +0 -6
- package/dist/tables/store-settings/PaymentMethodsTable.js +0 -15
package/dist/SQL.json
CHANGED
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
},
|
|
12
12
|
"accounts": {
|
|
13
13
|
"select": "SELECT id, email, created_at, activated, deleted, contact_details_id, delivery_details_id, invoice_details_id FROM clients.accounts WHERE id = $account_id::BIGINT",
|
|
14
|
+
"selectAll": "SELECT id, email, created_at, activated, deleted FROM clients.accounts $WHERE $ORDERBY $LIMIT",
|
|
14
15
|
"selectNextId": "SELECT nextval('clients.accounts_id'::regclass)",
|
|
15
16
|
"getIdForEmail": "SELECT id FROM clients.accounts WHERE LOWER( email ) = LOWER($email::TEXT)",
|
|
16
17
|
"insert": "INSERT INTO clients.accounts( id, email, activated, contact_details_id) VALUES ($id::BIGINT, LOWER($email::TEXT), $activated::BOOL, $contact_details_id::BIGINT)",
|
|
17
18
|
"update": "UPDATE clients.accounts SET activated = $activated::BOOL, deleted = $deleted::BOOL, contact_details_id = $contact_details_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, invoice_details_id = $invoice_details_id::BIGINT WHERE id = $id::BIGINT",
|
|
18
|
-
"delete": "DELETE FROM clients.accounts WHERE id = $account_id::BIGINT"
|
|
19
|
+
"delete": "DELETE FROM clients.accounts WHERE id = $account_id::BIGINT",
|
|
20
|
+
"count": "SELECT COUNT(*) AS total_rows FROM clients.accounts $WHERE ",
|
|
21
|
+
"selectEmail": "SELECT email FROM clients.accounts WHERE id = $id:BIGINT"
|
|
19
22
|
},
|
|
20
23
|
"contactDetails": {
|
|
21
24
|
"select": "SELECT id, personal_data_id, address_id FROM personal_information.contact_details WHERE id = $id::BIGINT",
|
|
@@ -37,6 +40,8 @@
|
|
|
37
40
|
},
|
|
38
41
|
"addresses": {
|
|
39
42
|
"select": "SELECT id, country, city, postal_code, street, house_number, apartment_number FROM personal_information.addresses WHERE id = $id::BIGINT",
|
|
43
|
+
"selectTypes": "SELECT type FROM personal_information.addresses WHERE account_id = $account_id::BIGINT",
|
|
44
|
+
"selectId": "SELECT id FROM personal_information.addresses WHERE account_id = $account_id::BIGINT AND type = $type::SMALLINT",
|
|
40
45
|
"insert": "INSERT INTO personal_information.addresses( id, country, city, postal_code, street, house_number, apartment_number) VALUES( $id::BIGINT, $country::TEXT, $city::TEXT, $postal_code::TEXT, $street::TEXT, $house_number::TEXT, $apartment_number::TEXT) ",
|
|
41
46
|
"update": "UPDATE personal_information.addresses SET country = $country::TEXT, city = $city::TEXT, postal_code = $postal_code::TEXT , street = $street::TEXT , house_number = $house_number::TEXT , apartment_number = $apartment_number::TEXT WHERE id = $id::BIGINT",
|
|
42
47
|
"selectNextId": "SELECT nextval('personal_information.addresses_id'::regclass)"
|
|
@@ -58,6 +63,12 @@
|
|
|
58
63
|
"products": {
|
|
59
64
|
"select": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE id = $id::BIGINT",
|
|
60
65
|
"selectAll": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE deleted = false $PARAMS $ORDERBY LIMIT $limit::BIGINT OFFSET $offset::BIGINT",
|
|
66
|
+
"selectListForOrder": "SELECT id, title, sku, file_id, net_price FROM products WHERE deleted = false",
|
|
67
|
+
"selectIdForSku": "SELECT id FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT) AND deleted = false",
|
|
68
|
+
"insert": "INSERT INTO products( id, sku, url, title, description, net_price, vat, color, quantity, width, length, height, file_id, deleted) VALUES ($id::BIGINT, $sku::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $vat::INT, $color::TEXT, $quantity::INT, $width::INT, $length::INT, $height::DOUBLE PRECISION,$file_id::BIGINT ,false::BOOL)",
|
|
69
|
+
"update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT , description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, vat = $vat::INT, color = $color::TEXT, quantity = $quantity::INT, width = $width::INT, length = $length::INT, height = $height::DOUBLE PRECISION, file_id = $file_id::BIGINT WHERE id = $id::BIGINT",
|
|
70
|
+
"delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
|
|
71
|
+
"restore": "UPDATE products SET deleted = false WHERE id = $id::BIGINT",
|
|
61
72
|
"selectForSku": "SELECT id as product_id FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
62
73
|
"selectForUrl": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE LOWER( url ) = LOWER($url::TEXT)",
|
|
63
74
|
"selectNextId": "SELECT nextval('product_id'::regclass)",
|
|
@@ -91,13 +102,28 @@
|
|
|
91
102
|
"select": "SELECT id, name, orginal_name, catalog, size_kb, type, created_at FROM files.files WHERE id = $id::BIGINT",
|
|
92
103
|
"selectForConnection": "SELECT id, name, catalog, type FROM files.files JOIN files.file_connections ON file_id = id WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT ORDER BY sequence"
|
|
93
104
|
},
|
|
105
|
+
"fileConnections": {
|
|
106
|
+
"select": "SELECT file_id, sequence FROM files.file_connections WHERE connection_type = $connection_type::BIGINT and connection_id = $connection_id::BIGINT",
|
|
107
|
+
"selectForFileId": "SELECT * FROM files.file_connections WHERE file_id = $file_id::BIGINT",
|
|
108
|
+
"insert": "INSERT INTO files.file_connections( file_id, connection_type, connection_id, sequence) VALUES ($file_id::BIGINT, $connection_type::TEXT, $connection_id::BIGINT, $sequence::BIGINT)",
|
|
109
|
+
"delete": "DELETE FROM files.file_connections WHERE file_id = $file_id::BIGINT",
|
|
110
|
+
"deleteForConnection": "DELETE FROM files.file_connections WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT"
|
|
111
|
+
},
|
|
94
112
|
"paymentMethods": {
|
|
95
113
|
"select": "SELECT * FROM settings.payment_methods WHERE id = $id::BIGINT",
|
|
96
|
-
"selectAll": "SELECT * FROM settings.payment_methods
|
|
114
|
+
"selectAll": "SELECT * FROM settings.payment_methods ORDER BY id",
|
|
115
|
+
"selectAllActive": "SELECT * FROM settings.payment_methods WHERE active=true ORDER BY id",
|
|
116
|
+
"insert": "INSERT INTO settings.payment_methods(id, key, active) VALUES ( $id::BIGINT, $key::TEXT, $active::BOOL)",
|
|
117
|
+
"update": "UPDATE settings.payment_methods SET id = $id::BIGINT, key = $key::TEXT, active = $active::BOOL WHERE id = $id::BIGINT",
|
|
118
|
+
"selectNextId": "SELECT nextval('settings.payment_methods_id'::regclass)"
|
|
97
119
|
},
|
|
98
120
|
"deliveryMethods": {
|
|
99
121
|
"select": "SELECT * FROM settings.delivery_methods WHERE id = $id::BIGINT",
|
|
100
|
-
"selectAll": "SELECT * FROM settings.delivery_methods
|
|
122
|
+
"selectAll": "SELECT * FROM settings.delivery_methods ORDER BY id",
|
|
123
|
+
"selectAllActive": "SELECT * FROM settings.delivery_methods WHERE active=true ORDER BY id",
|
|
124
|
+
"insert": "INSERT INTO settings.delivery_methods(id, key, active) VALUES ( $id::BIGINT, $key::TEXT, $active::BOOL)",
|
|
125
|
+
"update": "UPDATE settings.delivery_methods SET id = $id::BIGINT, key = $key::TEXT, active = $active::BOOL WHERE id = $id::BIGINT",
|
|
126
|
+
"selectNextId": "SELECT nextval('settings.delivery_methods_id'::regclass)"
|
|
101
127
|
},
|
|
102
128
|
"paymentStatusTypes": {
|
|
103
129
|
"select": "SELECT * FROM orders.payment_status_types WHERE id = $id::BIGINT"
|
|
@@ -119,5 +145,11 @@
|
|
|
119
145
|
},
|
|
120
146
|
"statusTypes": {
|
|
121
147
|
"select": "SELECT * FROM orders.status_types"
|
|
148
|
+
},
|
|
149
|
+
"companyData": {
|
|
150
|
+
"select": "SELECT * FROM settings.company_data ORDER BY id DESC LIMIT 1",
|
|
151
|
+
"insert": "INSERT INTO settings.company_data(id, name, tax_number, email, phone_number, address_id) VALUES ( $id::BIGINT, $name::TEXT, $tax_number::TEXT, $email::TEXT, $phone_number::TEXT, $address_id::BIGINT )",
|
|
152
|
+
"update": "UPDATE settings.company_data SET id = $id::BIGINT, name = $name::TEXT , email = LOWER($email::TEXT), phone_number = $phone_number::TEXT, tax_number = $tax_number::TEXT WHERE id = $id::BIGINT",
|
|
153
|
+
"selectNextId": "SELECT nextval('settings.company_data_id'::regclass)"
|
|
122
154
|
}
|
|
123
155
|
}
|
|
@@ -9,9 +9,9 @@ import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
|
9
9
|
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
10
10
|
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
11
11
|
import DeliveryStatusTypesTable from './tables/DeliveryStatusTypesTable';
|
|
12
|
-
import PaymentMethodsTable from './tables/
|
|
12
|
+
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
13
13
|
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
14
|
-
import DeliveryMethodsTable from './tables/
|
|
14
|
+
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
15
15
|
import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
|
|
16
16
|
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
17
17
|
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
@@ -21,6 +21,8 @@ import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
|
21
21
|
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
22
22
|
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
23
23
|
import StatusTypesTable from './tables/StatusTypesTable';
|
|
24
|
+
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
25
|
+
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
24
26
|
export default class TableConnection extends Connection {
|
|
25
27
|
private _AdminAccountsTable;
|
|
26
28
|
private _StatusTypesTable;
|
|
@@ -43,6 +45,8 @@ export default class TableConnection extends Connection {
|
|
|
43
45
|
private _DeliveryStatusesTable;
|
|
44
46
|
private _PaymentDetailsTable;
|
|
45
47
|
private _PaymentStatusesTable;
|
|
48
|
+
private _CompanyDataTable;
|
|
49
|
+
private _FileConnectionsTable;
|
|
46
50
|
constructor(pgClient: Client);
|
|
47
51
|
get adminAccounts(): AdminAccountsTable;
|
|
48
52
|
get statusTypes(): StatusTypesTable;
|
|
@@ -65,4 +69,6 @@ export default class TableConnection extends Connection {
|
|
|
65
69
|
get deliveryStatuses(): DeliveryStatusesTable;
|
|
66
70
|
get paymentDetails(): PaymentDetailsTable;
|
|
67
71
|
get paymentStatuses(): PaymentStatusesTable;
|
|
72
|
+
get companyData(): CompanyDataTable;
|
|
73
|
+
get fileConnections(): FileConnectionsTable;
|
|
68
74
|
}
|
package/dist/TableConnection.js
CHANGED
|
@@ -8,9 +8,9 @@ import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
|
8
8
|
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
9
9
|
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
10
10
|
import DeliveryStatusTypesTable from './tables/DeliveryStatusTypesTable';
|
|
11
|
-
import PaymentMethodsTable from './tables/
|
|
11
|
+
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
12
12
|
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
13
|
-
import DeliveryMethodsTable from './tables/
|
|
13
|
+
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
14
14
|
import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
|
|
15
15
|
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
16
16
|
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
@@ -20,6 +20,8 @@ import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
|
20
20
|
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
21
21
|
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
22
22
|
import StatusTypesTable from './tables/StatusTypesTable';
|
|
23
|
+
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
24
|
+
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
23
25
|
export default class TableConnection extends Connection {
|
|
24
26
|
_AdminAccountsTable;
|
|
25
27
|
_StatusTypesTable;
|
|
@@ -42,6 +44,8 @@ export default class TableConnection extends Connection {
|
|
|
42
44
|
_DeliveryStatusesTable;
|
|
43
45
|
_PaymentDetailsTable;
|
|
44
46
|
_PaymentStatusesTable;
|
|
47
|
+
_CompanyDataTable;
|
|
48
|
+
_FileConnectionsTable;
|
|
45
49
|
constructor(pgClient) {
|
|
46
50
|
super(pgClient);
|
|
47
51
|
this._AdminAccountsTable = new AdminAccountsTable(this);
|
|
@@ -65,6 +69,8 @@ export default class TableConnection extends Connection {
|
|
|
65
69
|
this._DeliveryStatusesTable = new DeliveryStatusesTable(this);
|
|
66
70
|
this._PaymentDetailsTable = new PaymentDetailsTable(this);
|
|
67
71
|
this._PaymentStatusesTable = new PaymentStatusesTable(this);
|
|
72
|
+
this._CompanyDataTable = new CompanyDataTable(this);
|
|
73
|
+
this._FileConnectionsTable = new FileConnectionsTable(this);
|
|
68
74
|
}
|
|
69
75
|
get adminAccounts() {
|
|
70
76
|
return this._AdminAccountsTable;
|
|
@@ -129,4 +135,10 @@ export default class TableConnection extends Connection {
|
|
|
129
135
|
get paymentStatuses() {
|
|
130
136
|
return this._PaymentStatusesTable;
|
|
131
137
|
}
|
|
138
|
+
get companyData() {
|
|
139
|
+
return this._CompanyDataTable;
|
|
140
|
+
}
|
|
141
|
+
get fileConnections() {
|
|
142
|
+
return this._FileConnectionsTable;
|
|
143
|
+
}
|
|
132
144
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import DeliveryMethodReader from "./reader/DeliveryMethodReader";
|
|
|
8
8
|
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
9
9
|
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
10
10
|
import OrderReader from "./reader/OrderReader";
|
|
11
|
+
import FilesReader from './reader/FilesReader';
|
|
11
12
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
12
13
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
13
14
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
@@ -17,12 +18,14 @@ import ProductReader from "./reader/ProductReader";
|
|
|
17
18
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
18
19
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
19
20
|
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
21
|
+
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
20
22
|
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
21
23
|
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
22
24
|
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
23
25
|
import OrderRepo from "./repo/OrderRepo";
|
|
24
26
|
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
25
27
|
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
28
|
+
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
26
29
|
import ProductRepo from "./repo/ProductRepo";
|
|
27
30
|
import Address from "./stockObjects/Address";
|
|
28
31
|
import Admin from "./stockObjects/Admin";
|
|
@@ -39,4 +42,21 @@ import PersonalData from "./stockObjects/PersonalData";
|
|
|
39
42
|
import Product from "./stockObjects/Product";
|
|
40
43
|
import Status from "./stockObjects/Status";
|
|
41
44
|
import Client from "./stockObjects/Client";
|
|
42
|
-
|
|
45
|
+
import AdminRepo from './repo/AdminRepo';
|
|
46
|
+
import TableConnection from './TableConnection';
|
|
47
|
+
import ParameterType from './types/parameters/ParameterType';
|
|
48
|
+
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
49
|
+
import FileConnectionE from './types/FileConnectionE';
|
|
50
|
+
import ConnectorE from './types/ConnectorE';
|
|
51
|
+
import ParameterI from './types/ParameterI';
|
|
52
|
+
import QueryOptionsI from './types/QueryOptionsI';
|
|
53
|
+
import ResultLimitationI from './types/ResultLimitationI';
|
|
54
|
+
import ParameterFilter from './types/parameters/ParameterFilter';
|
|
55
|
+
import PaymentStatusE from './types/PaymentStatusE';
|
|
56
|
+
import OrderProductI from './types/OrderProductI';
|
|
57
|
+
import Parameters from './utils/Parameters';
|
|
58
|
+
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
59
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
60
|
+
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
61
|
+
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
62
|
+
export { TableConnection, DatabaseConnection, ParameterType, ConnectorE, FileConnectionE, PaymentStatusE, Parameters, ParameterI, QueryOptionsI, ResultLimitationI, OrderProductI, ParameterFilter, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import DeliveryMethodReader from "./reader/DeliveryMethodReader";
|
|
|
8
8
|
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
9
9
|
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
10
10
|
import OrderReader from "./reader/OrderReader";
|
|
11
|
+
import FilesReader from './reader/FilesReader';
|
|
11
12
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
12
13
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
13
14
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
@@ -17,12 +18,14 @@ import ProductReader from "./reader/ProductReader";
|
|
|
17
18
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
18
19
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
19
20
|
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
21
|
+
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
20
22
|
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
21
23
|
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
22
24
|
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
23
25
|
import OrderRepo from "./repo/OrderRepo";
|
|
24
26
|
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
25
27
|
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
28
|
+
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
26
29
|
import ProductRepo from "./repo/ProductRepo";
|
|
27
30
|
import Address from "./stockObjects/Address";
|
|
28
31
|
import Admin from "./stockObjects/Admin";
|
|
@@ -39,4 +42,16 @@ import PersonalData from "./stockObjects/PersonalData";
|
|
|
39
42
|
import Product from "./stockObjects/Product";
|
|
40
43
|
import Status from "./stockObjects/Status";
|
|
41
44
|
import Client from "./stockObjects/Client";
|
|
42
|
-
|
|
45
|
+
import AdminRepo from './repo/AdminRepo';
|
|
46
|
+
import TableConnection from './TableConnection';
|
|
47
|
+
import ParameterType from './types/parameters/ParameterType';
|
|
48
|
+
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
49
|
+
import FileConnectionE from './types/FileConnectionE';
|
|
50
|
+
import ConnectorE from './types/ConnectorE';
|
|
51
|
+
import PaymentStatusE from './types/PaymentStatusE';
|
|
52
|
+
import Parameters from './utils/Parameters';
|
|
53
|
+
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
54
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
55
|
+
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
56
|
+
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
57
|
+
export { TableConnection, DatabaseConnection, ParameterType, ConnectorE, FileConnectionE, PaymentStatusE, Parameters, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import CompanyData from "../stockObjects/CompanyData";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class CompanyDataMapper implements StockObjectMapper {
|
|
4
|
+
private companyData;
|
|
5
|
+
private companyDataTable;
|
|
6
|
+
constructor(companyData: CompanyData);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class CompanyDataMapper {
|
|
3
|
+
companyData;
|
|
4
|
+
companyDataTable;
|
|
5
|
+
constructor(companyData) {
|
|
6
|
+
this.companyDataTable = DatabaseConnection.get().companyData;
|
|
7
|
+
this.companyData = companyData;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.companyData.getId())
|
|
11
|
+
await this.companyDataTable.update(this.companyData);
|
|
12
|
+
else
|
|
13
|
+
await this.companyDataTable.insert(this.companyData);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import DeliveryMethods from "../stockObjects/DeliveryMethods";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class DeliveryMethodsMapper implements StockObjectMapper {
|
|
4
|
+
private deliveryMethods;
|
|
5
|
+
private deliveryMethodsTable;
|
|
6
|
+
constructor(deliveryMethods: DeliveryMethods);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class DeliveryMethodsMapper {
|
|
3
|
+
deliveryMethods;
|
|
4
|
+
deliveryMethodsTable;
|
|
5
|
+
constructor(deliveryMethods) {
|
|
6
|
+
this.deliveryMethodsTable = DatabaseConnection.get().deliveryMethods;
|
|
7
|
+
this.deliveryMethods = deliveryMethods;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.deliveryMethods.getId())
|
|
11
|
+
await this.deliveryMethodsTable.update(this.deliveryMethods);
|
|
12
|
+
else
|
|
13
|
+
await this.deliveryMethodsTable.insert(this.deliveryMethods);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import FileConnection from '../stockObjects/FileConnection';
|
|
2
|
+
import StockObjectMapper from '../types/StockObjectMapper';
|
|
3
|
+
export default class FileConnectionMapper implements StockObjectMapper {
|
|
4
|
+
private fileConnection;
|
|
5
|
+
private fileConnectionsTable;
|
|
6
|
+
constructor(fileConnection: FileConnection);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from '../DatabaseConnection';
|
|
2
|
+
export default class FileConnectionMapper {
|
|
3
|
+
fileConnection;
|
|
4
|
+
fileConnectionsTable;
|
|
5
|
+
constructor(fileConnection) {
|
|
6
|
+
this.fileConnectionsTable = DatabaseConnection.get().fileConnections;
|
|
7
|
+
this.fileConnection = fileConnection;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.fileConnection.getId())
|
|
11
|
+
await this.fileConnectionsTable.update(this.fileConnection);
|
|
12
|
+
else
|
|
13
|
+
await this.fileConnectionsTable.insert(this.fileConnection);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import PaymentMethods from "../stockObjects/PaymentMethods";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class PaymentMethodsMapper implements StockObjectMapper {
|
|
4
|
+
private paymentMethods;
|
|
5
|
+
private paymentMethodsTable;
|
|
6
|
+
constructor(paymentMethods: PaymentMethods);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class PaymentMethodsMapper {
|
|
3
|
+
paymentMethods;
|
|
4
|
+
paymentMethodsTable;
|
|
5
|
+
constructor(paymentMethods) {
|
|
6
|
+
this.paymentMethodsTable = DatabaseConnection.get().paymentMethods;
|
|
7
|
+
this.paymentMethods = paymentMethods;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.paymentMethods.getId())
|
|
11
|
+
await this.paymentMethodsTable.update(this.paymentMethods);
|
|
12
|
+
else
|
|
13
|
+
await this.paymentMethodsTable.insert(this.paymentMethods);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ResultLimitationI from "../types/ResultLimitationI";
|
|
2
|
+
import OrderByI from "../utils/OrderByI";
|
|
3
|
+
export default class QueryOptions {
|
|
4
|
+
static correctingSorting(querySortBy: any): OrderByI[];
|
|
5
|
+
static correctingLimitation(queryLimit: any, queryOffset: any): ResultLimitationI;
|
|
6
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ParameterType from "../types/parameters/ParameterType";
|
|
2
|
+
import Filters from "../utils/Filters";
|
|
3
|
+
import Parameters from "../utils/Parameters";
|
|
4
|
+
export default class QueryOptions {
|
|
5
|
+
static correctingSorting(querySortBy) {
|
|
6
|
+
const sortBy = Parameters.correct(querySortBy, { type: ParameterType.arrayObject });
|
|
7
|
+
const table = [];
|
|
8
|
+
if (sortBy[0]) {
|
|
9
|
+
sortBy.forEach((element) => {
|
|
10
|
+
const key = Parameters.correct(element.key, { type: ParameterType.string, filter: Filters.databaseColumn });
|
|
11
|
+
const order = Parameters.correct(element.order, { type: ParameterType.string });
|
|
12
|
+
table.push({ key, order });
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return table;
|
|
16
|
+
}
|
|
17
|
+
static correctingLimitation(queryLimit, queryOffset) {
|
|
18
|
+
const limit = Parameters.correct(queryLimit, { type: ParameterType.bigint });
|
|
19
|
+
const offset = Parameters.correct(queryOffset, { type: ParameterType.bigint });
|
|
20
|
+
return {
|
|
21
|
+
limit,
|
|
22
|
+
offset
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import QueryOptions from "../query/QueryOptions";
|
|
1
2
|
import ClientAccountI from "../types/ClientAccountI";
|
|
2
3
|
export default class ClientAccountReader {
|
|
3
4
|
static get(accountId: number): Promise<ClientAccountI>;
|
|
5
|
+
static getAll(queryOptions: QueryOptions): Promise<{
|
|
6
|
+
clientAccounts: ClientAccountI[];
|
|
7
|
+
quantity: number;
|
|
8
|
+
}>;
|
|
4
9
|
static getForEmail(email: string): Promise<ClientAccountI>;
|
|
5
10
|
static getIdForEmail(email: string): Promise<number>;
|
|
11
|
+
private static correctClientsFromRows;
|
|
6
12
|
private static correctData;
|
|
7
13
|
}
|
|
@@ -5,6 +5,15 @@ export default class ClientAccountReader {
|
|
|
5
5
|
const account = await connection.accounts.select(accountId);
|
|
6
6
|
return this.correctData(account);
|
|
7
7
|
}
|
|
8
|
+
static async getAll(queryOptions) {
|
|
9
|
+
const connection = DatabaseConnection.get();
|
|
10
|
+
const clientAccounts = await connection.accounts.selectAll(queryOptions);
|
|
11
|
+
const quantity = await connection.accounts.count(queryOptions);
|
|
12
|
+
return {
|
|
13
|
+
clientAccounts: this.correctClientsFromRows(clientAccounts),
|
|
14
|
+
quantity
|
|
15
|
+
};
|
|
16
|
+
}
|
|
8
17
|
static async getForEmail(email) {
|
|
9
18
|
const connection = DatabaseConnection.get();
|
|
10
19
|
const account = await connection.accounts.selectForEmail(email);
|
|
@@ -12,19 +21,27 @@ export default class ClientAccountReader {
|
|
|
12
21
|
}
|
|
13
22
|
static async getIdForEmail(email) {
|
|
14
23
|
const connection = DatabaseConnection.get();
|
|
15
|
-
const accountId = await connection.accounts.
|
|
24
|
+
const accountId = await connection.accounts.getIdForEmail(email);
|
|
16
25
|
return accountId;
|
|
17
26
|
}
|
|
18
|
-
static
|
|
27
|
+
static correctClientsFromRows(dataRows) {
|
|
28
|
+
const clients = [];
|
|
29
|
+
for (const dataRow of dataRows) {
|
|
30
|
+
const client = this.correctData(dataRow);
|
|
31
|
+
clients.push(client);
|
|
32
|
+
}
|
|
33
|
+
return clients;
|
|
34
|
+
}
|
|
35
|
+
static correctData(client) {
|
|
19
36
|
return {
|
|
20
|
-
id:
|
|
21
|
-
email:
|
|
22
|
-
createdAt:
|
|
23
|
-
activated:
|
|
24
|
-
deleted:
|
|
25
|
-
contactDetailsId:
|
|
26
|
-
deliveryDetailsId:
|
|
27
|
-
invoiceDetailsId:
|
|
37
|
+
id: client.id,
|
|
38
|
+
email: client.email,
|
|
39
|
+
createdAt: client.created_at,
|
|
40
|
+
activated: client.activated,
|
|
41
|
+
deleted: client.deleted,
|
|
42
|
+
contactDetailsId: client.contact_details_id,
|
|
43
|
+
deliveryDetailsId: client.delivery_details_id,
|
|
44
|
+
invoiceDetailsId: client.invoice_details_id,
|
|
28
45
|
};
|
|
29
46
|
}
|
|
30
47
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./AddressesReader";
|
|
3
|
+
export default class CompanyDataReader {
|
|
4
|
+
static async get() {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const companyData = await connection.companyData.select();
|
|
7
|
+
if (companyData) {
|
|
8
|
+
const address = companyData?.address_id ? await AddressesReader.get(companyData.address_id) : null;
|
|
9
|
+
return {
|
|
10
|
+
id: companyData.id,
|
|
11
|
+
name: companyData.name,
|
|
12
|
+
taxNumber: companyData.tax_number,
|
|
13
|
+
phoneNumber: companyData.phone_number,
|
|
14
|
+
address: address
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return {
|
|
19
|
+
id: 0,
|
|
20
|
+
name: '',
|
|
21
|
+
taxNumber: '',
|
|
22
|
+
phoneNumber: '',
|
|
23
|
+
address: {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -10,4 +10,9 @@ export default class DeliveryMethodReader {
|
|
|
10
10
|
const deliveryMethods = await connection.deliveryMethods.selectAll();
|
|
11
11
|
return deliveryMethods;
|
|
12
12
|
}
|
|
13
|
+
static async getAllActive() {
|
|
14
|
+
const connection = DatabaseConnection.get();
|
|
15
|
+
const deliveryMethods = await connection.deliveryMethods.selectAllActive();
|
|
16
|
+
return deliveryMethods;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class FileConnectionsReader {
|
|
3
|
+
static async getAllForFileId(fileId) {
|
|
4
|
+
const connection = DatabaseConnection.get();
|
|
5
|
+
const fileConnections = await connection.fileConnections.selectForFileId(fileId);
|
|
6
|
+
return this.correctFileConnections(fileConnections);
|
|
7
|
+
}
|
|
8
|
+
static correctFileConnections(fileConnectionsRows) {
|
|
9
|
+
const fileConnections = [];
|
|
10
|
+
for (let i = 0; i < fileConnectionsRows.length; i++) {
|
|
11
|
+
const fileConnection = this.correctFileConnection(fileConnectionsRows[i]);
|
|
12
|
+
fileConnections.push(fileConnection);
|
|
13
|
+
}
|
|
14
|
+
return fileConnections;
|
|
15
|
+
}
|
|
16
|
+
static correctFileConnection(fileConnections) {
|
|
17
|
+
const correctFileConnection = {
|
|
18
|
+
fileId: fileConnections.file_id,
|
|
19
|
+
connectionType: fileConnections.connection_type,
|
|
20
|
+
connectionId: fileConnections.connection_id,
|
|
21
|
+
sequence: fileConnections.sequence
|
|
22
|
+
};
|
|
23
|
+
return correctFileConnection;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -3,8 +3,10 @@ import QueryOptionsI from "../types/QueryOptionsI";
|
|
|
3
3
|
export default class ProductReader {
|
|
4
4
|
static get(productId: number): Promise<ProductI>;
|
|
5
5
|
static getForUrl(productUrl: string): Promise<ProductI>;
|
|
6
|
+
static getListForOrder(): Promise<any>;
|
|
6
7
|
static getAll(queryOptions: QueryOptionsI): Promise<ProductI[]>;
|
|
7
8
|
static getQuantity(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
9
|
private static correctProducts;
|
|
9
10
|
private static correctProduct;
|
|
11
|
+
private static correctProductForOrderList;
|
|
10
12
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
|
+
import FilesReader from "./FilesReader";
|
|
3
4
|
export default class ProductReader {
|
|
4
5
|
static async get(productId) {
|
|
5
6
|
const connection = DatabaseConnection.get();
|
|
@@ -11,6 +12,17 @@ export default class ProductReader {
|
|
|
11
12
|
const product = await connection.products.selectForUrl(productUrl);
|
|
12
13
|
return this.correctProduct(product);
|
|
13
14
|
}
|
|
15
|
+
static async getListForOrder() {
|
|
16
|
+
const connection = DatabaseConnection.get();
|
|
17
|
+
let correctProducts = [];
|
|
18
|
+
const products = await connection.products.selectListForOrder();
|
|
19
|
+
for (const product of products) {
|
|
20
|
+
const file = await FilesReader.get(product.file_id);
|
|
21
|
+
product.file = file;
|
|
22
|
+
correctProducts.push(this.correctProductForOrderList(product));
|
|
23
|
+
}
|
|
24
|
+
return correctProducts;
|
|
25
|
+
}
|
|
14
26
|
static async getAll(queryOptions) {
|
|
15
27
|
const connection = DatabaseConnection.get();
|
|
16
28
|
const products = await connection.products.selectAll(queryOptions);
|
|
@@ -49,4 +61,13 @@ export default class ProductReader {
|
|
|
49
61
|
grossPrice: calculateNetToGrossPrice(product.net_price, product.vat)
|
|
50
62
|
};
|
|
51
63
|
}
|
|
64
|
+
static correctProductForOrderList(product) {
|
|
65
|
+
return {
|
|
66
|
+
id: product.id,
|
|
67
|
+
title: product.title,
|
|
68
|
+
sku: product.sku,
|
|
69
|
+
file: product.file,
|
|
70
|
+
netPrice: product.net_price
|
|
71
|
+
};
|
|
72
|
+
}
|
|
52
73
|
}
|