@dascompany/database 0.0.6 → 0.0.8
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 +5 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/reader/OrderProductsReader.d.ts +4 -0
- package/dist/reader/OrderProductsReader.js +42 -0
- package/dist/reader/OrderReader.d.ts +6 -0
- package/dist/reader/OrderReader.js +14 -0
- package/dist/repo/OrderStatusRepo.d.ts +7 -0
- package/dist/repo/OrderStatusRepo.js +27 -0
- package/dist/repo/ProductRepo.js +1 -0
- package/dist/stockObjects/Order.d.ts +3 -3
- package/dist/stockObjects/Status.d.ts +13 -5
- package/dist/stockObjects/Status.js +25 -9
- package/dist/tables/orders/OrdersProductsTable.d.ts +2 -0
- package/dist/tables/orders/OrdersProductsTable.js +12 -0
- package/dist/tables/orders/OrdersTable.d.ts +3 -0
- package/dist/tables/orders/OrdersTable.js +10 -0
- package/dist/tables/orders/StatusesTable.d.ts +1 -0
- package/dist/tables/orders/StatusesTable.js +6 -0
- package/dist/types/StatusI.d.ts +5 -0
- package/dist/types/StatusI.js +1 -0
- package/dist/types/rows/OrderRow.d.ts +3 -0
- package/dist/types/rows/StatusRow.d.ts +2 -1
- package/package.json +1 -1
package/dist/SQL.json
CHANGED
|
@@ -69,17 +69,19 @@
|
|
|
69
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
70
|
"delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
|
|
71
71
|
"restore": "UPDATE products SET deleted = false WHERE id = $id::BIGINT",
|
|
72
|
-
"selectForSku": "SELECT
|
|
72
|
+
"selectForSku": "SELECT * FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
73
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)",
|
|
74
74
|
"selectNextId": "SELECT nextval('product_id'::regclass)",
|
|
75
75
|
"count": "SELECT COUNT(*) AS total_rows FROM products WHERE deleted = false $PARAMS"
|
|
76
76
|
},
|
|
77
77
|
"orders": {
|
|
78
|
+
"selectAll": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id, zsi_id, created_at FROM orders.orders",
|
|
78
79
|
"select": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id, zsi_id FROM orders.orders WHERE id = $id::BIGINT",
|
|
79
80
|
"selectForClient": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id FROM orders.orders WHERE client_id = $client_id::BIGINT ORDER BY id DESC",
|
|
80
81
|
"insert": "INSERT INTO orders.orders( id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id ) VALUES ($order_id::BIGINT, $email::TEXT, $price::DOUBLE PRECISION, $client_id::BIGINT, $contact_details_id::BIGINT, $delivery_details_id::BIGINT , $invoice_details_id::BIGINT, $payment_details_id::BIGINT )",
|
|
81
82
|
"update": "UPDATE orders.orders SET price = $price::DOUBLE PRECISION, contact_details_id = $contact_details_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, invoice_details_id = $invoice_details_id::BIGINT, payment_details_id = $payment_details_id::BIGINT, zsi_id = $zsi_id::BIGINT WHERE id = $id::BIGINT",
|
|
82
|
-
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)"
|
|
83
|
+
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)",
|
|
84
|
+
"count": "SELECT COUNT (*) AS TOTAL_ROWS FROM orders.orders as o JOIN orders.statuses as os ON o.id = os.order_id JOIN (SELECT order_id, MAX(id) as max_id FROM orders.statuses GROUP BY order_id) as latest ON os.order_id = latest.order_id AND os.id = latest.max_id $WHERE"
|
|
83
85
|
},
|
|
84
86
|
"ordersProducts": {
|
|
85
87
|
"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",
|
|
@@ -91,6 +93,7 @@
|
|
|
91
93
|
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
92
94
|
},
|
|
93
95
|
"statuses": {
|
|
96
|
+
"selectLatest": "SELECT s.id, s.order_id, created_at, user_id, s.type as type_id, st.key as type_name FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE s.order_id = $order_id::BIGINT ORDER BY s.id DESC LIMIT 1",
|
|
94
97
|
"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",
|
|
95
98
|
"selectAllForOrder": "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",
|
|
96
99
|
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import DatabaseConnection from "./DatabaseConnection";
|
|
2
|
+
import StockObject from "./types/StockObject";
|
|
3
|
+
import StockObjectMapper from "./types/StockObjectMapper";
|
|
2
4
|
import AddressesReader from "./reader/AddressesReader";
|
|
3
5
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
4
6
|
import CompanyDetailsReader from "./reader/CompanyDetailsReader";
|
|
@@ -10,6 +12,7 @@ import OrderProductsReader from "./reader/OrderProductsReader";
|
|
|
10
12
|
import OrderReader from "./reader/OrderReader";
|
|
11
13
|
import FilesReader from './reader/FilesReader';
|
|
12
14
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
15
|
+
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
13
16
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
14
17
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
15
18
|
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
@@ -65,4 +68,4 @@ import File from './stockObjects/File';
|
|
|
65
68
|
import QueryOptions from './query/QueryOptions';
|
|
66
69
|
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
67
70
|
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, };
|
|
71
|
+
export { TableConnection, StockObject, StockObjectMapper, 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, OrderStatusRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DatabaseConnection from "./DatabaseConnection";
|
|
2
|
+
import StockObject from "./types/StockObject";
|
|
2
3
|
import AddressesReader from "./reader/AddressesReader";
|
|
3
4
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
4
5
|
import CompanyDetailsReader from "./reader/CompanyDetailsReader";
|
|
@@ -10,6 +11,7 @@ import OrderProductsReader from "./reader/OrderProductsReader";
|
|
|
10
11
|
import OrderReader from "./reader/OrderReader";
|
|
11
12
|
import FilesReader from './reader/FilesReader';
|
|
12
13
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
14
|
+
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
13
15
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
14
16
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
15
17
|
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
@@ -59,4 +61,4 @@ import File from './stockObjects/File';
|
|
|
59
61
|
import QueryOptions from './query/QueryOptions';
|
|
60
62
|
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
61
63
|
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, };
|
|
64
|
+
export { TableConnection, StockObject, 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, OrderStatusRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
|
@@ -3,4 +3,8 @@ export default class OrderProductsReader {
|
|
|
3
3
|
static getForOrder(orderId: number): Promise<any[]>;
|
|
4
4
|
static getAll(orderId: number): Promise<OrderProductI[]>;
|
|
5
5
|
private static correctProduct;
|
|
6
|
+
static get(orderId: number): Promise<OrderProductI[]>;
|
|
7
|
+
static getAllForIds(orderProductsIds: number[]): Promise<any[]>;
|
|
8
|
+
private static correctOrdersProducts;
|
|
9
|
+
private static correctOrderProduct;
|
|
6
10
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import ConnectorE from "../types/ConnectorE";
|
|
3
|
+
import ParameterType from "../types/parameters/ParameterType";
|
|
2
4
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
5
|
import FilesReader from "./FilesReader";
|
|
4
6
|
import ProductReader from "./ProductReader";
|
|
@@ -47,4 +49,44 @@ export default class OrderProductsReader {
|
|
|
47
49
|
};
|
|
48
50
|
return correctProduct;
|
|
49
51
|
}
|
|
52
|
+
static async get(orderId) {
|
|
53
|
+
const connection = DatabaseConnection.get();
|
|
54
|
+
const orderProducts = await connection.ordersProducts.selectProducts(orderId);
|
|
55
|
+
for (const product of orderProducts) {
|
|
56
|
+
const file = await FilesReader.get(product.file_id);
|
|
57
|
+
product.file = file;
|
|
58
|
+
}
|
|
59
|
+
return this.correctOrdersProducts(orderProducts);
|
|
60
|
+
}
|
|
61
|
+
static async getAllForIds(orderProductsIds) {
|
|
62
|
+
const connection = DatabaseConnection.get();
|
|
63
|
+
const queryOptions = {
|
|
64
|
+
where: {
|
|
65
|
+
connector: ConnectorE.and,
|
|
66
|
+
parameters: [
|
|
67
|
+
{ name: 'id', type: ParameterType.arrayBigint, value: orderProductsIds },
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const orderProducts = await connection.ordersProducts.selectAllForIds(queryOptions);
|
|
72
|
+
return orderProducts;
|
|
73
|
+
}
|
|
74
|
+
static correctOrdersProducts(productRows) {
|
|
75
|
+
const products = [];
|
|
76
|
+
for (let i = 0; i < productRows.length; i++) {
|
|
77
|
+
const product = this.correctOrderProduct(productRows[i]);
|
|
78
|
+
products.push(product);
|
|
79
|
+
}
|
|
80
|
+
return products;
|
|
81
|
+
}
|
|
82
|
+
static correctOrderProduct(product) {
|
|
83
|
+
return {
|
|
84
|
+
orderProductId: product.id,
|
|
85
|
+
netPrice: product.net_price,
|
|
86
|
+
id: product.product_id,
|
|
87
|
+
title: product.title,
|
|
88
|
+
sku: product.sku,
|
|
89
|
+
file: product.file
|
|
90
|
+
};
|
|
91
|
+
}
|
|
50
92
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import OrderI from "../types/OrderI";
|
|
2
|
+
import QueryOptionsI from "../types/QueryOptionsI";
|
|
2
3
|
export default class OrderReader {
|
|
3
4
|
static get(orderId: number): Promise<OrderI>;
|
|
4
5
|
static getForClient(clientAccountId: number): Promise<OrderI[]>;
|
|
6
|
+
static getAll(queryOptions: QueryOptionsI): Promise<{
|
|
7
|
+
orders: OrderI[];
|
|
8
|
+
quantity: number;
|
|
9
|
+
}>;
|
|
10
|
+
private static correctOrders;
|
|
5
11
|
private static correctOrder;
|
|
6
12
|
}
|
|
@@ -19,6 +19,20 @@ export default class OrderReader {
|
|
|
19
19
|
}
|
|
20
20
|
return correctOrders;
|
|
21
21
|
}
|
|
22
|
+
static async getAll(queryOptions) {
|
|
23
|
+
const connection = DatabaseConnection.get();
|
|
24
|
+
const orders = await connection.orders.selectAll(queryOptions);
|
|
25
|
+
const quantity = await connection.orders.count(queryOptions);
|
|
26
|
+
return { orders: this.correctOrders(orders), quantity };
|
|
27
|
+
}
|
|
28
|
+
static correctOrders(orderRows) {
|
|
29
|
+
const orders = [];
|
|
30
|
+
for (let i = 0; i < orderRows.length; i++) {
|
|
31
|
+
const order = this.correctOrder(orderRows[i]);
|
|
32
|
+
orders.push(order);
|
|
33
|
+
}
|
|
34
|
+
return orders;
|
|
35
|
+
}
|
|
22
36
|
static correctOrder(order) {
|
|
23
37
|
const correctOrder = {
|
|
24
38
|
id: order.id,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Status from "../stockObjects/Status";
|
|
2
|
+
export default class OrderStatusRepo {
|
|
3
|
+
static get(orderId: number): Promise<Status>;
|
|
4
|
+
static getAll(orderId: number): Promise<Status[]>;
|
|
5
|
+
private static createStatusesFromRows;
|
|
6
|
+
private static createStatusFromRow;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import Status from "../stockObjects/Status";
|
|
3
|
+
export default class OrderStatusRepo {
|
|
4
|
+
static async get(orderId) {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const status = await connection.statuses.selectLatest(orderId);
|
|
7
|
+
return this.createStatusFromRow(status);
|
|
8
|
+
}
|
|
9
|
+
static async getAll(orderId) {
|
|
10
|
+
const connection = DatabaseConnection.get();
|
|
11
|
+
const statuses = await connection.statuses.selectAllForOrder(orderId);
|
|
12
|
+
return this.createStatusesFromRows(statuses);
|
|
13
|
+
}
|
|
14
|
+
static async createStatusesFromRows(dataRows) {
|
|
15
|
+
const statuses = [];
|
|
16
|
+
for (const dataRow of dataRows) {
|
|
17
|
+
const status = await this.createStatusFromRow(dataRow);
|
|
18
|
+
statuses.push(status);
|
|
19
|
+
}
|
|
20
|
+
return statuses;
|
|
21
|
+
}
|
|
22
|
+
static async createStatusFromRow(dataRow) {
|
|
23
|
+
const status = new Status(dataRow.order_id, dataRow.user_id, dataRow.type_id, dataRow.type_name, dataRow.created_at);
|
|
24
|
+
status.setId(dataRow.id);
|
|
25
|
+
return status;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/repo/ProductRepo.js
CHANGED
|
@@ -9,6 +9,7 @@ export default class ProductRepo {
|
|
|
9
9
|
static async getForSku(productSku) {
|
|
10
10
|
const connection = DatabaseConnection.get();
|
|
11
11
|
const product = await connection.products.selectForSku(productSku);
|
|
12
|
+
console.log(product);
|
|
12
13
|
return this.createProductFromRow(product);
|
|
13
14
|
}
|
|
14
15
|
static createProductFromRow(productRow) {
|
|
@@ -9,12 +9,12 @@ export default class Order extends StockObject {
|
|
|
9
9
|
private invoiceDetailsId;
|
|
10
10
|
private paymentDetailsId;
|
|
11
11
|
private zsiId;
|
|
12
|
-
constructor(email: string, price: number, clientId: number, contactDetailsId: number, deliveryDetailsId: number, invoiceDetailsId?: number | null, paymentDetailsId?: number | null);
|
|
12
|
+
constructor(email: string, price: number, clientId: number | null, contactDetailsId: number, deliveryDetailsId: number, invoiceDetailsId?: number | null, paymentDetailsId?: number | null);
|
|
13
13
|
getData(): Promise<{
|
|
14
14
|
id: number | null;
|
|
15
15
|
email: string;
|
|
16
16
|
price: number;
|
|
17
|
-
clientId: number;
|
|
17
|
+
clientId: number | null;
|
|
18
18
|
contactDetailsId: number | null;
|
|
19
19
|
deliveryDetailsId: number | null;
|
|
20
20
|
invoiceDetailsId: number | null;
|
|
@@ -24,7 +24,7 @@ export default class Order extends StockObject {
|
|
|
24
24
|
getPrice(): number;
|
|
25
25
|
getZsiId(): number | null;
|
|
26
26
|
getGrossPrice(): number;
|
|
27
|
-
getclientId(): number;
|
|
27
|
+
getclientId(): number | null;
|
|
28
28
|
getContactDetailsId(): number | null;
|
|
29
29
|
getDeliveryDetailsId(): number | null;
|
|
30
30
|
getInvoiceDetailsId(): number | null;
|
|
@@ -3,13 +3,21 @@ import StockObjectMapper from "../types/StockObjectMapper";
|
|
|
3
3
|
export default class Status extends StockObject {
|
|
4
4
|
private orderId;
|
|
5
5
|
private userId;
|
|
6
|
-
private
|
|
7
|
-
|
|
6
|
+
private typeId;
|
|
7
|
+
private typeName;
|
|
8
|
+
private createdAt;
|
|
9
|
+
constructor(orderId: number, userId: number, typeId: number, typeName?: string | null, createdAt?: string | null);
|
|
8
10
|
getOrderId(): number;
|
|
11
|
+
getCreatedAt(): string | null;
|
|
9
12
|
getUserId(): number;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
getTypeId(): number;
|
|
14
|
+
getType(): {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string | null;
|
|
17
|
+
};
|
|
13
18
|
setOrderId(orderId: number): void;
|
|
19
|
+
setCreatedAt(createdAt: string): void;
|
|
20
|
+
setUserId(userId: number): void;
|
|
21
|
+
setTypeId(typeId: number): void;
|
|
14
22
|
protected getMapper(): StockObjectMapper;
|
|
15
23
|
}
|
|
@@ -3,30 +3,46 @@ import StockObject from "../types/StockObject";
|
|
|
3
3
|
export default class Status extends StockObject {
|
|
4
4
|
orderId;
|
|
5
5
|
userId;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
typeId;
|
|
7
|
+
typeName;
|
|
8
|
+
createdAt;
|
|
9
|
+
constructor(orderId, userId, typeId, typeName = null, createdAt = null) {
|
|
8
10
|
super();
|
|
9
11
|
this.orderId = orderId;
|
|
10
12
|
this.userId = userId;
|
|
11
|
-
this.
|
|
13
|
+
this.typeId = typeId;
|
|
14
|
+
this.typeName = typeName;
|
|
15
|
+
this.createdAt = createdAt;
|
|
12
16
|
}
|
|
13
17
|
getOrderId() {
|
|
14
18
|
return this.orderId;
|
|
15
19
|
}
|
|
20
|
+
getCreatedAt() {
|
|
21
|
+
return this.createdAt;
|
|
22
|
+
}
|
|
16
23
|
getUserId() {
|
|
17
24
|
return this.userId;
|
|
18
25
|
}
|
|
26
|
+
getTypeId() {
|
|
27
|
+
return this.typeId;
|
|
28
|
+
}
|
|
19
29
|
getType() {
|
|
20
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
id: this.typeId,
|
|
32
|
+
name: this.typeName
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
setOrderId(orderId) {
|
|
36
|
+
this.orderId = orderId;
|
|
37
|
+
}
|
|
38
|
+
setCreatedAt(createdAt) {
|
|
39
|
+
this.createdAt = createdAt;
|
|
21
40
|
}
|
|
22
41
|
setUserId(userId) {
|
|
23
42
|
this.userId = userId;
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
}
|
|
28
|
-
setOrderId(orderId) {
|
|
29
|
-
this.orderId = orderId;
|
|
44
|
+
setTypeId(typeId) {
|
|
45
|
+
this.typeId = typeId;
|
|
30
46
|
}
|
|
31
47
|
getMapper() {
|
|
32
48
|
return new StatusMapper(this);
|
|
@@ -4,6 +4,8 @@ import OrderProduct from '../../stockObjects/OrderProduct';
|
|
|
4
4
|
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
5
5
|
export default class OrdersProductsTable extends Table {
|
|
6
6
|
selectAll(orderId: number): Promise<OrderProductRow[]>;
|
|
7
|
+
getAllActiveForOrderId(orderId: number): Promise<OrderProduct[]>;
|
|
8
|
+
selectProducts(orderId: number): Promise<OrderProductRow[]>;
|
|
7
9
|
selectAllForIds(queryOprions: QueryOptionsI): Promise<OrderProduct[]>;
|
|
8
10
|
delete(orderProduct: OrderProduct): Promise<boolean>;
|
|
9
11
|
private bindParams;
|
|
@@ -7,6 +7,18 @@ export default class OrdersProductsTable extends Table {
|
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRows();
|
|
9
9
|
}
|
|
10
|
+
async getAllActiveForOrderId(orderId) {
|
|
11
|
+
const query = this.createQuery(SQL.ordersProducts.getAllActiveForOrderId);
|
|
12
|
+
query.bindParameter('order_id', orderId);
|
|
13
|
+
const result = await query.execute();
|
|
14
|
+
return result.getRows();
|
|
15
|
+
}
|
|
16
|
+
async selectProducts(orderId) {
|
|
17
|
+
const query = this.createQuery(SQL.ordersProducts.selectProducts);
|
|
18
|
+
query.bindParameter('order_id', orderId);
|
|
19
|
+
const result = await query.execute();
|
|
20
|
+
return result.getRows();
|
|
21
|
+
}
|
|
10
22
|
async selectAllForIds(queryOprions) {
|
|
11
23
|
const query = this.createQuery(SQL.ordersProducts.selectAll, queryOprions);
|
|
12
24
|
const result = await query.execute();
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import OrderRow from '../../types/rows/OrderRow';
|
|
3
3
|
import Order from '../../stockObjects/Order';
|
|
4
|
+
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
4
5
|
export default class OrdersTable extends Table {
|
|
5
6
|
select(orderId: number): Promise<OrderRow>;
|
|
6
7
|
selectForClient(clientId: number): Promise<OrderRow[]>;
|
|
8
|
+
selectAll(queryOption: QueryOptionsI): Promise<OrderRow[]>;
|
|
9
|
+
count(queryOptions?: QueryOptionsI): Promise<number>;
|
|
7
10
|
insert(order: Order): Promise<void>;
|
|
8
11
|
update(order: Order): Promise<void>;
|
|
9
12
|
private bindParameters;
|
|
@@ -13,6 +13,16 @@ export default class OrdersTable extends Table {
|
|
|
13
13
|
const result = await query.execute();
|
|
14
14
|
return result.getRows();
|
|
15
15
|
}
|
|
16
|
+
async selectAll(queryOption) {
|
|
17
|
+
const query = this.createQuery(SQL.orders.selectAll, queryOption);
|
|
18
|
+
const result = await query.execute();
|
|
19
|
+
return result.getRows();
|
|
20
|
+
}
|
|
21
|
+
async count(queryOptions) {
|
|
22
|
+
const query = this.createQuery(SQL.orders.count, queryOptions);
|
|
23
|
+
const result = await query.execute();
|
|
24
|
+
return result.getValue();
|
|
25
|
+
}
|
|
16
26
|
async insert(order) {
|
|
17
27
|
const orderId = await this.selectNextId();
|
|
18
28
|
const query = this.createQuery(SQL.orders.insert);
|
|
@@ -3,6 +3,7 @@ import Status from '../../stockObjects/Status';
|
|
|
3
3
|
import StatusRow from '../../types/rows/StatusRow';
|
|
4
4
|
export default class StatusesTable extends Table {
|
|
5
5
|
selectForOrder(orderId: number): Promise<StatusRow>;
|
|
6
|
+
selectLatest(orderId: number): Promise<StatusRow>;
|
|
6
7
|
selectAllForOrder(orderId: number): Promise<StatusRow[]>;
|
|
7
8
|
insert(status: Status): Promise<void>;
|
|
8
9
|
private bindParameters;
|
|
@@ -7,6 +7,12 @@ export default class StatusesTable extends Table {
|
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRow();
|
|
9
9
|
}
|
|
10
|
+
async selectLatest(orderId) {
|
|
11
|
+
const query = this.createQuery(SQL.statuses.selectLatest);
|
|
12
|
+
query.bindParameter('order_id', orderId);
|
|
13
|
+
const result = await query.execute();
|
|
14
|
+
return result.getRow();
|
|
15
|
+
}
|
|
10
16
|
async selectAllForOrder(orderId) {
|
|
11
17
|
const query = this.createQuery(SQL.statuses.selectAllForOrder);
|
|
12
18
|
query.bindParameter('order_id', orderId);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|