@dascompany/database 0.0.4 → 0.0.6
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 +15 -4
- package/dist/TableConnection.d.ts +6 -6
- package/dist/TableConnection.js +6 -6
- package/dist/index.d.ts +8 -2
- package/dist/index.js +7 -2
- package/dist/mappers/FileConnectionMapper.js +4 -4
- package/dist/mappers/FileMapper.d.ts +9 -0
- package/dist/mappers/FileMapper.js +17 -0
- package/dist/mappers/ProductMapper.d.ts +9 -0
- package/dist/mappers/ProductMapper.js +20 -0
- package/dist/reader/CompanyDataReader.js +1 -1
- package/dist/reader/FilesReader.d.ts +7 -2
- package/dist/reader/FilesReader.js +24 -5
- package/dist/reader/OrderProductsReader.d.ts +1 -1
- package/dist/reader/ProductReader.d.ts +2 -1
- package/dist/reader/ProductReader.js +21 -13
- package/dist/repo/FilesRepo.d.ts +7 -0
- package/dist/repo/FilesRepo.js +26 -0
- package/dist/repo/OrderProductsRepo.d.ts +7 -0
- package/dist/repo/OrderProductsRepo.js +37 -0
- package/dist/stockObjects/File.d.ts +21 -0
- package/dist/stockObjects/File.js +50 -0
- package/dist/stockObjects/Order.d.ts +1 -0
- package/dist/stockObjects/Order.js +9 -0
- package/dist/stockObjects/OrderProduct.d.ts +1 -1
- package/dist/stockObjects/OrderProduct.js +2 -2
- package/dist/stockObjects/Product.d.ts +30 -0
- package/dist/stockObjects/Product.js +62 -3
- package/dist/tables/{ClientAccountsTable.d.ts → clients/ClientAccountsTable.d.ts} +4 -4
- package/dist/tables/{ClientAccountsTable.js → clients/ClientAccountsTable.js} +2 -2
- package/dist/tables/files/FilesTable.d.ts +12 -2
- package/dist/tables/files/FilesTable.js +48 -0
- package/dist/tables/orders/OrdersProductsTable.d.ts +5 -1
- package/dist/tables/orders/OrdersProductsTable.js +23 -6
- package/dist/tables/{DeliveryStatusTypesTable.d.ts → personalInformation/DeliveryStatusTypesTable.d.ts} +1 -1
- package/dist/tables/{DeliveryStatusTypesTable.js → personalInformation/DeliveryStatusTypesTable.js} +2 -2
- package/dist/tables/{DeliveryStatusesTable.d.ts → personalInformation/DeliveryStatusesTable.d.ts} +3 -3
- package/dist/tables/{DeliveryStatusesTable.js → personalInformation/DeliveryStatusesTable.js} +2 -2
- package/dist/tables/{AdminAccountsTable.d.ts → public/AdminAccountsTable.d.ts} +4 -4
- package/dist/tables/{AdminAccountsTable.js → public/AdminAccountsTable.js} +2 -2
- package/dist/tables/{ProductsTable.d.ts → public/ProductsTable.d.ts} +4 -4
- package/dist/tables/{ProductsTable.js → public/ProductsTable.js} +2 -2
- package/dist/types/CompanyDataI.d.ts +1 -1
- package/dist/types/OrderProductI.d.ts +11 -5
- package/dist/types/ProductI.d.ts +1 -0
- package/package.json +1 -1
- package/dist/tables/StatusTypesTable.d.ts +0 -4
- package/dist/tables/StatusTypesTable.js +0 -9
- package/dist/types/FileConnectionE.d.ts +0 -4
- package/dist/types/FileConnectionE.js +0 -5
package/dist/SQL.json
CHANGED
|
@@ -82,9 +82,13 @@
|
|
|
82
82
|
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)"
|
|
83
83
|
},
|
|
84
84
|
"ordersProducts": {
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
85
|
+
"selectProducts": "SELECT op.id, order_id, product_id, title, sku, p.file_id, op.net_price FROM orders.orders_products as op JOIN products as p ON op.product_id = p.id WHERE order_id = $order_id::BIGINT AND in_order = true",
|
|
86
|
+
"select": "SELECT id, order_id, product_id, in_order FROM orders.orders_products WHERE order_id = $order_id::BIGINT AND in_order = true",
|
|
87
|
+
"selectAll": "SELECT * FROM orders.orders_products $WHERE",
|
|
88
|
+
"getAllActiveForOrderId": "SELECT * FROM orders.orders_products WHERE order_id = $order_id::BIGINT and in_order = true",
|
|
89
|
+
"insert": "INSERT INTO orders.orders_products( id, order_id, product_id, net_price ) VALUES ( $id::BIGINT , $order_id::BIGINT, $product_id::BIGINT, $net_price::DOUBLE PRECISION )",
|
|
90
|
+
"selectNextId": "SELECT nextval('orders.orders_products_id'::regclass)",
|
|
91
|
+
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
88
92
|
},
|
|
89
93
|
"statuses": {
|
|
90
94
|
"selectForOrder": "SELECT s.id, order_id, created_at, user_id, st.key as type FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE order_id = $order_id::BIGINT ORDER BY s.id DESC LIMIT 1",
|
|
@@ -99,8 +103,15 @@
|
|
|
99
103
|
"selectNextId": "SELECT nextval('orders.payment_details_id'::regclass)"
|
|
100
104
|
},
|
|
101
105
|
"files": {
|
|
106
|
+
"selectId": "SELECT id FROM files.files $WHERE",
|
|
107
|
+
"selectAll": "SELECT f.id, f.name, f.orginal_name, f.catalog, f.size_kb, f.type, f.created_at FROM files.files as f $WHERE $ORDERBY",
|
|
102
108
|
"select": "SELECT id, name, orginal_name, catalog, size_kb, type, created_at FROM files.files WHERE id = $id::BIGINT",
|
|
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"
|
|
109
|
+
"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",
|
|
110
|
+
"selectNextId": "SELECT nextval('files.files_id'::regclass)",
|
|
111
|
+
"insert": "INSERT INTO files.files( id, name, orginal_name, catalog, size_kb, type, created_at ) VALUES ( $id::BIGINT, $name::TEXT, $orginal_name::TEXT, $catalog::TEXT, $size_kb::BIGINT, $type::TEXT, now() )",
|
|
112
|
+
"update": "UPDATE files.files SET name = $name::TEXT, orginal_name = $orginal_name::TEXT, catalog = $catalog::TEXT, size_kb = $size_kb::BIGINT, type = $type::TEXT WHERE id = $id::BIGINT ",
|
|
113
|
+
"count": "SELECT COUNT(*) AS total_rows FROM files.files as f $WHERE ",
|
|
114
|
+
"delete": "DELETE FROM files.files WHERE id = $id::BIGINT "
|
|
104
115
|
},
|
|
105
116
|
"fileConnections": {
|
|
106
117
|
"select": "SELECT file_id, sequence FROM files.file_connections WHERE connection_type = $connection_type::BIGINT and connection_id = $connection_id::BIGINT",
|
|
@@ -3,12 +3,12 @@ import Connection from './Connection';
|
|
|
3
3
|
import OrdersTable from './tables/orders/OrdersTable';
|
|
4
4
|
import FilesTable from './tables/files/FilesTable';
|
|
5
5
|
import StatusesTable from './tables/orders/StatusesTable';
|
|
6
|
-
import ProductsTable from './tables/ProductsTable';
|
|
7
|
-
import ClientAccountsTable from './tables/ClientAccountsTable';
|
|
6
|
+
import ProductsTable from './tables/public/ProductsTable';
|
|
7
|
+
import ClientAccountsTable from './tables/clients/ClientAccountsTable';
|
|
8
8
|
import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
9
9
|
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
10
10
|
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
11
|
-
import DeliveryStatusTypesTable from './tables/DeliveryStatusTypesTable';
|
|
11
|
+
import DeliveryStatusTypesTable from './tables/personalInformation/DeliveryStatusTypesTable';
|
|
12
12
|
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
13
13
|
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
14
14
|
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
@@ -16,11 +16,11 @@ import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTabl
|
|
|
16
16
|
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
17
17
|
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
18
18
|
import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
|
|
19
|
-
import DeliveryStatusesTable from './tables/DeliveryStatusesTable';
|
|
19
|
+
import DeliveryStatusesTable from './tables/personalInformation/DeliveryStatusesTable';
|
|
20
20
|
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
21
21
|
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
22
|
-
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
23
|
-
import StatusTypesTable from './tables/StatusTypesTable';
|
|
22
|
+
import AdminAccountsTable from './tables/public/AdminAccountsTable';
|
|
23
|
+
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
24
24
|
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
25
25
|
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
26
26
|
export default class TableConnection extends Connection {
|
package/dist/TableConnection.js
CHANGED
|
@@ -2,12 +2,12 @@ import Connection from './Connection';
|
|
|
2
2
|
import OrdersTable from './tables/orders/OrdersTable';
|
|
3
3
|
import FilesTable from './tables/files/FilesTable';
|
|
4
4
|
import StatusesTable from './tables/orders/StatusesTable';
|
|
5
|
-
import ProductsTable from './tables/ProductsTable';
|
|
6
|
-
import ClientAccountsTable from './tables/ClientAccountsTable';
|
|
5
|
+
import ProductsTable from './tables/public/ProductsTable';
|
|
6
|
+
import ClientAccountsTable from './tables/clients/ClientAccountsTable';
|
|
7
7
|
import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
8
8
|
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
9
9
|
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
10
|
-
import DeliveryStatusTypesTable from './tables/DeliveryStatusTypesTable';
|
|
10
|
+
import DeliveryStatusTypesTable from './tables/personalInformation/DeliveryStatusTypesTable';
|
|
11
11
|
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
12
12
|
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
13
13
|
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
@@ -15,11 +15,11 @@ import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTabl
|
|
|
15
15
|
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
16
16
|
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
17
17
|
import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
|
|
18
|
-
import DeliveryStatusesTable from './tables/DeliveryStatusesTable';
|
|
18
|
+
import DeliveryStatusesTable from './tables/personalInformation/DeliveryStatusesTable';
|
|
19
19
|
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
20
20
|
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
21
|
-
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
22
|
-
import StatusTypesTable from './tables/StatusTypesTable';
|
|
21
|
+
import AdminAccountsTable from './tables/public/AdminAccountsTable';
|
|
22
|
+
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
23
23
|
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
24
24
|
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
25
25
|
export default class TableConnection extends Connection {
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,6 @@ import AdminRepo from './repo/AdminRepo';
|
|
|
46
46
|
import TableConnection from './TableConnection';
|
|
47
47
|
import ParameterType from './types/parameters/ParameterType';
|
|
48
48
|
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
49
|
-
import FileConnectionE from './types/FileConnectionE';
|
|
50
49
|
import ConnectorE from './types/ConnectorE';
|
|
51
50
|
import ParameterI from './types/ParameterI';
|
|
52
51
|
import QueryOptionsI from './types/QueryOptionsI';
|
|
@@ -59,4 +58,11 @@ import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
|
59
58
|
import StatusTypesReader from './reader/StatusTypesReader';
|
|
60
59
|
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
61
60
|
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
62
|
-
|
|
61
|
+
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
62
|
+
import OrderByI from "./utils/OrderByI";
|
|
63
|
+
import FilesRepo from './repo/FilesRepo';
|
|
64
|
+
import File from './stockObjects/File';
|
|
65
|
+
import QueryOptions from './query/QueryOptions';
|
|
66
|
+
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
67
|
+
import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
68
|
+
export { TableConnection, DatabaseConnection, File, OrderByI, ParameterType, ConnectorE, FileConnectionTypeE, PaymentStatusE, Parameters, ParameterI, QueryOptions, QueryOptionsI, ResultLimitationI, OrderProductI, ParameterFilter, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, CompanyDataReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, FilesRepo, OrderProductsRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,6 @@ import AdminRepo from './repo/AdminRepo';
|
|
|
46
46
|
import TableConnection from './TableConnection';
|
|
47
47
|
import ParameterType from './types/parameters/ParameterType';
|
|
48
48
|
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
49
|
-
import FileConnectionE from './types/FileConnectionE';
|
|
50
49
|
import ConnectorE from './types/ConnectorE';
|
|
51
50
|
import PaymentStatusE from './types/PaymentStatusE';
|
|
52
51
|
import Parameters from './utils/Parameters';
|
|
@@ -54,4 +53,10 @@ import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
|
54
53
|
import StatusTypesReader from './reader/StatusTypesReader';
|
|
55
54
|
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
56
55
|
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
57
|
-
|
|
56
|
+
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
57
|
+
import FilesRepo from './repo/FilesRepo';
|
|
58
|
+
import File from './stockObjects/File';
|
|
59
|
+
import QueryOptions from './query/QueryOptions';
|
|
60
|
+
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
61
|
+
import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
62
|
+
export { TableConnection, DatabaseConnection, File, ParameterType, ConnectorE, FileConnectionTypeE, PaymentStatusE, Parameters, QueryOptions, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, CompanyDataReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, FilesRepo, OrderProductsRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
|
@@ -7,10 +7,10 @@ export default class FileConnectionMapper {
|
|
|
7
7
|
this.fileConnection = fileConnection;
|
|
8
8
|
}
|
|
9
9
|
async save() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const id = this.fileConnection.getId();
|
|
11
|
+
if (id)
|
|
12
|
+
await this.fileConnectionsTable.delete(id);
|
|
13
|
+
await this.fileConnectionsTable.insert(this.fileConnection);
|
|
14
14
|
}
|
|
15
15
|
async delete() {
|
|
16
16
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import File from "../stockObjects/File";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class FileMapper implements StockObjectMapper {
|
|
4
|
+
private file;
|
|
5
|
+
private filesTable;
|
|
6
|
+
constructor(file: File);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class FileMapper {
|
|
3
|
+
file;
|
|
4
|
+
filesTable;
|
|
5
|
+
constructor(file) {
|
|
6
|
+
this.filesTable = DatabaseConnection.get().files;
|
|
7
|
+
this.file = file;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.file.getId())
|
|
11
|
+
await this.filesTable.update(this.file);
|
|
12
|
+
else
|
|
13
|
+
await this.filesTable.insert(this.file);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Product from "../stockObjects/Product";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class ProductMapper implements StockObjectMapper {
|
|
4
|
+
private product;
|
|
5
|
+
private productTable;
|
|
6
|
+
constructor(product: Product);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class ProductMapper {
|
|
3
|
+
product;
|
|
4
|
+
productTable;
|
|
5
|
+
constructor(product) {
|
|
6
|
+
this.productTable = DatabaseConnection.get().products;
|
|
7
|
+
this.product = product;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.product.getId() && !this.product.getDeleted())
|
|
11
|
+
await this.productTable.update(this.product);
|
|
12
|
+
else
|
|
13
|
+
await this.productTable.insert(this.product);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
const id = this.product.getId();
|
|
17
|
+
if (id)
|
|
18
|
+
await this.productTable.delete(id);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
2
|
import FileI from "../types/FileI";
|
|
3
|
+
import QueryOptionsI from "../types/QueryOptionsI";
|
|
3
4
|
export default class FilesReader {
|
|
4
5
|
static get(fileId: number): Promise<FileI>;
|
|
5
|
-
static
|
|
6
|
+
static getAll(queryOptions: QueryOptionsI): Promise<FileI[]>;
|
|
7
|
+
static isExist(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
|
+
static getQuantity(queryOptions: any): Promise<number>;
|
|
9
|
+
static getForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<FileI[]>;
|
|
10
|
+
private static correctFiles;
|
|
6
11
|
private static correctFile;
|
|
7
12
|
}
|
|
@@ -5,14 +5,33 @@ export default class FilesReader {
|
|
|
5
5
|
const file = await connection.files.select(fileId);
|
|
6
6
|
return this.correctFile(file);
|
|
7
7
|
}
|
|
8
|
+
static async getAll(queryOptions) {
|
|
9
|
+
const connection = DatabaseConnection.get();
|
|
10
|
+
const file = await connection.files.selectAll(queryOptions);
|
|
11
|
+
return this.correctFiles(file);
|
|
12
|
+
}
|
|
13
|
+
static async isExist(queryOptions) {
|
|
14
|
+
const connection = DatabaseConnection.get();
|
|
15
|
+
const fileId = await connection.files.selectId(queryOptions);
|
|
16
|
+
return fileId;
|
|
17
|
+
}
|
|
18
|
+
static async getQuantity(queryOptions) {
|
|
19
|
+
const connection = DatabaseConnection.get();
|
|
20
|
+
const quantity = await connection.files.count(queryOptions);
|
|
21
|
+
return quantity;
|
|
22
|
+
}
|
|
8
23
|
static async getForConnection(connectionType, connectionId) {
|
|
9
24
|
const connection = DatabaseConnection.get();
|
|
10
25
|
const files = await connection.files.selectForConnection(connectionType, connectionId);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
return this.correctFiles(files);
|
|
27
|
+
}
|
|
28
|
+
static correctFiles(fileRows) {
|
|
29
|
+
const fileConnections = [];
|
|
30
|
+
for (let i = 0; i < fileRows.length; i++) {
|
|
31
|
+
const fileConnection = this.correctFile(fileRows[i]);
|
|
32
|
+
fileConnections.push(fileConnection);
|
|
33
|
+
}
|
|
34
|
+
return fileConnections;
|
|
16
35
|
}
|
|
17
36
|
static correctFile(file) {
|
|
18
37
|
const correctFile = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OrderProductI from "../types/OrderProductI";
|
|
2
2
|
export default class OrderProductsReader {
|
|
3
|
-
static getForOrder(orderId: number): Promise<
|
|
3
|
+
static getForOrder(orderId: number): Promise<any[]>;
|
|
4
4
|
static getAll(orderId: number): Promise<OrderProductI[]>;
|
|
5
5
|
private static correctProduct;
|
|
6
6
|
}
|
|
@@ -2,10 +2,11 @@ import ProductI from "../types/ProductI";
|
|
|
2
2
|
import QueryOptionsI from "../types/QueryOptionsI";
|
|
3
3
|
export default class ProductReader {
|
|
4
4
|
static get(productId: number): Promise<ProductI>;
|
|
5
|
+
static getIdForSku(productSku: string): Promise<number>;
|
|
5
6
|
static getForUrl(productUrl: string): Promise<ProductI>;
|
|
6
|
-
static getListForOrder(): Promise<any>;
|
|
7
7
|
static getAll(queryOptions: QueryOptionsI): Promise<ProductI[]>;
|
|
8
8
|
static getQuantity(queryOptions: QueryOptionsI): Promise<number>;
|
|
9
|
+
static getListForOrder(): Promise<any>;
|
|
9
10
|
private static correctProducts;
|
|
10
11
|
private static correctProduct;
|
|
11
12
|
private static correctProductForOrderList;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
3
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
4
|
import FilesReader from "./FilesReader";
|
|
4
5
|
export default class ProductReader {
|
|
5
6
|
static async get(productId) {
|
|
6
7
|
const connection = DatabaseConnection.get();
|
|
7
8
|
const product = await connection.products.select(productId);
|
|
8
|
-
|
|
9
|
+
const thumbnail = await FilesReader.get(product.file_id);
|
|
10
|
+
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
11
|
+
return this.correctProduct(product, thumbnail, files);
|
|
12
|
+
}
|
|
13
|
+
static async getIdForSku(productSku) {
|
|
14
|
+
const connection = DatabaseConnection.get();
|
|
15
|
+
return await connection.products.selectIdForSku(productSku);
|
|
9
16
|
}
|
|
10
17
|
static async getForUrl(productUrl) {
|
|
11
18
|
const connection = DatabaseConnection.get();
|
|
12
19
|
const product = await connection.products.selectForUrl(productUrl);
|
|
13
20
|
return this.correctProduct(product);
|
|
14
21
|
}
|
|
22
|
+
static async getAll(queryOptions) {
|
|
23
|
+
const connection = DatabaseConnection.get();
|
|
24
|
+
const products = await connection.products.selectAll(queryOptions);
|
|
25
|
+
return this.correctProducts(products);
|
|
26
|
+
}
|
|
27
|
+
static async getQuantity(queryOptions) {
|
|
28
|
+
const connection = DatabaseConnection.get();
|
|
29
|
+
const quantity = await connection.products.count(queryOptions);
|
|
30
|
+
return quantity;
|
|
31
|
+
}
|
|
15
32
|
static async getListForOrder() {
|
|
16
33
|
const connection = DatabaseConnection.get();
|
|
17
34
|
let correctProducts = [];
|
|
@@ -23,16 +40,6 @@ export default class ProductReader {
|
|
|
23
40
|
}
|
|
24
41
|
return correctProducts;
|
|
25
42
|
}
|
|
26
|
-
static async getAll(queryOptions) {
|
|
27
|
-
const connection = DatabaseConnection.get();
|
|
28
|
-
const products = await connection.products.selectAll(queryOptions);
|
|
29
|
-
return this.correctProducts(products);
|
|
30
|
-
}
|
|
31
|
-
static async getQuantity(queryOptions) {
|
|
32
|
-
const connection = DatabaseConnection.get();
|
|
33
|
-
const quantity = await connection.products.count(queryOptions);
|
|
34
|
-
return quantity;
|
|
35
|
-
}
|
|
36
43
|
static correctProducts(products) {
|
|
37
44
|
const correctProducts = [];
|
|
38
45
|
for (let i = 0; i < products.length; i++) {
|
|
@@ -41,7 +48,7 @@ export default class ProductReader {
|
|
|
41
48
|
}
|
|
42
49
|
return correctProducts;
|
|
43
50
|
}
|
|
44
|
-
static correctProduct(product) {
|
|
51
|
+
static correctProduct(product, thumbnail, files) {
|
|
45
52
|
return {
|
|
46
53
|
id: product.id,
|
|
47
54
|
sku: product.sku,
|
|
@@ -55,9 +62,10 @@ export default class ProductReader {
|
|
|
55
62
|
width: product.width,
|
|
56
63
|
height: product.height,
|
|
57
64
|
length: product.length,
|
|
58
|
-
fileId: product.file_id,
|
|
59
65
|
createdAt: product.created_at,
|
|
60
66
|
deleted: product.deleted,
|
|
67
|
+
thumbnail: thumbnail ? thumbnail : null,
|
|
68
|
+
files: files,
|
|
61
69
|
grossPrice: calculateNetToGrossPrice(product.net_price, product.vat)
|
|
62
70
|
};
|
|
63
71
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
|
+
export default class FilesRepo {
|
|
3
|
+
static get(fileId: number): Promise<any>;
|
|
4
|
+
static getAllForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<any>;
|
|
5
|
+
private static createFilesFromRows;
|
|
6
|
+
private static createFileFromRow;
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import File from "../stockObjects/File";
|
|
3
|
+
export default class FilesRepo {
|
|
4
|
+
static async get(fileId) {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const file = await connection.files.select(fileId);
|
|
7
|
+
return this.createFileFromRow(file);
|
|
8
|
+
}
|
|
9
|
+
static async getAllForConnection(connectionType, connectionId) {
|
|
10
|
+
const connection = DatabaseConnection.get();
|
|
11
|
+
const files = await connection.files.selectForConnection(connectionType, connectionId);
|
|
12
|
+
return this.createFilesFromRows(files);
|
|
13
|
+
}
|
|
14
|
+
static async createFilesFromRows(dataRows) {
|
|
15
|
+
const files = [];
|
|
16
|
+
for (const dataRow of dataRows) {
|
|
17
|
+
const file = await this.createFileFromRow(dataRow);
|
|
18
|
+
files.push(file);
|
|
19
|
+
}
|
|
20
|
+
return files;
|
|
21
|
+
}
|
|
22
|
+
static createFileFromRow(file) {
|
|
23
|
+
const correctFile = new File(file.name, file.catalog, file.size_kb, file.type, file.orginal_name);
|
|
24
|
+
return correctFile;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import OrderProduct from "../stockObjects/OrderProduct";
|
|
2
|
+
export default class OrderProductsRepo {
|
|
3
|
+
static getAllActiveForOrderId(orderId: number): Promise<OrderProduct[]>;
|
|
4
|
+
static getAllForIds(orderProductsIds: number[]): Promise<OrderProduct[]>;
|
|
5
|
+
private static createOrdersProductsFromRows;
|
|
6
|
+
private static createOrdersProductFromRow;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import OrderProduct from "../stockObjects/OrderProduct";
|
|
3
|
+
import ConnectorE from "../types/ConnectorE";
|
|
4
|
+
import ParameterType from "../types/parameters/ParameterType";
|
|
5
|
+
export default class OrderProductsRepo {
|
|
6
|
+
static async getAllActiveForOrderId(orderId) {
|
|
7
|
+
const connection = DatabaseConnection.get();
|
|
8
|
+
const orderProducts = await connection.ordersProducts.selectAll(orderId);
|
|
9
|
+
return this.createOrdersProductsFromRows(orderProducts);
|
|
10
|
+
}
|
|
11
|
+
static async getAllForIds(orderProductsIds) {
|
|
12
|
+
const connection = DatabaseConnection.get();
|
|
13
|
+
const queryOptions = {
|
|
14
|
+
where: {
|
|
15
|
+
connector: ConnectorE.and,
|
|
16
|
+
parameters: [
|
|
17
|
+
{ name: 'id', type: ParameterType.arrayBigint, value: orderProductsIds },
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const orderProducts = await connection.ordersProducts.selectAllForIds(queryOptions);
|
|
22
|
+
return this.createOrdersProductsFromRows(orderProducts);
|
|
23
|
+
}
|
|
24
|
+
static async createOrdersProductsFromRows(dataRows) {
|
|
25
|
+
const products = [];
|
|
26
|
+
for (const dataRow of dataRows) {
|
|
27
|
+
const product = await this.createOrdersProductFromRow(dataRow);
|
|
28
|
+
products.push(product);
|
|
29
|
+
}
|
|
30
|
+
return products;
|
|
31
|
+
}
|
|
32
|
+
static async createOrdersProductFromRow(dataRow) {
|
|
33
|
+
const orderProduct = new OrderProduct(dataRow.order_id, dataRow.product_id, dataRow.net_price, dataRow.in_order);
|
|
34
|
+
orderProduct.setId(dataRow.id);
|
|
35
|
+
return orderProduct;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import StockObject from "../types/StockObject";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class File extends StockObject {
|
|
4
|
+
private name;
|
|
5
|
+
private catalog;
|
|
6
|
+
private sizeKb;
|
|
7
|
+
private type;
|
|
8
|
+
private orginalName;
|
|
9
|
+
constructor(name: string, catalog: string, sizeKb: number, type: string, orginalName: string);
|
|
10
|
+
getName(): string;
|
|
11
|
+
getCatalog(): string;
|
|
12
|
+
getSizeKb(): number;
|
|
13
|
+
getType(): string;
|
|
14
|
+
getOrginalName(): string;
|
|
15
|
+
setName(name: string): void;
|
|
16
|
+
setCatalog(catalog: string): void;
|
|
17
|
+
setSizeKb(sizeKb: number): void;
|
|
18
|
+
setType(type: string): void;
|
|
19
|
+
setOrginalName(orginalName: string): void;
|
|
20
|
+
protected getMapper(): StockObjectMapper;
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import FileMapper from "../mappers/FileMapper";
|
|
2
|
+
import StockObject from "../types/StockObject";
|
|
3
|
+
export default class File extends StockObject {
|
|
4
|
+
name;
|
|
5
|
+
catalog;
|
|
6
|
+
sizeKb;
|
|
7
|
+
type;
|
|
8
|
+
orginalName;
|
|
9
|
+
constructor(name, catalog, sizeKb, type, orginalName) {
|
|
10
|
+
super();
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.catalog = catalog;
|
|
13
|
+
this.sizeKb = sizeKb;
|
|
14
|
+
this.type = type;
|
|
15
|
+
this.orginalName = orginalName;
|
|
16
|
+
}
|
|
17
|
+
getName() {
|
|
18
|
+
return this.name;
|
|
19
|
+
}
|
|
20
|
+
getCatalog() {
|
|
21
|
+
return this.catalog;
|
|
22
|
+
}
|
|
23
|
+
getSizeKb() {
|
|
24
|
+
return this.sizeKb;
|
|
25
|
+
}
|
|
26
|
+
getType() {
|
|
27
|
+
return this.type;
|
|
28
|
+
}
|
|
29
|
+
getOrginalName() {
|
|
30
|
+
return this.orginalName;
|
|
31
|
+
}
|
|
32
|
+
setName(name) {
|
|
33
|
+
this.name = name;
|
|
34
|
+
}
|
|
35
|
+
setCatalog(catalog) {
|
|
36
|
+
this.catalog = catalog;
|
|
37
|
+
}
|
|
38
|
+
setSizeKb(sizeKb) {
|
|
39
|
+
this.sizeKb = sizeKb;
|
|
40
|
+
}
|
|
41
|
+
setType(type) {
|
|
42
|
+
this.type = type;
|
|
43
|
+
}
|
|
44
|
+
setOrginalName(orginalName) {
|
|
45
|
+
this.orginalName = orginalName;
|
|
46
|
+
}
|
|
47
|
+
getMapper() {
|
|
48
|
+
return new FileMapper(this);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -36,5 +36,6 @@ export default class Order extends StockObject {
|
|
|
36
36
|
setInvoiceDetailsId(invoiceDetailsId: number): void;
|
|
37
37
|
setPaymentDetailsId(paymentDetailsId: number): void;
|
|
38
38
|
setZsiId(zsiId: number): void;
|
|
39
|
+
calculateAndUpdatePrice(): Promise<void>;
|
|
39
40
|
protected getMapper(): StockObjectMapper;
|
|
40
41
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import OrderMapper from "../mappers/OrderMapper";
|
|
2
|
+
import OrderProductsRepo from "../repo/OrderProductsRepo";
|
|
2
3
|
import StockObject from "../types/StockObject";
|
|
3
4
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
4
5
|
export default class Order extends StockObject {
|
|
@@ -82,6 +83,14 @@ export default class Order extends StockObject {
|
|
|
82
83
|
setZsiId(zsiId) {
|
|
83
84
|
this.zsiId = zsiId;
|
|
84
85
|
}
|
|
86
|
+
async calculateAndUpdatePrice() {
|
|
87
|
+
let totalPrice = 0;
|
|
88
|
+
const orderProducts = await OrderProductsRepo.getAllActiveForOrderId(this.getId());
|
|
89
|
+
for (const product of orderProducts) {
|
|
90
|
+
totalPrice += product.getNetPrice();
|
|
91
|
+
}
|
|
92
|
+
this.setPrice(totalPrice);
|
|
93
|
+
}
|
|
85
94
|
getMapper() {
|
|
86
95
|
return new OrderMapper(this);
|
|
87
96
|
}
|
|
@@ -5,7 +5,7 @@ export default class OrderProduct extends StockObject {
|
|
|
5
5
|
private productId;
|
|
6
6
|
private netPrice;
|
|
7
7
|
private inOrder;
|
|
8
|
-
constructor(orderId: number, productId: number, netPrice: number);
|
|
8
|
+
constructor(orderId: number, productId: number, netPrice: number, inOrder: boolean);
|
|
9
9
|
getOrderId(): number;
|
|
10
10
|
getProductId(): number;
|
|
11
11
|
getNetPrice(): number;
|
|
@@ -5,12 +5,12 @@ export default class OrderProduct extends StockObject {
|
|
|
5
5
|
productId;
|
|
6
6
|
netPrice;
|
|
7
7
|
inOrder;
|
|
8
|
-
constructor(orderId, productId, netPrice) {
|
|
8
|
+
constructor(orderId, productId, netPrice, inOrder) {
|
|
9
9
|
super();
|
|
10
10
|
this.orderId = orderId;
|
|
11
11
|
this.productId = productId;
|
|
12
12
|
this.netPrice = netPrice;
|
|
13
|
-
this.inOrder =
|
|
13
|
+
this.inOrder = inOrder;
|
|
14
14
|
}
|
|
15
15
|
getOrderId() {
|
|
16
16
|
return this.orderId;
|
|
@@ -35,6 +35,36 @@ export default class Product extends StockObject {
|
|
|
35
35
|
getDeleted(): boolean;
|
|
36
36
|
getFile(): Promise<FileI | null>;
|
|
37
37
|
getFiles(): Promise<FileI[] | null>;
|
|
38
|
+
getData(): {
|
|
39
|
+
id: number | null;
|
|
40
|
+
sku: string;
|
|
41
|
+
url: string;
|
|
42
|
+
title: string;
|
|
43
|
+
description: string;
|
|
44
|
+
netPrice: number;
|
|
45
|
+
vat: number;
|
|
46
|
+
color: string;
|
|
47
|
+
quantity: number;
|
|
48
|
+
width: number;
|
|
49
|
+
length: number;
|
|
50
|
+
height: number;
|
|
51
|
+
deleted: boolean;
|
|
52
|
+
createdAt: number | null;
|
|
53
|
+
fileId: number;
|
|
54
|
+
};
|
|
55
|
+
calculateGrossPrice(): number;
|
|
38
56
|
setCreatedAt(createdAt: any): void;
|
|
57
|
+
setUrl(url: string): string;
|
|
58
|
+
setTitle(title: string): string;
|
|
59
|
+
setDescription(description: string): string;
|
|
60
|
+
setNetPrice(netPrice: number): number;
|
|
61
|
+
setVat(vat: number): number;
|
|
62
|
+
setColor(color: string): string;
|
|
63
|
+
setQuantity(quantity: number): number;
|
|
64
|
+
setWidth(width: number): number;
|
|
65
|
+
setLength(length: number): number;
|
|
66
|
+
setHeight(height: number): number;
|
|
67
|
+
setFileId(fileId: number): number;
|
|
68
|
+
setDeleted(deleted: boolean): boolean;
|
|
39
69
|
protected getMapper(): StockObjectMapper;
|
|
40
70
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import ProductMapper from "../mappers/ProductMapper";
|
|
1
2
|
import FilesReader from "../reader/FilesReader";
|
|
2
|
-
import
|
|
3
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
3
4
|
import StockObject from "../types/StockObject";
|
|
4
5
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
5
6
|
export default class Product extends StockObject {
|
|
@@ -89,16 +90,74 @@ export default class Product extends StockObject {
|
|
|
89
90
|
if (!this.files) {
|
|
90
91
|
const id = this.getId();
|
|
91
92
|
if (id) {
|
|
92
|
-
const files = await FilesReader.getForConnection(
|
|
93
|
+
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, id);
|
|
93
94
|
this.files = files;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
return this.files;
|
|
97
98
|
}
|
|
99
|
+
getData() {
|
|
100
|
+
return {
|
|
101
|
+
id: this.getId(),
|
|
102
|
+
sku: this.sku,
|
|
103
|
+
url: this.url,
|
|
104
|
+
title: this.title,
|
|
105
|
+
description: this.description,
|
|
106
|
+
netPrice: this.netPrice,
|
|
107
|
+
vat: this.vat,
|
|
108
|
+
color: this.color,
|
|
109
|
+
quantity: this.quantity,
|
|
110
|
+
width: this.width,
|
|
111
|
+
length: this.length,
|
|
112
|
+
height: this.height,
|
|
113
|
+
deleted: this.deleted,
|
|
114
|
+
createdAt: this.createdAt,
|
|
115
|
+
fileId: this.fileId,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
calculateGrossPrice() {
|
|
119
|
+
return calculateNetToGrossPrice(this.netPrice, this.vat);
|
|
120
|
+
}
|
|
98
121
|
setCreatedAt(createdAt) {
|
|
99
122
|
this.createdAt = createdAt;
|
|
100
123
|
}
|
|
124
|
+
setUrl(url) {
|
|
125
|
+
return this.url = url;
|
|
126
|
+
}
|
|
127
|
+
setTitle(title) {
|
|
128
|
+
return this.title = title;
|
|
129
|
+
}
|
|
130
|
+
setDescription(description) {
|
|
131
|
+
return this.description = description;
|
|
132
|
+
}
|
|
133
|
+
setNetPrice(netPrice) {
|
|
134
|
+
return this.netPrice = netPrice;
|
|
135
|
+
}
|
|
136
|
+
setVat(vat) {
|
|
137
|
+
return this.vat = vat;
|
|
138
|
+
}
|
|
139
|
+
setColor(color) {
|
|
140
|
+
return this.color = color;
|
|
141
|
+
}
|
|
142
|
+
setQuantity(quantity) {
|
|
143
|
+
return this.quantity = quantity;
|
|
144
|
+
}
|
|
145
|
+
setWidth(width) {
|
|
146
|
+
return this.width = width;
|
|
147
|
+
}
|
|
148
|
+
setLength(length) {
|
|
149
|
+
return this.length = length;
|
|
150
|
+
}
|
|
151
|
+
setHeight(height) {
|
|
152
|
+
return this.height = height;
|
|
153
|
+
}
|
|
154
|
+
setFileId(fileId) {
|
|
155
|
+
return this.fileId = fileId;
|
|
156
|
+
}
|
|
157
|
+
setDeleted(deleted) {
|
|
158
|
+
return this.deleted = deleted;
|
|
159
|
+
}
|
|
101
160
|
getMapper() {
|
|
102
|
-
|
|
161
|
+
return new ProductMapper(this);
|
|
103
162
|
}
|
|
104
163
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Table from '
|
|
2
|
-
import ClientAccountRow from '
|
|
3
|
-
import Client from '
|
|
4
|
-
import QueryOptions from '
|
|
1
|
+
import Table from '../../Table';
|
|
2
|
+
import ClientAccountRow from '../../types/rows/ClientAccountRow';
|
|
3
|
+
import Client from '../../stockObjects/Client';
|
|
4
|
+
import QueryOptions from '../../query/QueryOptions';
|
|
5
5
|
export default class ClientAccountsTable extends Table {
|
|
6
6
|
select(accountId: number): Promise<ClientAccountRow>;
|
|
7
7
|
selectEmail(id: number): Promise<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Table from '
|
|
2
|
-
import * as SQL from '
|
|
1
|
+
import Table from '../../Table';
|
|
2
|
+
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class ClientAccountsTable extends Table {
|
|
4
4
|
async select(accountId) {
|
|
5
5
|
const query = this.createQuery(SQL.accounts.select);
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import FileRow from '../../types/rows/FileRow';
|
|
3
|
-
import
|
|
3
|
+
import FileConnectionTypeE from '../../types/FileConnectionTypeE';
|
|
4
|
+
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
5
|
+
import File from '../../stockObjects/File';
|
|
4
6
|
export default class FilesTable extends Table {
|
|
7
|
+
selectId(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
|
+
selectAll(queryOptions: QueryOptionsI): Promise<FileRow[]>;
|
|
5
9
|
select(fileId: number): Promise<FileRow>;
|
|
6
|
-
selectForConnection(connectionType:
|
|
10
|
+
selectForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<FileRow[]>;
|
|
11
|
+
insert(file: File): Promise<boolean>;
|
|
12
|
+
update(fileData: File): Promise<boolean>;
|
|
13
|
+
count(queryOptions: QueryOptionsI): Promise<number>;
|
|
14
|
+
private bindParameters;
|
|
15
|
+
delete(fileId: number): Promise<number>;
|
|
16
|
+
private selectNextId;
|
|
7
17
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class FilesTable extends Table {
|
|
4
|
+
async selectId(queryOptions) {
|
|
5
|
+
const query = this.createQuery(SQL.files.selectId, queryOptions);
|
|
6
|
+
const result = await query.execute();
|
|
7
|
+
return result.getValue();
|
|
8
|
+
}
|
|
9
|
+
async selectAll(queryOptions) {
|
|
10
|
+
const query = this.createQuery(SQL.files.selectAll, queryOptions);
|
|
11
|
+
const result = await query.execute();
|
|
12
|
+
return result.getRows();
|
|
13
|
+
}
|
|
4
14
|
async select(fileId) {
|
|
5
15
|
const query = this.createQuery(SQL.files.select);
|
|
6
16
|
query.bindParameter('id', fileId);
|
|
@@ -14,4 +24,42 @@ export default class FilesTable extends Table {
|
|
|
14
24
|
const result = await query.execute();
|
|
15
25
|
return result.getRows();
|
|
16
26
|
}
|
|
27
|
+
async insert(file) {
|
|
28
|
+
const query = this.createQuery(SQL.files.insert);
|
|
29
|
+
const id = await this.selectNextId();
|
|
30
|
+
query.bindParameter('id', id);
|
|
31
|
+
this.bindParameters(query, file);
|
|
32
|
+
await query.execute();
|
|
33
|
+
file.setId(id);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
async update(fileData) {
|
|
37
|
+
const query = this.createQuery(SQL.files.update);
|
|
38
|
+
this.bindParameters(query, fileData);
|
|
39
|
+
await query.execute();
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
async count(queryOptions) {
|
|
43
|
+
const query = this.createQuery(SQL.files.count, queryOptions);
|
|
44
|
+
const result = await query.execute();
|
|
45
|
+
return result.getValue();
|
|
46
|
+
}
|
|
47
|
+
bindParameters(query, file) {
|
|
48
|
+
query.bindParameter('name', file.getName());
|
|
49
|
+
query.bindParameter('orginal_name', file.getOrginalName());
|
|
50
|
+
query.bindParameter('catalog', file.getCatalog());
|
|
51
|
+
query.bindParameter('size_kb', file.getSizeKb());
|
|
52
|
+
query.bindParameter('type', file.getType());
|
|
53
|
+
}
|
|
54
|
+
async delete(fileId) {
|
|
55
|
+
const query = this.createQuery(SQL.files.delete);
|
|
56
|
+
query.bindParameter('file_id', fileId);
|
|
57
|
+
const response = await query.execute();
|
|
58
|
+
return response.getRowCount();
|
|
59
|
+
}
|
|
60
|
+
async selectNextId() {
|
|
61
|
+
const query = this.createQuery(SQL.files.selectNextId);
|
|
62
|
+
const result = await query.execute();
|
|
63
|
+
return result.getValue();
|
|
64
|
+
}
|
|
17
65
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import OrderProductRow from '../../types/rows/OrderProductRow';
|
|
3
3
|
import OrderProduct from '../../stockObjects/OrderProduct';
|
|
4
|
+
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
4
5
|
export default class OrdersProductsTable extends Table {
|
|
5
6
|
selectAll(orderId: number): Promise<OrderProductRow[]>;
|
|
6
|
-
|
|
7
|
+
selectAllForIds(queryOprions: QueryOptionsI): Promise<OrderProduct[]>;
|
|
8
|
+
delete(orderProduct: OrderProduct): Promise<boolean>;
|
|
9
|
+
private bindParams;
|
|
10
|
+
insert(orderProduct: OrderProduct): Promise<boolean>;
|
|
7
11
|
private selectNextId;
|
|
8
12
|
}
|
|
@@ -2,20 +2,37 @@ import Table from '../../Table';
|
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class OrdersProductsTable extends Table {
|
|
4
4
|
async selectAll(orderId) {
|
|
5
|
-
const query = this.createQuery(SQL.ordersProducts.
|
|
5
|
+
const query = this.createQuery(SQL.ordersProducts.getAllActiveForOrderId);
|
|
6
6
|
query.bindParameter('order_id', orderId);
|
|
7
|
-
const
|
|
8
|
-
return
|
|
7
|
+
const result = await query.execute();
|
|
8
|
+
return result.getRows();
|
|
9
9
|
}
|
|
10
|
-
async
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
async selectAllForIds(queryOprions) {
|
|
11
|
+
const query = this.createQuery(SQL.ordersProducts.selectAll, queryOprions);
|
|
12
|
+
const result = await query.execute();
|
|
13
|
+
return result.getRows();
|
|
14
|
+
}
|
|
15
|
+
async delete(orderProduct) {
|
|
16
|
+
const query = this.createQuery(SQL.ordersProducts.delete);
|
|
17
|
+
const id = orderProduct.getId();
|
|
13
18
|
query.bindParameter('id', id);
|
|
19
|
+
await query.execute();
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
bindParams(query, orderProduct) {
|
|
14
23
|
query.bindParameter('order_id', orderProduct.getOrderId());
|
|
15
24
|
query.bindParameter('product_id', orderProduct.getProductId());
|
|
16
25
|
query.bindParameter('net_price', orderProduct.getNetPrice());
|
|
26
|
+
query.bindParameter('in_order', orderProduct.getInOrder());
|
|
27
|
+
}
|
|
28
|
+
async insert(orderProduct) {
|
|
29
|
+
const query = this.createQuery(SQL.ordersProducts.insert);
|
|
30
|
+
const id = await this.selectNextId();
|
|
31
|
+
query.bindParameter('id', id);
|
|
32
|
+
this.bindParams(query, orderProduct);
|
|
17
33
|
await query.execute();
|
|
18
34
|
orderProduct.setId(id);
|
|
35
|
+
return true;
|
|
19
36
|
}
|
|
20
37
|
async selectNextId() {
|
|
21
38
|
const query = this.createQuery(SQL.ordersProducts.selectNextId);
|
package/dist/tables/{DeliveryStatusTypesTable.js → personalInformation/DeliveryStatusTypesTable.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as SQL from '
|
|
2
|
-
import Table from '
|
|
1
|
+
import * as SQL from '../../SQL.json';
|
|
2
|
+
import Table from '../../Table';
|
|
3
3
|
export default class DeliveryStatusTypesTable extends Table {
|
|
4
4
|
async select(deliveryStatusTypeId) {
|
|
5
5
|
const query = this.createQuery(SQL.deliveryStatusTypes.select);
|
package/dist/tables/{DeliveryStatusesTable.d.ts → personalInformation/DeliveryStatusesTable.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import DeliveryStatus from '
|
|
2
|
-
import Table from '
|
|
3
|
-
import DeliveryStatusRow from '
|
|
1
|
+
import DeliveryStatus from '../../stockObjects/DeliveryStatus';
|
|
2
|
+
import Table from '../../Table';
|
|
3
|
+
import DeliveryStatusRow from '../../types/rows/DeliveryStatusRow';
|
|
4
4
|
export default class DeliveryStatusesTable extends Table {
|
|
5
5
|
select(deliveryDetailsId: number): Promise<DeliveryStatusRow>;
|
|
6
6
|
selectAll(deliveryDetailsId: number): Promise<DeliveryStatusRow[]>;
|
package/dist/tables/{DeliveryStatusesTable.js → personalInformation/DeliveryStatusesTable.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as SQL from '
|
|
2
|
-
import Table from '
|
|
1
|
+
import * as SQL from '../../SQL.json';
|
|
2
|
+
import Table from '../../Table';
|
|
3
3
|
export default class DeliveryStatusesTable extends Table {
|
|
4
4
|
async select(deliveryDetailsId) {
|
|
5
5
|
const query = this.createQuery(SQL.deliveryStatuses.select);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import QueryOptionsI from "
|
|
2
|
-
import Table from "
|
|
3
|
-
import AdminRow from "
|
|
4
|
-
import Admin from "
|
|
1
|
+
import QueryOptionsI from "../../types/QueryOptionsI";
|
|
2
|
+
import Table from "../../Table";
|
|
3
|
+
import AdminRow from "../../types/rows/AdminRow";
|
|
4
|
+
import Admin from "../../stockObjects/Admin";
|
|
5
5
|
export default class AdminAccountsTable extends Table {
|
|
6
6
|
select(accountId: number): Promise<AdminRow>;
|
|
7
7
|
selectAll(queryOptions: QueryOptionsI): Promise<AdminRow[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Table from "
|
|
2
|
-
import * as SQL from '
|
|
1
|
+
import Table from "../../Table";
|
|
2
|
+
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class AdminAccountsTable extends Table {
|
|
4
4
|
async select(accountId) {
|
|
5
5
|
const query = this.createQuery(SQL.adminAccounts.select);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import Product from '../../stockObjects/Product';
|
|
2
|
+
import Table from '../../Table';
|
|
3
|
+
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
4
|
+
import ProductRow from '../../types/rows/ProductRow';
|
|
5
5
|
export default class ProductsTable extends Table {
|
|
6
6
|
select(productId: number): Promise<ProductRow>;
|
|
7
7
|
selectForSku(sku: string): Promise<ProductRow>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as SQL from '../../SQL.json';
|
|
2
|
+
import Table from '../../Table';
|
|
3
3
|
export default class ProductsTable extends Table {
|
|
4
4
|
async select(productId) {
|
|
5
5
|
const query = this.createQuery(SQL.products.select);
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import FileI from "./FileI";
|
|
2
2
|
export default interface OrderProductI {
|
|
3
|
-
orderProductId: number;
|
|
4
3
|
id: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
productId: number;
|
|
5
|
+
orderId: number;
|
|
6
|
+
product: {
|
|
7
|
+
id: number;
|
|
8
|
+
sku: string;
|
|
9
|
+
title: string;
|
|
10
|
+
netPrice: number;
|
|
11
|
+
grossPrice: number;
|
|
12
|
+
vat: number;
|
|
13
|
+
file: FileI;
|
|
14
|
+
};
|
|
9
15
|
}
|
package/dist/types/ProductI.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Table from "../Table";
|
|
2
|
-
import * as SQL from '../SQL.json';
|
|
3
|
-
export default class StatusTypesTable extends Table {
|
|
4
|
-
async select() {
|
|
5
|
-
const query = this.createQuery(SQL.statusTypes.select);
|
|
6
|
-
const result = await query.execute();
|
|
7
|
-
return result.getRows();
|
|
8
|
-
}
|
|
9
|
-
}
|