@dascompany/product 4.2.0 → 4.2.1
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 +6 -5
- package/dist/stockObjects/AccountCartItem.ts.d.ts +21 -0
- package/dist/stockObjects/AccountCartItem.ts.js +44 -0
- package/dist/stockObjects/Product.js +1 -1
- package/dist/tables/clients/AccountCartTable.d.ts +6 -3
- package/dist/tables/clients/AccountCartTable.js +23 -9
- package/dist/utils/AccountCart.d.ts +3 -3
- package/dist/utils/AccountCart.js +9 -6
- package/package.json +1 -1
package/dist/SQL.json
CHANGED
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"selectNextId": "SELECT nextval('clients.accounts_id'::regclass)"
|
|
19
19
|
},
|
|
20
20
|
"accountCart": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
21
|
+
"selectAll": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT",
|
|
22
|
+
"select": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT",
|
|
23
|
+
"insert": "INSERT INTO clients.account_cart(account_id, product_id, installation, quantity) VALUES ($account_id::BIGINT, $product_id::BIGINT, $installation::BOOL, $quantity::INT)",
|
|
24
|
+
"update": "UPDATE clients.account_cart SET installation = $installation::BOOL, quantity = $quantity::INT WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT AND (installation != $installation::BOOL OR quantity != $quantity::INT)",
|
|
25
|
+
"delete": "DELETE FROM clients.account_cart WHERE product_id = $product_id::BIGINT AND account_id = $account_id::BIGINT"
|
|
25
26
|
},
|
|
26
27
|
"accountDeliveryDetails": {
|
|
27
28
|
"select": "SELECT * FROM clients.account_delivery_details WHERE account_id = $account_id::BIGINT",
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
"files": {
|
|
99
100
|
"select": "SELECT * FROM files.files",
|
|
100
101
|
"selectId": "SELECT id FROM files.files ",
|
|
101
|
-
"selectForConnection": "SELECT id, name, catalog, type, sequence FROM files.files JOIN files.file_connections ON file_id = id",
|
|
102
|
+
"selectForConnection": "SELECT id, name, catalog, type, sequence, alt, title FROM files.files JOIN files.file_connections ON file_id = id",
|
|
102
103
|
"insert": "INSERT INTO files.files( id, name, orginal_name, catalog, size_kb, type, alt, title, created_at ) VALUES ( $id::BIGINT, $name::TEXT, $orginal_name::TEXT, $catalog::TEXT, $size_kb::BIGINT, $type::TEXT, $alt::TEXT, $title::TEXT, now() )",
|
|
103
104
|
"update": "UPDATE files.files SET name = $name::TEXT, orginal_name = $orginal_name::TEXT, catalog = $catalog::TEXT, size_kb = $size_kb::BIGINT, type = $type::TEXT, alt = $alt::TEXT, title = $title::TEXT WHERE id = $id::BIGINT ",
|
|
104
105
|
"count": "SELECT COUNT(*) AS total_rows FROM files.files",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default class AccountCartItem {
|
|
2
|
+
private accountId;
|
|
3
|
+
private productId;
|
|
4
|
+
private installation;
|
|
5
|
+
private quantity;
|
|
6
|
+
constructor(accountId: string, productId: string, installation: boolean, quantity: number);
|
|
7
|
+
getData(): {
|
|
8
|
+
accountId: string;
|
|
9
|
+
productId: string;
|
|
10
|
+
installation: boolean;
|
|
11
|
+
quantity: number;
|
|
12
|
+
};
|
|
13
|
+
getAccountId(): string;
|
|
14
|
+
getProductId(): string;
|
|
15
|
+
getInstallation(): boolean;
|
|
16
|
+
getQuantity(): number;
|
|
17
|
+
setAccountId(accountId: string): void;
|
|
18
|
+
setProductId(productId: string): void;
|
|
19
|
+
setInstallation(installation: boolean): void;
|
|
20
|
+
setQuantity(quantity: number): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default class AccountCartItem {
|
|
2
|
+
accountId;
|
|
3
|
+
productId;
|
|
4
|
+
installation;
|
|
5
|
+
quantity;
|
|
6
|
+
constructor(accountId, productId, installation, quantity) {
|
|
7
|
+
this.accountId = accountId;
|
|
8
|
+
this.productId = productId;
|
|
9
|
+
this.installation = installation;
|
|
10
|
+
this.quantity = quantity;
|
|
11
|
+
}
|
|
12
|
+
getData() {
|
|
13
|
+
return {
|
|
14
|
+
accountId: this.accountId,
|
|
15
|
+
productId: this.productId,
|
|
16
|
+
installation: this.installation,
|
|
17
|
+
quantity: this.quantity,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
getAccountId() {
|
|
21
|
+
return this.accountId;
|
|
22
|
+
}
|
|
23
|
+
getProductId() {
|
|
24
|
+
return this.productId;
|
|
25
|
+
}
|
|
26
|
+
getInstallation() {
|
|
27
|
+
return this.installation;
|
|
28
|
+
}
|
|
29
|
+
getQuantity() {
|
|
30
|
+
return this.quantity;
|
|
31
|
+
}
|
|
32
|
+
setAccountId(accountId) {
|
|
33
|
+
this.accountId = accountId;
|
|
34
|
+
}
|
|
35
|
+
setProductId(productId) {
|
|
36
|
+
this.productId = productId;
|
|
37
|
+
}
|
|
38
|
+
setInstallation(installation) {
|
|
39
|
+
this.installation = installation;
|
|
40
|
+
}
|
|
41
|
+
setQuantity(quantity) {
|
|
42
|
+
this.quantity = quantity;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Table } from '@dascompany/database';
|
|
2
2
|
import AccountCartRow from '../../types/rows/AccountCartRow';
|
|
3
|
+
import AccountCartItem from '../../stockObjects/AccountCartItem.ts';
|
|
3
4
|
export default class AccountCartTable extends Table {
|
|
4
5
|
selectAll(accountId: string): Promise<AccountCartRow[]>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
select(accountId: string, productId: string): Promise<AccountCartRow[]>;
|
|
7
|
+
delete(accountId: string, productId: string): Promise<void>;
|
|
8
|
+
insert(accountCartItem: AccountCartItem): Promise<void>;
|
|
9
|
+
update(accountCartItem: AccountCartItem): Promise<void>;
|
|
8
10
|
private bindParams;
|
|
11
|
+
private bindSideParams;
|
|
9
12
|
}
|
|
@@ -2,29 +2,43 @@ import { Table } from '@dascompany/database';
|
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class AccountCartTable extends Table {
|
|
4
4
|
async selectAll(accountId) {
|
|
5
|
-
const query = this.createQuery(SQL.accountCart.
|
|
5
|
+
const query = this.createQuery(SQL.accountCart.selectAll);
|
|
6
6
|
query.bindParameter('account_id', accountId);
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRows();
|
|
9
9
|
}
|
|
10
|
-
async
|
|
10
|
+
async select(accountId, productId) {
|
|
11
|
+
const query = this.createQuery(SQL.accountCart.select);
|
|
12
|
+
query.bindParameter('account_id', accountId);
|
|
13
|
+
query.bindParameter('product_id', productId);
|
|
14
|
+
const result = await query.execute();
|
|
15
|
+
return result.getRow();
|
|
16
|
+
}
|
|
17
|
+
async delete(accountId, productId) {
|
|
11
18
|
const query = this.createQuery(SQL.accountCart.delete);
|
|
12
|
-
this.bindParams(query, accountId, productId
|
|
19
|
+
this.bindParams(query, accountId, productId);
|
|
13
20
|
await query.execute();
|
|
14
21
|
}
|
|
15
|
-
async insert(
|
|
22
|
+
async insert(accountCartItem) {
|
|
16
23
|
const query = this.createQuery(SQL.accountCart.insert);
|
|
17
|
-
this.bindParams(query,
|
|
24
|
+
this.bindParams(query, accountCartItem.getAccountId(), accountCartItem.getProductId());
|
|
25
|
+
this.bindSideParams(query, accountCartItem);
|
|
18
26
|
await query.execute();
|
|
19
27
|
}
|
|
20
|
-
async update(
|
|
28
|
+
async update(accountCartItem) {
|
|
21
29
|
const query = this.createQuery(SQL.accountCart.update);
|
|
22
|
-
|
|
30
|
+
query.bindParameter('account_id', accountCartItem.getAccountId());
|
|
31
|
+
query.bindParameter('product_id', accountCartItem.getProductId());
|
|
32
|
+
query.bindParameter('installation', accountCartItem.getInstallation());
|
|
33
|
+
query.bindParameter('quantity', accountCartItem.getQuantity());
|
|
23
34
|
await query.execute();
|
|
24
35
|
}
|
|
25
|
-
bindParams(query, accountId, productId
|
|
36
|
+
bindParams(query, accountId, productId) {
|
|
26
37
|
query.bindParameter('account_id', accountId);
|
|
27
38
|
query.bindParameter('product_id', productId);
|
|
28
|
-
|
|
39
|
+
}
|
|
40
|
+
bindSideParams(query, accountCartItem) {
|
|
41
|
+
query.bindParameter('installation', accountCartItem.getInstallation());
|
|
42
|
+
query.bindParameter('quantity', accountCartItem.getQuantity());
|
|
29
43
|
}
|
|
30
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default class AccountCart {
|
|
2
|
-
static delete(accountId: string, productId: string
|
|
3
|
-
static insert(accountId: string, productId: string, installation: boolean): Promise<boolean>;
|
|
4
|
-
static update(accountId: string, productId: string,
|
|
2
|
+
static delete(accountId: string, productId: string): Promise<boolean>;
|
|
3
|
+
static insert(accountId: string, productId: string, installation: boolean, quantity: number): Promise<boolean>;
|
|
4
|
+
static update(accountId: string, productId: string, installation: boolean, quantity: number): Promise<boolean>;
|
|
5
5
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import AccountCartItem from "../stockObjects/AccountCartItem.ts";
|
|
2
3
|
export default class AccountCart {
|
|
3
|
-
static async delete(accountId, productId
|
|
4
|
-
await DatabaseConnection.getInstance().accountCart.delete(accountId, productId
|
|
4
|
+
static async delete(accountId, productId) {
|
|
5
|
+
await DatabaseConnection.getInstance().accountCart.delete(accountId, productId);
|
|
5
6
|
return true;
|
|
6
7
|
}
|
|
7
|
-
static async insert(accountId, productId, installation) {
|
|
8
|
-
|
|
8
|
+
static async insert(accountId, productId, installation, quantity) {
|
|
9
|
+
const item = new AccountCartItem(accountId, productId, installation, quantity);
|
|
10
|
+
await DatabaseConnection.getInstance().accountCart.insert(item);
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
11
|
-
static async update(accountId, productId,
|
|
12
|
-
|
|
13
|
+
static async update(accountId, productId, installation, quantity) {
|
|
14
|
+
const item = new AccountCartItem(accountId, productId, installation, quantity);
|
|
15
|
+
await DatabaseConnection.getInstance().accountCart.update(item);
|
|
13
16
|
return true;
|
|
14
17
|
}
|
|
15
18
|
}
|