@things-factory/warehouse-base 7.1.23 → 7.1.25
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-server/service/warehouse/warehouse-mutation.js +24 -0
- package/dist-server/service/warehouse/warehouse-mutation.js.map +1 -1
- package/dist-server/service/warehouse/warehouse-query.js +5 -3
- package/dist-server/service/warehouse/warehouse-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/server/service/warehouse/warehouse-mutation.ts +36 -1
- package/server/service/warehouse/warehouse-query.ts +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/warehouse-base",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.25",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/biz-base": "^7.1.
|
|
28
|
-
"@things-factory/id-rule-base": "^7.1.
|
|
29
|
-
"@things-factory/integration-sellercraft": "^7.1.
|
|
30
|
-
"@things-factory/marketplace-base": "^7.1.
|
|
31
|
-
"@things-factory/product-base": "^7.1.
|
|
32
|
-
"@things-factory/setting-base": "^7.1.
|
|
27
|
+
"@things-factory/biz-base": "^7.1.24",
|
|
28
|
+
"@things-factory/id-rule-base": "^7.1.24",
|
|
29
|
+
"@things-factory/integration-sellercraft": "^7.1.24",
|
|
30
|
+
"@things-factory/marketplace-base": "^7.1.25",
|
|
31
|
+
"@things-factory/product-base": "^7.1.25",
|
|
32
|
+
"@things-factory/setting-base": "^7.1.24"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "99180f1ee824d20cd9521b432c3a2bdd1f600354"
|
|
35
35
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import { Repository } from 'typeorm'
|
|
2
|
+
import { Repository, In, Equal } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
import { Warehouse } from './warehouse'
|
|
5
5
|
import { NewWarehouse, WarehousePatch } from './warehouse-types'
|
|
6
|
+
import { Product } from '@things-factory/product-base'
|
|
6
7
|
|
|
7
8
|
@Resolver(Warehouse)
|
|
8
9
|
export class WarehouseMutation {
|
|
@@ -61,6 +62,21 @@ export class WarehouseMutation {
|
|
|
61
62
|
@Directive('@transaction')
|
|
62
63
|
@Mutation(returns => Boolean)
|
|
63
64
|
async deleteWarehouse(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {
|
|
65
|
+
const { domain, user, tx } = context.state
|
|
66
|
+
const product = await tx.getRepository(Product).findOne({
|
|
67
|
+
where: {
|
|
68
|
+
domain: { id: domain.id },
|
|
69
|
+
warehouseId: Equal(id)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
if (product?.id) {
|
|
74
|
+
await tx.getRepository(Product).save({
|
|
75
|
+
...product,
|
|
76
|
+
warehouseId: null
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
64
80
|
return await deleteWarehouse(id, context)
|
|
65
81
|
}
|
|
66
82
|
|
|
@@ -71,6 +87,25 @@ export class WarehouseMutation {
|
|
|
71
87
|
@Arg('ids', type => [String]) ids: string[],
|
|
72
88
|
@Ctx() context: ResolverContext
|
|
73
89
|
): Promise<Boolean> {
|
|
90
|
+
const { domain, user, tx } = context.state
|
|
91
|
+
const products = await tx.getRepository(Product).find({
|
|
92
|
+
where: {
|
|
93
|
+
domain: { id: domain.id },
|
|
94
|
+
warehouseId: In(ids)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (products?.length) {
|
|
99
|
+
await tx.getRepository(Product).save(
|
|
100
|
+
products.map(i => {
|
|
101
|
+
return {
|
|
102
|
+
...i,
|
|
103
|
+
warehouseId: null
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
74
109
|
return await deleteWarehouses(ids, context)
|
|
75
110
|
}
|
|
76
111
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import {
|
|
4
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
5
5
|
|
|
6
6
|
import { Warehouse } from './warehouse'
|
|
7
7
|
import { WarehouseList } from './warehouse-types'
|
|
@@ -29,14 +29,15 @@ export class WarehouseQuery {
|
|
|
29
29
|
): Promise<WarehouseList> {
|
|
30
30
|
const { domain } = context.state
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
domain
|
|
32
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
33
|
+
domain,
|
|
34
|
+
params,
|
|
35
|
+
repository: getRepository(Warehouse),
|
|
34
36
|
searchables: ['name', 'description']
|
|
35
37
|
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
38
|
+
|
|
39
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
40
|
+
|
|
40
41
|
return { items, total }
|
|
41
42
|
}
|
|
42
43
|
|