@things-factory/operato-hub 4.3.236 → 4.3.238
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/config.development.js +106 -78
- package/dist-server/graphql/resolvers/synchronization/powrup-pack-order.js +121 -0
- package/dist-server/graphql/resolvers/synchronization/powrup-pack-order.js.map +1 -0
- package/dist-server/routers/internal/apis/create-bizplace.js +7 -6
- package/dist-server/routers/internal/apis/create-bizplace.js.map +1 -1
- package/dist-server/routers/internal/apis/create-company.js +5 -6
- package/dist-server/routers/internal/apis/create-company.js.map +1 -1
- package/dist-server/routers/internal/apis/create-partner.js +9 -9
- package/dist-server/routers/internal/apis/create-partner.js.map +1 -1
- package/dist-server/routers/internal/apis/create-user.js +2 -2
- package/dist-server/routers/internal/apis/create-user.js.map +1 -1
- package/dist-server/routers/internal/apis/invite-user.js +7 -7
- package/dist-server/routers/internal/apis/invite-user.js.map +1 -1
- package/dist-server/routers/internal/apis/terminate-partner.js +7 -7
- package/dist-server/routers/internal/apis/terminate-partner.js.map +1 -1
- package/dist-server/routers/internal/apis/terminate-user.js +7 -7
- package/dist-server/routers/internal/apis/terminate-user.js.map +1 -1
- package/dist-server/routers/internal/apis/update-bizplace.js +2 -2
- package/dist-server/routers/internal/apis/update-bizplace.js.map +1 -1
- package/dist-server/routers/internal/apis/update-company.js +4 -8
- package/dist-server/routers/internal/apis/update-company.js.map +1 -1
- package/dist-server/routers/internal/apis/update-user.js +1 -1
- package/dist-server/routers/internal/apis/update-user.js.map +1 -1
- package/dist-server/routers/internal/powrup-router.js +17 -17
- package/dist-server/routers/internal/powrup-router.js.map +1 -1
- package/dist-server/routers/internal/utils/params.js +34 -59
- package/dist-server/routers/internal/utils/params.js.map +1 -1
- package/package.json +51 -50
- package/server/graphql/resolvers/synchronization/powrup-pack-order.ts +156 -0
- package/server/routers/internal/apis/create-bizplace.ts +7 -6
- package/server/routers/internal/apis/create-company.ts +5 -6
- package/server/routers/internal/apis/create-partner.ts +9 -9
- package/server/routers/internal/apis/create-user.ts +2 -2
- package/server/routers/internal/apis/invite-user.ts +7 -7
- package/server/routers/internal/apis/terminate-partner.ts +7 -7
- package/server/routers/internal/apis/terminate-user.ts +7 -7
- package/server/routers/internal/apis/update-bizplace.ts +2 -2
- package/server/routers/internal/apis/update-company.ts +4 -9
- package/server/routers/internal/apis/update-user.ts +1 -1
- package/server/routers/internal/powrup-router.ts +17 -17
- package/server/routers/internal/utils/params.ts +34 -59
- package/translations/ja.json +69 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.238",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -55,59 +55,60 @@
|
|
|
55
55
|
"@operato/scene-tab": "^0.1.8",
|
|
56
56
|
"@operato/scene-table": "^0.1.8",
|
|
57
57
|
"@operato/scene-wheel-sorter": "^0.1.8",
|
|
58
|
-
"@things-factory/api": "^4.3.
|
|
59
|
-
"@things-factory/apptool-ui": "^4.3.
|
|
60
|
-
"@things-factory/attachment-base": "^4.3.
|
|
61
|
-
"@things-factory/auth-base": "^4.3.
|
|
62
|
-
"@things-factory/auth-ui": "^4.3.
|
|
63
|
-
"@things-factory/biz-base": "^4.3.
|
|
64
|
-
"@things-factory/biz-ui": "^4.3.
|
|
65
|
-
"@things-factory/board-service": "^4.3.
|
|
66
|
-
"@things-factory/board-ui": "^4.3.
|
|
67
|
-
"@things-factory/code-ui": "^4.3.
|
|
58
|
+
"@things-factory/api": "^4.3.237",
|
|
59
|
+
"@things-factory/apptool-ui": "^4.3.237",
|
|
60
|
+
"@things-factory/attachment-base": "^4.3.237",
|
|
61
|
+
"@things-factory/auth-base": "^4.3.237",
|
|
62
|
+
"@things-factory/auth-ui": "^4.3.237",
|
|
63
|
+
"@things-factory/biz-base": "^4.3.237",
|
|
64
|
+
"@things-factory/biz-ui": "^4.3.237",
|
|
65
|
+
"@things-factory/board-service": "^4.3.237",
|
|
66
|
+
"@things-factory/board-ui": "^4.3.237",
|
|
67
|
+
"@things-factory/code-ui": "^4.3.237",
|
|
68
68
|
"@things-factory/component-ui": "^4.3.227",
|
|
69
|
-
"@things-factory/context-ui": "^4.3.
|
|
70
|
-
"@things-factory/document-template-ui": "^4.3.
|
|
71
|
-
"@things-factory/export-ui": "^4.3.
|
|
72
|
-
"@things-factory/export-ui-csv": "^4.3.
|
|
73
|
-
"@things-factory/export-ui-excel": "^4.3.
|
|
74
|
-
"@things-factory/geography": "^4.3.
|
|
75
|
-
"@things-factory/grist-ui": "^4.3.
|
|
76
|
-
"@things-factory/help": "^4.3.
|
|
77
|
-
"@things-factory/i18n-base": "^4.3.
|
|
78
|
-
"@things-factory/import-ui": "^4.3.
|
|
79
|
-
"@things-factory/import-ui-excel": "^4.3.
|
|
80
|
-
"@things-factory/integration-accounting": "^4.3.
|
|
81
|
-
"@things-factory/integration-fulfillment": "^4.3.
|
|
82
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
83
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
84
|
-
"@things-factory/integration-pos": "^4.3.
|
|
85
|
-
"@things-factory/integration-
|
|
86
|
-
"@things-factory/integration-
|
|
87
|
-
"@things-factory/
|
|
88
|
-
"@things-factory/
|
|
89
|
-
"@things-factory/
|
|
90
|
-
"@things-factory/
|
|
69
|
+
"@things-factory/context-ui": "^4.3.237",
|
|
70
|
+
"@things-factory/document-template-ui": "^4.3.237",
|
|
71
|
+
"@things-factory/export-ui": "^4.3.237",
|
|
72
|
+
"@things-factory/export-ui-csv": "^4.3.237",
|
|
73
|
+
"@things-factory/export-ui-excel": "^4.3.237",
|
|
74
|
+
"@things-factory/geography": "^4.3.237",
|
|
75
|
+
"@things-factory/grist-ui": "^4.3.237",
|
|
76
|
+
"@things-factory/help": "^4.3.237",
|
|
77
|
+
"@things-factory/i18n-base": "^4.3.237",
|
|
78
|
+
"@things-factory/import-ui": "^4.3.237",
|
|
79
|
+
"@things-factory/import-ui-excel": "^4.3.237",
|
|
80
|
+
"@things-factory/integration-accounting": "^4.3.238",
|
|
81
|
+
"@things-factory/integration-fulfillment": "^4.3.238",
|
|
82
|
+
"@things-factory/integration-lmd": "^4.3.238",
|
|
83
|
+
"@things-factory/integration-marketplace": "^4.3.238",
|
|
84
|
+
"@things-factory/integration-pos": "^4.3.238",
|
|
85
|
+
"@things-factory/integration-powrup": "^4.3.238",
|
|
86
|
+
"@things-factory/integration-sellercraft": "^4.3.238",
|
|
87
|
+
"@things-factory/integration-sftp": "^4.3.238",
|
|
88
|
+
"@things-factory/lite-menu": "^4.3.237",
|
|
89
|
+
"@things-factory/marketplace-base": "^4.3.238",
|
|
90
|
+
"@things-factory/more-ui": "^4.3.237",
|
|
91
|
+
"@things-factory/notification": "^4.3.237",
|
|
91
92
|
"@things-factory/pdf": "^4.3.227",
|
|
92
|
-
"@things-factory/product-ui": "^4.3.
|
|
93
|
-
"@things-factory/resource-ui": "^4.3.
|
|
94
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
-
"@things-factory/scene-data-transform": "^4.3.
|
|
96
|
-
"@things-factory/scene-excel": "^4.3.
|
|
93
|
+
"@things-factory/product-ui": "^4.3.237",
|
|
94
|
+
"@things-factory/resource-ui": "^4.3.237",
|
|
95
|
+
"@things-factory/sales-base": "^4.3.238",
|
|
96
|
+
"@things-factory/scene-data-transform": "^4.3.237",
|
|
97
|
+
"@things-factory/scene-excel": "^4.3.237",
|
|
97
98
|
"@things-factory/scene-firebase": "^4.3.227",
|
|
98
|
-
"@things-factory/scene-form": "^4.3.
|
|
99
|
-
"@things-factory/scene-google-map": "^4.3.
|
|
100
|
-
"@things-factory/scene-graphql": "^4.3.
|
|
101
|
-
"@things-factory/scene-label": "^4.3.
|
|
99
|
+
"@things-factory/scene-form": "^4.3.237",
|
|
100
|
+
"@things-factory/scene-google-map": "^4.3.237",
|
|
101
|
+
"@things-factory/scene-graphql": "^4.3.237",
|
|
102
|
+
"@things-factory/scene-label": "^4.3.237",
|
|
102
103
|
"@things-factory/scene-marker": "^4.3.227",
|
|
103
104
|
"@things-factory/scene-mqtt": "^4.3.227",
|
|
104
|
-
"@things-factory/scene-restful": "^4.3.
|
|
105
|
-
"@things-factory/scene-visualizer": "^4.3.
|
|
106
|
-
"@things-factory/setting-ui": "^4.3.
|
|
107
|
-
"@things-factory/shell": "^4.3.
|
|
108
|
-
"@things-factory/system-ui": "^4.3.
|
|
109
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
110
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
105
|
+
"@things-factory/scene-restful": "^4.3.237",
|
|
106
|
+
"@things-factory/scene-visualizer": "^4.3.237",
|
|
107
|
+
"@things-factory/setting-ui": "^4.3.237",
|
|
108
|
+
"@things-factory/shell": "^4.3.237",
|
|
109
|
+
"@things-factory/system-ui": "^4.3.237",
|
|
110
|
+
"@things-factory/warehouse-base": "^4.3.238",
|
|
111
|
+
"@things-factory/worksheet-base": "^4.3.238",
|
|
111
112
|
"cron-parser": "^4.7.0",
|
|
112
113
|
"koa2-swagger-ui": "^5.0.2",
|
|
113
114
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -119,5 +120,5 @@
|
|
|
119
120
|
"resolutions": {
|
|
120
121
|
"core-js": "^3.16.0"
|
|
121
122
|
},
|
|
122
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "926d659dd0e4d6c24c33ed7cf558779a51f5cba7"
|
|
123
124
|
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { getConnection, getRepository } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { logger } from '@things-factory/env'
|
|
4
|
+
import { createPayloadLog, PayloadType } from '@things-factory/integration-base'
|
|
5
|
+
import { Powrup, PowrupAPI } from '@things-factory/integration-powrup'
|
|
6
|
+
import {
|
|
7
|
+
ORDER_STATUS,
|
|
8
|
+
OrderNoGenerator,
|
|
9
|
+
OrderPackage,
|
|
10
|
+
OrderPackageItem,
|
|
11
|
+
OrderProduct,
|
|
12
|
+
ReleaseGood
|
|
13
|
+
} from '@things-factory/sales-base'
|
|
14
|
+
import { DateTimeDifference, Worksheet } from '@things-factory/worksheet-base'
|
|
15
|
+
|
|
16
|
+
export const powrupPackOrderResolver = {
|
|
17
|
+
async powrupPackOrder(_: void, {}, context: any): Promise<void> {
|
|
18
|
+
try {
|
|
19
|
+
await getConnection().transaction(async tx => {
|
|
20
|
+
try {
|
|
21
|
+
const powrup: Powrup = await tx.getRepository(Powrup).findOne({ where: { platform: 'powrup' } })
|
|
22
|
+
|
|
23
|
+
let releaseGoodQb = await tx
|
|
24
|
+
.getRepository(ReleaseGood)
|
|
25
|
+
.createQueryBuilder('rg')
|
|
26
|
+
.innerJoinAndSelect('rg.domain', 'domain')
|
|
27
|
+
.innerJoinAndSelect('rg.bizplace', 'bizplace')
|
|
28
|
+
.innerJoinAndSelect('rg.creator', 'creator')
|
|
29
|
+
.innerJoinAndSelect('rg.orderProducts', 'op')
|
|
30
|
+
.innerJoinAndSelect('op.product', 'prd')
|
|
31
|
+
.innerJoinAndSelect('op.productDetail', 'pd')
|
|
32
|
+
.where(`rg.source = :source`, { source: 'POWRUP' })
|
|
33
|
+
.andWhere(`rg.type = :rgType`, { rgType: 'b2c' })
|
|
34
|
+
.andWhere(`rg.status NOT IN(:...status) `, {
|
|
35
|
+
status: [ORDER_STATUS.CANCELLED, ORDER_STATUS.PENDING_CANCEL, ORDER_STATUS.DONE]
|
|
36
|
+
})
|
|
37
|
+
.andWhere(qb => {
|
|
38
|
+
const subQuery = qb
|
|
39
|
+
.subQuery()
|
|
40
|
+
.from(Worksheet, 'ws')
|
|
41
|
+
.innerJoin('ws.worksheetDetails', 'wsd')
|
|
42
|
+
.innerJoin('wsd.targetInventory', 'oi')
|
|
43
|
+
.where('rg.id = oi.release_good_id')
|
|
44
|
+
.andWhere('ws.type IN (:...wsType)', { wsType: ['PICKING', 'BATCH_PICKING'] })
|
|
45
|
+
.getQuery()
|
|
46
|
+
return 'EXISTS ' + subQuery
|
|
47
|
+
})
|
|
48
|
+
.andWhere(qb => {
|
|
49
|
+
const subQuery = qb.subQuery().from(OrderPackage, 'opk').where('rg.id = opk.release_good_id').getQuery()
|
|
50
|
+
return 'NOT EXISTS ' + subQuery
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
let releaseGoodsWithoutPackageId: ReleaseGood[] = await releaseGoodQb.getMany()
|
|
54
|
+
|
|
55
|
+
if (releaseGoodsWithoutPackageId?.length > 0) {
|
|
56
|
+
await Promise.all(
|
|
57
|
+
releaseGoodsWithoutPackageId.map(async releaseGood => {
|
|
58
|
+
const orderProducts: OrderProduct[] = releaseGood.orderProducts
|
|
59
|
+
if (
|
|
60
|
+
releaseGood?.lastMarketPackCall &&
|
|
61
|
+
DateTimeDifference.timeDifferenceInSeconds(releaseGood.lastMarketPackCall, new Date()) <= 5
|
|
62
|
+
) {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await getRepository(ReleaseGood).update(
|
|
67
|
+
{ id: releaseGood.id },
|
|
68
|
+
{
|
|
69
|
+
lastMarketPackCall: new Date()
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
await getConnection().transaction(async tx2 => {
|
|
74
|
+
try {
|
|
75
|
+
const orderPack: any = await PowrupAPI.packOrder(powrup, {
|
|
76
|
+
context: { state: { domain: releaseGood?.domain, user: null } },
|
|
77
|
+
refOrderId: releaseGood.refOrderId
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
createPayloadLog(
|
|
81
|
+
releaseGood.bizplace.id,
|
|
82
|
+
`/order-pack`,
|
|
83
|
+
{ name: releaseGood.name, refNo: releaseGood.refNo, refOrderId: releaseGood.refOrderId },
|
|
84
|
+
JSON.stringify(orderPack),
|
|
85
|
+
{ state: { domain: releaseGood?.domain, user: null } },
|
|
86
|
+
PayloadType.EGESTION,
|
|
87
|
+
'scheduler'
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
if (orderPack?.packages) {
|
|
91
|
+
const packages: any[] = orderPack.packages
|
|
92
|
+
|
|
93
|
+
await tx2.getRepository(ReleaseGood).update(
|
|
94
|
+
{ id: releaseGood.id },
|
|
95
|
+
{
|
|
96
|
+
packageId: packages[0].packageId,
|
|
97
|
+
lastMarketPackCall: new Date(),
|
|
98
|
+
updatedAt: new Date()
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
for (let idx = 0; idx < packages.length; idx++) {
|
|
103
|
+
let pkg = packages[idx]
|
|
104
|
+
const items = pkg.items
|
|
105
|
+
const orderPackage: OrderPackage = {
|
|
106
|
+
name: OrderNoGenerator.orderPackage(),
|
|
107
|
+
packageId: pkg.packageId,
|
|
108
|
+
status: ORDER_STATUS.PROCESSING,
|
|
109
|
+
releaseGood,
|
|
110
|
+
domain: releaseGood.domain,
|
|
111
|
+
bizplace: releaseGood.bizplace,
|
|
112
|
+
creator: releaseGood.creator,
|
|
113
|
+
updater: releaseGood.updater
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let savedOrderPackage: OrderPackage = await tx2.getRepository(OrderPackage).save(orderPackage)
|
|
117
|
+
|
|
118
|
+
const orderPackageItems: OrderPackageItem[] = items.map(itm => {
|
|
119
|
+
const { refCode, qty } = itm
|
|
120
|
+
const matchedOrderProduct: OrderProduct = orderProducts.find(
|
|
121
|
+
op => op.productDetail.refCode == refCode
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
name: OrderNoGenerator.orderPackageItem(),
|
|
126
|
+
orderProduct: matchedOrderProduct,
|
|
127
|
+
status: ORDER_STATUS.PROCESSING,
|
|
128
|
+
releaseQty: qty,
|
|
129
|
+
orderPackage: savedOrderPackage,
|
|
130
|
+
domain: releaseGood.domain,
|
|
131
|
+
bizplace: releaseGood.bizplace,
|
|
132
|
+
creator: releaseGood.creator,
|
|
133
|
+
updater: releaseGood.updater
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
await tx2.getRepository(OrderPackageItem).save(orderPackageItems)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} catch (e) {
|
|
141
|
+
logger.error(`powrupPackOrder[PackOrder]: ${e}`)
|
|
142
|
+
await tx2.getRepository(ReleaseGood).update({ id: releaseGood.id }, { packOrderFail: true })
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
logger.error(`powrupPackOrder[ROSearch]: ${e}`)
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
} catch (e) {
|
|
153
|
+
logger.error(`powrupPackOrder[MainError]: ${e}`)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -16,24 +16,25 @@ import { ApiError } from '../utils/error-util'
|
|
|
16
16
|
|
|
17
17
|
export async function createBizplace(request, context, tx) {
|
|
18
18
|
const { data: bizplace } = request
|
|
19
|
-
const company: Company = await tx.getRepository(Company).findOne({ where: {
|
|
19
|
+
const company: Company = await tx.getRepository(Company).findOne({ where: { id: bizplace.companyId } })
|
|
20
20
|
|
|
21
21
|
if (!company) {
|
|
22
|
-
throw new ApiError('E04', `${bizplace.
|
|
22
|
+
throw new ApiError('E04', `${bizplace.companyId} not found`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const oldBizplace = await tx.getRepository(Bizplace).findOne({
|
|
26
26
|
where: {
|
|
27
|
-
|
|
27
|
+
id: bizplace.id
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
30
|
if (oldBizplace) {
|
|
31
|
-
throw new ApiError('E04', `${bizplace.
|
|
31
|
+
throw new ApiError('E04', `${bizplace.id} is duplicated`)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
let foundUser: User = await tx.getRepository(User).findOne({ where: {
|
|
34
|
+
let foundUser: User = await tx.getRepository(User).findOne({ where: { id: bizplace.userId } })
|
|
35
35
|
|
|
36
36
|
let createdBizplace: Bizplace = await tx.getRepository(Bizplace).save({
|
|
37
|
+
id: bizplace.id,
|
|
37
38
|
name: bizplace.name,
|
|
38
39
|
description: bizplace?.description || null,
|
|
39
40
|
address: bizplace?.address || '',
|
|
@@ -56,7 +57,7 @@ export async function createBizplace(request, context, tx) {
|
|
|
56
57
|
await initGroups(tx, domain)
|
|
57
58
|
|
|
58
59
|
const userRepo: Repository<User> = tx.getRepository(User)
|
|
59
|
-
const user: User = await userRepo.findOne({ where: {
|
|
60
|
+
const user: User = await userRepo.findOne({ where: { id: bizplace.userId }, relations: ['domains', 'roles'] })
|
|
60
61
|
const roleRepo: Repository<Role> = tx.getRepository(Role)
|
|
61
62
|
const role: Role = await roleRepo.findOne({ where: { domain } })
|
|
62
63
|
const privilegeRepo: Repository<Privilege> = tx.getRepository(Privilege)
|
|
@@ -7,24 +7,22 @@ import { generateBusinessRoles } from '../../../controllers/company-initializer'
|
|
|
7
7
|
import { ApiError } from '../utils/error-util'
|
|
8
8
|
|
|
9
9
|
export async function createCompany(request, context, tx) {
|
|
10
|
-
const { name, description, brn, address, postalCode, countryCode, type, status,
|
|
10
|
+
const { id, name, description, brn, address, postalCode, countryCode, type, status, userId, refCompanyId } =
|
|
11
11
|
request.data
|
|
12
12
|
|
|
13
|
-
let foundUser: User = await tx
|
|
14
|
-
.getRepository(User)
|
|
15
|
-
.findOne({ where: { email: userEmail }, relations: ['domains', 'roles'] })
|
|
13
|
+
let foundUser: User = await tx.getRepository(User).findOne({ where: { id: userId }, relations: ['domains', 'roles'] })
|
|
16
14
|
|
|
17
15
|
const subdomain = slugger(name)
|
|
18
16
|
|
|
19
17
|
//check for existing company
|
|
20
18
|
const oldCompany = await tx.getRepository(Company).findOne({
|
|
21
19
|
where: {
|
|
22
|
-
|
|
20
|
+
id
|
|
23
21
|
}
|
|
24
22
|
})
|
|
25
23
|
|
|
26
24
|
if (oldCompany) {
|
|
27
|
-
throw new ApiError('E04', `${
|
|
25
|
+
throw new ApiError('E04', `${id} is duplicated`)
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
const oldDomain = await tx.getRepository(Domain).findOne({
|
|
@@ -48,6 +46,7 @@ export async function createCompany(request, context, tx) {
|
|
|
48
46
|
})
|
|
49
47
|
|
|
50
48
|
const company: Company = await tx.getRepository(Company).save({
|
|
49
|
+
id,
|
|
51
50
|
name,
|
|
52
51
|
description,
|
|
53
52
|
brn,
|
|
@@ -4,22 +4,22 @@ import { Bizplace } from '@things-factory/biz-base'
|
|
|
4
4
|
import { ApiError } from '../utils/error-util'
|
|
5
5
|
|
|
6
6
|
export async function createPartner(request, context, tx) {
|
|
7
|
-
const {
|
|
7
|
+
const { bizplaceId, partnerBizplaceId, userId } = request.data
|
|
8
8
|
|
|
9
9
|
const bizplace: Bizplace = await tx
|
|
10
10
|
.getRepository(Bizplace)
|
|
11
|
-
.findOne({ where: {
|
|
11
|
+
.findOne({ where: { id: bizplaceId }, relations: ['domain'] })
|
|
12
12
|
|
|
13
13
|
if (!bizplace) {
|
|
14
|
-
throw new ApiError('E04', `${
|
|
14
|
+
throw new ApiError('E04', `${bizplaceId} does not exist`)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const partnerBizplace: Bizplace = await tx
|
|
18
18
|
.getRepository(Bizplace)
|
|
19
|
-
.findOne({ where: {
|
|
19
|
+
.findOne({ where: { id: partnerBizplaceId }, relations: ['domain'] })
|
|
20
20
|
|
|
21
21
|
if (!partnerBizplace) {
|
|
22
|
-
throw new ApiError('E04', `${
|
|
22
|
+
throw new ApiError('E04', `${partnerBizplaceId} does not exist`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const isExistingCustomer: boolean = Boolean(
|
|
@@ -29,10 +29,10 @@ export async function createPartner(request, context, tx) {
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
if (isExistingCustomer) {
|
|
32
|
-
throw new ApiError('E04', `${
|
|
32
|
+
throw new ApiError('E04', `${partnerBizplaceId} already registered as partner`)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
let user: User = await tx.getRepository(User).findOne({ where: {
|
|
35
|
+
let user: User = await tx.getRepository(User).findOne({ where: { id: userId } })
|
|
36
36
|
|
|
37
37
|
await tx.getRepository(Partner).save({
|
|
38
38
|
domain: bizplace.domain,
|
|
@@ -42,8 +42,8 @@ export async function createPartner(request, context, tx) {
|
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
let data = {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
bizplaceId,
|
|
46
|
+
partnerBizplaceId
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return data
|
|
@@ -4,10 +4,10 @@ import { ApiError } from '../utils/error-util'
|
|
|
4
4
|
|
|
5
5
|
export async function createUser(request, context, tx) {
|
|
6
6
|
let user: NewUser = request?.data || {}
|
|
7
|
-
const { email } = user
|
|
7
|
+
const { id, email } = user
|
|
8
8
|
user.email = email.trim()
|
|
9
9
|
|
|
10
|
-
const oldUser: User = await tx.getRepository(User).findOne(
|
|
10
|
+
const oldUser: User = await tx.getRepository(User).findOne(id)
|
|
11
11
|
if (oldUser) {
|
|
12
12
|
throw new ApiError('E04', context.t('error.x already exists in y', { x: context.t('field.user'), y: 'operato' }))
|
|
13
13
|
}
|
|
@@ -5,20 +5,20 @@ import { Domain } from '@things-factory/shell'
|
|
|
5
5
|
import { ApiError } from '../utils/error-util'
|
|
6
6
|
|
|
7
7
|
export async function inviteUser(request, context, tx) {
|
|
8
|
-
const {
|
|
8
|
+
const { userId, bizplaceId } = request.data
|
|
9
9
|
|
|
10
|
-
const user: User = await tx.getRepository(User).findOne({ where: {
|
|
10
|
+
const user: User = await tx.getRepository(User).findOne({ where: { id: userId }, relations: ['domains'] })
|
|
11
11
|
|
|
12
12
|
if (!user) {
|
|
13
|
-
throw new ApiError('E04', `${
|
|
13
|
+
throw new ApiError('E04', `${userId} does not exist`)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const bizplace: Bizplace = await tx
|
|
17
17
|
.getRepository(Bizplace)
|
|
18
|
-
.findOne({ where: {
|
|
18
|
+
.findOne({ where: { id: bizplaceId }, relations: ['domain'] })
|
|
19
19
|
|
|
20
20
|
if (!bizplace) {
|
|
21
|
-
throw new ApiError('E04', `${
|
|
21
|
+
throw new ApiError('E04', `${bizplaceId} does not exist`)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const existingDomains: Domain[] = user.domains
|
|
@@ -30,8 +30,8 @@ export async function inviteUser(request, context, tx) {
|
|
|
30
30
|
await tx.getRepository(User).save(user)
|
|
31
31
|
|
|
32
32
|
let data = {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
bizplaceId,
|
|
34
|
+
userId
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return data
|
|
@@ -4,22 +4,22 @@ import { Bizplace } from '@things-factory/biz-base'
|
|
|
4
4
|
import { ApiError } from '../utils/error-util'
|
|
5
5
|
|
|
6
6
|
export async function terminatePartner(request, context, tx) {
|
|
7
|
-
const {
|
|
7
|
+
const { bizplaceId, partnerBizplaceId } = request.data
|
|
8
8
|
|
|
9
9
|
const bizplace: Bizplace = await tx
|
|
10
10
|
.getRepository(Bizplace)
|
|
11
|
-
.findOne({ where: {
|
|
11
|
+
.findOne({ where: { id: bizplaceId }, relations: ['domain'] })
|
|
12
12
|
|
|
13
13
|
if (!bizplace) {
|
|
14
|
-
throw new ApiError('E04', `${
|
|
14
|
+
throw new ApiError('E04', `${bizplaceId} does not exist`)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const partnerBizplace: Bizplace = await tx
|
|
18
18
|
.getRepository(Bizplace)
|
|
19
|
-
.findOne({ where: {
|
|
19
|
+
.findOne({ where: { id: partnerBizplaceId }, relations: ['domain'] })
|
|
20
20
|
|
|
21
21
|
if (!partnerBizplace) {
|
|
22
|
-
throw new ApiError('E04', `${
|
|
22
|
+
throw new ApiError('E04', `${partnerBizplaceId} does not exist`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const partner: Partner = await tx.getRepository(Partner).findOne({
|
|
@@ -37,8 +37,8 @@ export async function terminatePartner(request, context, tx) {
|
|
|
37
37
|
await terminateGrantedRoles(bizplace.domain, partnerBizplace.domain, tx)
|
|
38
38
|
|
|
39
39
|
let data = {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
bizplaceId,
|
|
41
|
+
partnerBizplaceId
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return data
|
|
@@ -5,22 +5,22 @@ import { Domain } from '@things-factory/shell'
|
|
|
5
5
|
import { ApiError } from '../utils/error-util'
|
|
6
6
|
|
|
7
7
|
export async function terminateUser(request, context, tx) {
|
|
8
|
-
const {
|
|
8
|
+
const { userId, bizplaceId } = request.data
|
|
9
9
|
|
|
10
10
|
const user: User = await tx
|
|
11
11
|
.getRepository(User)
|
|
12
|
-
.findOne({ where: {
|
|
12
|
+
.findOne({ where: { id: userId }, relations: ['domains', 'roles', 'roles.domain'] })
|
|
13
13
|
|
|
14
14
|
if (!user) {
|
|
15
|
-
throw new ApiError('E04', `${
|
|
15
|
+
throw new ApiError('E04', `${userId} does not exist`)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const bizplace: Bizplace = await tx
|
|
19
19
|
.getRepository(Bizplace)
|
|
20
|
-
.findOne({ where: {
|
|
20
|
+
.findOne({ where: { id: bizplaceId }, relations: ['domain'] })
|
|
21
21
|
|
|
22
22
|
if (!bizplace) {
|
|
23
|
-
throw new ApiError('E04', `${
|
|
23
|
+
throw new ApiError('E04', `${bizplaceId} does not exist`)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const targetDomainIdx: number = user.domains.findIndex((userDomain: Domain) => userDomain.id === bizplace.domain.id)
|
|
@@ -37,8 +37,8 @@ export async function terminateUser(request, context, tx) {
|
|
|
37
37
|
await tx.getRepository(User).save(user)
|
|
38
38
|
|
|
39
39
|
let data = {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
userId,
|
|
41
|
+
bizplaceId
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return data
|
|
@@ -9,12 +9,12 @@ export async function updateBizplace(request, context, tx) {
|
|
|
9
9
|
|
|
10
10
|
const existingBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
11
11
|
where: {
|
|
12
|
-
|
|
12
|
+
id: bizplace.id
|
|
13
13
|
},
|
|
14
14
|
relations: ['company', 'domain']
|
|
15
15
|
})
|
|
16
16
|
if (!existingBizplace) {
|
|
17
|
-
throw new ApiError('E04', `${bizplace.
|
|
17
|
+
throw new ApiError('E04', `${bizplace.id} does not exist`)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const company: Company = existingBizplace.company
|
|
@@ -6,22 +6,17 @@ import { slugger } from '@things-factory/utils'
|
|
|
6
6
|
import { ApiError } from '../utils/error-util'
|
|
7
7
|
|
|
8
8
|
export async function updateCompany(request, context, tx) {
|
|
9
|
-
const {
|
|
10
|
-
request.data
|
|
9
|
+
const { id, name, description, brn, address, postalCode, countryCode, type, status, userId } = request.data
|
|
11
10
|
|
|
12
|
-
let foundUser: User = await tx
|
|
13
|
-
.getRepository(User)
|
|
14
|
-
.findOne({ where: { email: userEmail }, relations: ['domains', 'roles'] })
|
|
11
|
+
let foundUser: User = await tx.getRepository(User).findOne({ where: { id: userId }, relations: ['domains', 'roles'] })
|
|
15
12
|
|
|
16
13
|
const subdomain = slugger(name)
|
|
17
14
|
|
|
18
15
|
//check for existing company
|
|
19
|
-
const existingCompany: Company = await tx.getRepository(Company).findOne(
|
|
20
|
-
where: { refCompanyId }
|
|
21
|
-
})
|
|
16
|
+
const existingCompany: Company = await tx.getRepository(Company).findOne(id)
|
|
22
17
|
|
|
23
18
|
if (!existingCompany) {
|
|
24
|
-
throw new ApiError('E04', `${
|
|
19
|
+
throw new ApiError('E04', `${id} does not exist`)
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
const existingBizplaces: Bizplace[] = await tx
|
|
@@ -5,7 +5,7 @@ import { ApiError } from '../utils/error-util'
|
|
|
5
5
|
export async function updateUser(request, context, tx) {
|
|
6
6
|
let user: NewUser = request?.data || {}
|
|
7
7
|
|
|
8
|
-
const existingUser: User = await tx.getRepository(User).findOne({ where: {
|
|
8
|
+
const existingUser: User = await tx.getRepository(User).findOne({ where: { id: user.id } })
|
|
9
9
|
if (!existingUser) {
|
|
10
10
|
throw new ApiError('E04', context.t('error.x does not exists in y', { x: context.t('field.user'), y: 'operato' }))
|
|
11
11
|
}
|