@dascompany/product 2.1.4 → 2.1.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
CHANGED
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
79
79
|
},
|
|
80
80
|
"statuses": {
|
|
81
|
-
"select": "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
|
|
81
|
+
"select": "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",
|
|
82
82
|
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
|
83
83
|
"selectNextId": "SELECT nextval('orders.statuses_id'::regclass)"
|
|
84
84
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
3
|
import OrderStatusReader from "./OrderStatusReader";
|
|
3
|
-
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
4
4
|
export default class OrderReader {
|
|
5
5
|
static async get(queryOptions) {
|
|
6
6
|
const orderData = await DatabaseConnection.getInstance().orders.select(queryOptions);
|
|
@@ -33,7 +33,9 @@ export default class OrderReader {
|
|
|
33
33
|
return orders;
|
|
34
34
|
}
|
|
35
35
|
static async correctOrder(order) {
|
|
36
|
-
const
|
|
36
|
+
const queryOptions = new QueryOptions();
|
|
37
|
+
queryOptions.setWhere([{ name: 'order_id', type: ParameterType.bigint, value: order.id }]);
|
|
38
|
+
const status = await OrderStatusReader.get(queryOptions);
|
|
37
39
|
const correctOrder = {
|
|
38
40
|
id: order.id,
|
|
39
41
|
email: order.email,
|
|
@@ -5,12 +5,13 @@ import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
|
5
5
|
import PriceConverter from "../utils/PriceConverter";
|
|
6
6
|
export default class ProductReader {
|
|
7
7
|
static async get(queryOption) {
|
|
8
|
-
const
|
|
8
|
+
const productRow = await DatabaseConnection.getInstance().products.select(queryOption);
|
|
9
9
|
const queryOptionsFiles = new QueryOptions();
|
|
10
|
-
queryOptionsFiles.setWhere([{ name: 'connection_id', type: ParameterType.bigint, value:
|
|
10
|
+
queryOptionsFiles.setWhere([{ name: 'connection_id', type: ParameterType.bigint, value: productRow.id }, { name: 'connection_type', type: ParameterType.string, value: FileConnectionTypeE.product }]);
|
|
11
11
|
queryOptionsFiles.setOrderBy([{ key: 'sequence', order: 'asc' }]);
|
|
12
12
|
const files = await FilesReader.getForConnection(queryOptionsFiles);
|
|
13
|
-
|
|
13
|
+
const product = await this.correctProduct(productRow);
|
|
14
|
+
return { ...product, files };
|
|
14
15
|
}
|
|
15
16
|
static async getAll(queryOption) {
|
|
16
17
|
const products = await DatabaseConnection.getInstance().products.selectAll(queryOption);
|