storemw-core-api 1.0.17 → 1.0.18
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/controllers/item/itemController.js +233 -0
- package/dist/controllers/location/locationController.js +163 -117
- package/dist/controllers/user/userController.js +112 -0
- package/dist/generated/generated/prisma/edge.js +43 -26
- package/dist/generated/generated/prisma/index-browser.js +30 -21
- package/dist/generated/generated/prisma/index.d.ts +2279 -2018
- package/dist/generated/generated/prisma/index.js +51 -26
- package/dist/generated/generated/prisma/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node +0 -0
- package/dist/generated/generated/prisma/libquery_engine-rhel-openssl-3.0.x.so.node +0 -0
- package/dist/generated/generated/prisma/package.json +1 -1
- package/dist/generated/generated/prisma/query_engine_bg.wasm +0 -0
- package/dist/generated/generated/prisma/runtime/edge-esm.js +3 -3
- package/dist/generated/generated/prisma/runtime/edge.js +3 -3
- package/dist/generated/generated/prisma/runtime/library.js +2 -2
- package/dist/generated/generated/prisma/runtime/react-native.js +2 -2
- package/dist/generated/generated/prisma/runtime/wasm-compiler-edge.js +3 -3
- package/dist/generated/generated/prisma/runtime/wasm-engine-edge.js +2 -2
- package/dist/generated/generated/prisma/schema.prisma +69 -60
- package/dist/generated/generated/prisma/wasm.js +43 -26
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +5 -2
- package/dist/models/injection_field/ItemInjectionFieldModel.d.ts +73 -1
- package/dist/models/user/RetailerModel.d.ts +191 -0
- package/dist/models/user/RetailerModel.js +15 -0
- package/dist/schema/middleware/route/schemaUser.d.ts +3 -3
- package/dist/schema/middleware/route/schemaUser.js +1 -1
- package/dist/schema/payload/index.d.ts +10 -0
- package/dist/schema/payload/index.js +20 -1
- package/dist/schema/payload/injection_field/schemaInjectionField.d.ts +14 -14
- package/dist/schema/payload/item/schemaItemItem.d.ts +333 -190
- package/dist/schema/payload/item/schemaItemItem.js +32 -55
- package/dist/schema/payload/item/schemaItemProduct.d.ts +333 -0
- package/dist/schema/payload/item/schemaItemProduct.js +38 -0
- package/dist/schema/payload/location/schemaLocationRack.d.ts +287 -0
- package/dist/schema/payload/location/schemaLocationRack.js +53 -0
- package/dist/schema/payload/location/schemaLocationSlot.d.ts +194 -0
- package/dist/schema/payload/location/schemaLocationSlot.js +40 -0
- package/dist/schema/payload/user/schemaUser.d.ts +5 -5
- package/dist/schema/payload/user/schemaUser.js +1 -1
- package/dist/schema/payload/user/schemaUserRetailer.d.ts +309 -0
- package/dist/schema/payload/user/schemaUserRetailer.js +53 -0
- package/dist/services/injection_field/InjectionFieldService.d.ts +1 -1
- package/dist/services/injection_field/ItemInjectionFieldService.d.ts +9 -0
- package/dist/services/item/ItemItemService.d.ts +36 -2
- package/dist/services/item/ItemItemService.js +38 -3
- package/dist/services/item/ItemProductService.d.ts +32 -64
- package/dist/services/item/ItemProductService.js +23 -14
- package/dist/services/item/ItemService.d.ts +1 -0
- package/dist/services/item/ItemService.js +59 -5
- package/dist/services/location/LocationRackService.d.ts +5 -11
- package/dist/services/location/LocationRackService.js +8 -112
- package/dist/services/location/LocationService.d.ts +8 -1
- package/dist/services/location/LocationService.js +79 -17
- package/dist/services/location/LocationSlotService.d.ts +6 -9
- package/dist/services/location/LocationSlotService.js +9 -14
- package/dist/services/user/RetailerService.d.ts +113 -0
- package/dist/services/user/RetailerService.js +268 -0
- package/dist/services/user/UserService.d.ts +5 -0
- package/dist/services/user/UserService.js +35 -0
- package/dist/utils/responseUtils.js +18 -1
- package/package.json +2 -2
- package/prisma/schema.prisma +1 -1
|
@@ -54,6 +54,141 @@ const createItem = async (req, res, next) => {
|
|
|
54
54
|
let response = {};
|
|
55
55
|
let reqScope = req.body.scope;
|
|
56
56
|
let reqPayload = req.body.payload;
|
|
57
|
+
if (requestItemType === "product") {
|
|
58
|
+
let request = payload_1.schemaItemProductCreatePayload.parse({
|
|
59
|
+
scope: {
|
|
60
|
+
target: reqScope.target,
|
|
61
|
+
action: reqScope.action
|
|
62
|
+
},
|
|
63
|
+
payload: {
|
|
64
|
+
product: {
|
|
65
|
+
itemName: reqPayload.product.item_name,
|
|
66
|
+
productCode: reqPayload.product.product_code,
|
|
67
|
+
model: reqPayload.product.model,
|
|
68
|
+
description: reqPayload.product.description,
|
|
69
|
+
categoryId: reqPayload.product.category_id,
|
|
70
|
+
brandId: reqPayload.product.brand_id,
|
|
71
|
+
summary: reqPayload.product.summary,
|
|
72
|
+
status: reqPayload.product.status,
|
|
73
|
+
},
|
|
74
|
+
item: {
|
|
75
|
+
productId: reqPayload.item.product_id,
|
|
76
|
+
code: reqPayload.item.code,
|
|
77
|
+
skuCode: reqPayload.item.sku_code,
|
|
78
|
+
uomId: reqPayload.item.uom_id,
|
|
79
|
+
status: reqPayload.item.status,
|
|
80
|
+
isPackage: reqPayload.item.is_package,
|
|
81
|
+
itemDescription: reqPayload.item.item_description,
|
|
82
|
+
remark: reqPayload.item.remark,
|
|
83
|
+
cost: reqPayload.item.cost,
|
|
84
|
+
uomPrice: reqPayload.item.uom_price,
|
|
85
|
+
floorPrice: reqPayload.item.floor_price,
|
|
86
|
+
grossWeight: reqPayload.item.gross_weight,
|
|
87
|
+
volumeWeight: reqPayload.item.volume_weight,
|
|
88
|
+
netWeight: reqPayload.item.net_weight,
|
|
89
|
+
dimensionWidth: reqPayload.item.dimension_width,
|
|
90
|
+
dimensionHeight: reqPayload.item.dimension_height,
|
|
91
|
+
dimensionLength: reqPayload.item.dimension_length,
|
|
92
|
+
cbm: reqPayload.item.cbm,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
let payload = {
|
|
97
|
+
itemType: requestItemType,
|
|
98
|
+
data: {
|
|
99
|
+
product: {
|
|
100
|
+
itemName: request.payload.product.itemName,
|
|
101
|
+
brandId: request.payload.product.brandId,
|
|
102
|
+
categoryId: request.payload.product.categoryId,
|
|
103
|
+
model: request.payload.product.model,
|
|
104
|
+
description: request.payload.product.description,
|
|
105
|
+
productCode: request.payload.product.productCode,
|
|
106
|
+
status: Boolean(request.payload.product.status),
|
|
107
|
+
summary: request.payload.product.summary,
|
|
108
|
+
},
|
|
109
|
+
item: {
|
|
110
|
+
code: request.payload.item.code,
|
|
111
|
+
skuCode: request.payload.item.skuCode,
|
|
112
|
+
uomId: request.payload.item.uomId,
|
|
113
|
+
status: Boolean(request.payload.item.status),
|
|
114
|
+
isPackage: Boolean(request.payload.item.isPackage),
|
|
115
|
+
itemDescription: request.payload.item.itemDescription,
|
|
116
|
+
remark: request.payload.item.remark,
|
|
117
|
+
cost: request.payload.item.cost,
|
|
118
|
+
uomPrice: request.payload.item.uomPrice,
|
|
119
|
+
floorPrice: request.payload.item.floorPrice,
|
|
120
|
+
grossWeight: request.payload.item.grossWeight,
|
|
121
|
+
volumeWeight: request.payload.item.volumeWeight,
|
|
122
|
+
netWeight: request.payload.item.netWeight,
|
|
123
|
+
dimensionWidth: request.payload.item.dimensionWidth,
|
|
124
|
+
dimensionHeight: request.payload.item.dimensionHeight,
|
|
125
|
+
dimensionLength: request.payload.item.dimensionLength,
|
|
126
|
+
cbm: request.payload.item.cbm,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
response = {
|
|
131
|
+
[`${getRootName(requestItemType, true)}`]: await itemService.createItem(payload)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (requestItemType === "item") {
|
|
135
|
+
let request = payload_1.schemaItemItemCreatePayload.parse({
|
|
136
|
+
scope: {
|
|
137
|
+
target: reqScope.target,
|
|
138
|
+
action: reqScope.action
|
|
139
|
+
},
|
|
140
|
+
payload: {
|
|
141
|
+
item: {
|
|
142
|
+
productId: reqPayload.item.product_id,
|
|
143
|
+
code: reqPayload.item.code,
|
|
144
|
+
skuCode: reqPayload.item.sku_code,
|
|
145
|
+
uomId: reqPayload.item.uom_id,
|
|
146
|
+
status: reqPayload.item.status,
|
|
147
|
+
isPackage: reqPayload.item.is_package,
|
|
148
|
+
itemDescription: reqPayload.item.item_description,
|
|
149
|
+
remark: reqPayload.item.remark,
|
|
150
|
+
cost: reqPayload.item.cost,
|
|
151
|
+
uomPrice: reqPayload.item.uom_price,
|
|
152
|
+
floorPrice: reqPayload.item.floor_price,
|
|
153
|
+
grossWeight: reqPayload.item.gross_weight,
|
|
154
|
+
volumeWeight: reqPayload.item.volume_weight,
|
|
155
|
+
netWeight: reqPayload.item.net_weight,
|
|
156
|
+
dimensionWidth: reqPayload.item.dimension_width,
|
|
157
|
+
dimensionHeight: reqPayload.item.dimension_height,
|
|
158
|
+
dimensionLength: reqPayload.item.dimension_length,
|
|
159
|
+
cbm: reqPayload.item.cbm,
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
let payload = {
|
|
164
|
+
itemType: requestItemType,
|
|
165
|
+
data: {
|
|
166
|
+
item: {
|
|
167
|
+
productId: request.payload.item.productId,
|
|
168
|
+
code: request.payload.item.code,
|
|
169
|
+
skuCode: request.payload.item.skuCode,
|
|
170
|
+
uomId: request.payload.item.uomId,
|
|
171
|
+
status: Boolean(request.payload.item.status),
|
|
172
|
+
isPackage: Boolean(request.payload.item.isPackage),
|
|
173
|
+
itemDescription: request.payload.item.itemDescription,
|
|
174
|
+
remark: request.payload.item.remark,
|
|
175
|
+
cost: request.payload.item.cost,
|
|
176
|
+
uomPrice: request.payload.item.uomPrice,
|
|
177
|
+
floorPrice: request.payload.item.floorPrice,
|
|
178
|
+
grossWeight: request.payload.item.grossWeight,
|
|
179
|
+
volumeWeight: request.payload.item.volumeWeight,
|
|
180
|
+
netWeight: request.payload.item.netWeight,
|
|
181
|
+
dimensionWidth: request.payload.item.dimensionWidth,
|
|
182
|
+
dimensionHeight: request.payload.item.dimensionHeight,
|
|
183
|
+
dimensionLength: request.payload.item.dimensionLength,
|
|
184
|
+
cbm: request.payload.item.cbm,
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
response = {
|
|
189
|
+
[`${getRootName(requestItemType, true)}`]: await itemService.createItem(payload)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
57
192
|
if (requestItemType === "category") {
|
|
58
193
|
let request = payload_1.schemaItemCategoryCreatePayload.parse({
|
|
59
194
|
scope: {
|
|
@@ -165,6 +300,104 @@ const updateItem = async (req, res, next) => {
|
|
|
165
300
|
let response = {};
|
|
166
301
|
let reqScope = req.body.scope;
|
|
167
302
|
let reqPayload = req.body.payload;
|
|
303
|
+
if (requestItemType === "product") {
|
|
304
|
+
let request = payload_1.schemaItemProductUpdatePayload.parse({
|
|
305
|
+
scope: {
|
|
306
|
+
target: reqScope.target,
|
|
307
|
+
action: reqScope.action
|
|
308
|
+
},
|
|
309
|
+
payload: {
|
|
310
|
+
product: {
|
|
311
|
+
itemName: reqPayload.product.item_name,
|
|
312
|
+
productCode: reqPayload.product.product_code,
|
|
313
|
+
model: reqPayload.product.model,
|
|
314
|
+
description: reqPayload.product.description,
|
|
315
|
+
categoryId: reqPayload.product.category_id,
|
|
316
|
+
brandId: reqPayload.product.brand_id,
|
|
317
|
+
summary: reqPayload.product.summary,
|
|
318
|
+
status: reqPayload.product.status,
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
let payload = {
|
|
323
|
+
id: Number(itemId),
|
|
324
|
+
itemType: requestItemType,
|
|
325
|
+
data: {
|
|
326
|
+
product: {
|
|
327
|
+
itemName: request.payload.product.itemName,
|
|
328
|
+
brandId: request.payload.product.brandId,
|
|
329
|
+
categoryId: request.payload.product.categoryId,
|
|
330
|
+
model: request.payload.product.model,
|
|
331
|
+
description: request.payload.product.description,
|
|
332
|
+
productCode: request.payload.product.productCode,
|
|
333
|
+
status: Boolean(request.payload.product.status),
|
|
334
|
+
summary: request.payload.product.summary,
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
response = {
|
|
339
|
+
[`${getRootName(requestItemType, true)}`]: await itemService.updateItem(payload)
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
if (requestItemType === "item") {
|
|
343
|
+
let request = payload_1.schemaItemItemUpdatePayload.parse({
|
|
344
|
+
scope: {
|
|
345
|
+
target: reqScope.target,
|
|
346
|
+
action: reqScope.action
|
|
347
|
+
},
|
|
348
|
+
payload: {
|
|
349
|
+
item: {
|
|
350
|
+
// productId: reqPayload.item.product_id,
|
|
351
|
+
// uomId: reqPayload.item.uom_id,
|
|
352
|
+
code: reqPayload.item.code,
|
|
353
|
+
skuCode: reqPayload.item.sku_code,
|
|
354
|
+
status: reqPayload.item.status,
|
|
355
|
+
isPackage: reqPayload.item.is_package,
|
|
356
|
+
itemDescription: reqPayload.item.item_description,
|
|
357
|
+
remark: reqPayload.item.remark,
|
|
358
|
+
cost: reqPayload.item.cost,
|
|
359
|
+
uomPrice: reqPayload.item.uom_price,
|
|
360
|
+
floorPrice: reqPayload.item.floor_price,
|
|
361
|
+
grossWeight: reqPayload.item.gross_weight,
|
|
362
|
+
volumeWeight: reqPayload.item.volume_weight,
|
|
363
|
+
netWeight: reqPayload.item.net_weight,
|
|
364
|
+
dimensionWidth: reqPayload.item.dimension_width,
|
|
365
|
+
dimensionHeight: reqPayload.item.dimension_height,
|
|
366
|
+
dimensionLength: reqPayload.item.dimension_length,
|
|
367
|
+
cbm: reqPayload.item.cbm,
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
let payload = {
|
|
372
|
+
id: Number(itemId),
|
|
373
|
+
itemType: requestItemType,
|
|
374
|
+
data: {
|
|
375
|
+
item: {
|
|
376
|
+
// productId: request.payload.item.productId,
|
|
377
|
+
// uomId: request.payload.item.uomId,
|
|
378
|
+
code: request.payload.item.code,
|
|
379
|
+
skuCode: request.payload.item.skuCode,
|
|
380
|
+
status: Boolean(request.payload.item.status),
|
|
381
|
+
isPackage: Boolean(request.payload.item.isPackage),
|
|
382
|
+
itemDescription: request.payload.item.itemDescription,
|
|
383
|
+
remark: request.payload.item.remark,
|
|
384
|
+
cost: request.payload.item.cost,
|
|
385
|
+
uomPrice: request.payload.item.uomPrice,
|
|
386
|
+
floorPrice: request.payload.item.floorPrice,
|
|
387
|
+
grossWeight: request.payload.item.grossWeight,
|
|
388
|
+
volumeWeight: request.payload.item.volumeWeight,
|
|
389
|
+
netWeight: request.payload.item.netWeight,
|
|
390
|
+
dimensionWidth: request.payload.item.dimensionWidth,
|
|
391
|
+
dimensionHeight: request.payload.item.dimensionHeight,
|
|
392
|
+
dimensionLength: request.payload.item.dimensionLength,
|
|
393
|
+
cbm: request.payload.item.cbm,
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
response = {
|
|
398
|
+
[`${getRootName(requestItemType, true)}`]: await itemService.updateItem(payload)
|
|
399
|
+
};
|
|
400
|
+
}
|
|
168
401
|
if (requestItemType === "category") {
|
|
169
402
|
let request = payload_1.schemaItemCategoryUpdatePayload.parse({
|
|
170
403
|
scope: {
|
|
@@ -98,64 +98,88 @@ const createLocation = async (req, res, next) => {
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
response = {
|
|
101
|
-
|
|
101
|
+
[`${getRootName(requestLocationType, true)}`]: await locationService.createLocation(payload)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (requestLocationType === "rack") {
|
|
105
|
+
let request = payload_1.schemaLocationRackCreatePayload.parse({
|
|
106
|
+
scope: {
|
|
107
|
+
target: reqScope.target,
|
|
108
|
+
action: reqScope.action,
|
|
109
|
+
},
|
|
110
|
+
payload: {
|
|
111
|
+
rack: {
|
|
112
|
+
locationId: reqPayload.rack.location_id,
|
|
113
|
+
rackType: reqPayload.rack.rack_type,
|
|
114
|
+
rackName: reqPayload.rack.rack_name,
|
|
115
|
+
sequence: reqPayload.rack.sequence,
|
|
116
|
+
isDefault: Boolean(reqPayload.rack.is_default),
|
|
117
|
+
status: Boolean(reqPayload.rack.status)
|
|
118
|
+
},
|
|
119
|
+
slots: reqPayload.slots.map((i) => ({
|
|
120
|
+
// rackId: i.rack_id,
|
|
121
|
+
slotName: i.name,
|
|
122
|
+
sequence: i.sequence,
|
|
123
|
+
isDefault: Boolean(i.is_default),
|
|
124
|
+
status: Boolean(i.status)
|
|
125
|
+
}))
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
let payload = {
|
|
129
|
+
locationType: requestLocationType,
|
|
130
|
+
data: {
|
|
131
|
+
rack: {
|
|
132
|
+
locationId: request.payload.rack.locationId,
|
|
133
|
+
rackName: request.payload.rack.rackName,
|
|
134
|
+
rackSequence: request.payload.rack.sequence,
|
|
135
|
+
rackType: request.payload.rack.rackType,
|
|
136
|
+
status: Boolean(request.payload.rack.status),
|
|
137
|
+
isDefault: Boolean(request.payload.rack.isDefault)
|
|
138
|
+
},
|
|
139
|
+
slots: request.payload.slots.map(i => ({
|
|
140
|
+
slotName: i.slotName,
|
|
141
|
+
slotSequence: i.sequence,
|
|
142
|
+
isDefault: i.isDefault,
|
|
143
|
+
status: i.status
|
|
144
|
+
}))
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
response = {
|
|
148
|
+
[`${getRootName(requestLocationType, true)}`]: await locationService.createLocation(payload)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (requestLocationType === "slot") {
|
|
152
|
+
let request = payload_1.schemaLocationSlotCreatePayload.parse({
|
|
153
|
+
scope: {
|
|
154
|
+
target: reqScope.target,
|
|
155
|
+
action: reqScope.action,
|
|
156
|
+
},
|
|
157
|
+
payload: {
|
|
158
|
+
slot: {
|
|
159
|
+
rackId: reqPayload.slot.rack_id,
|
|
160
|
+
slotName: reqPayload.slot.slot_name,
|
|
161
|
+
sequence: reqPayload.slot.sequence,
|
|
162
|
+
isDefault: Boolean(reqPayload.slot.is_default),
|
|
163
|
+
status: Boolean(reqPayload.slot.status)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
let payload = {
|
|
168
|
+
locationType: requestLocationType,
|
|
169
|
+
data: {
|
|
170
|
+
slot: {
|
|
171
|
+
rackId: request.payload.slot.rackId,
|
|
172
|
+
slotName: request.payload.slot.slotName,
|
|
173
|
+
slotSequence: request.payload.slot.sequence,
|
|
174
|
+
status: Boolean(request.payload.slot.status),
|
|
175
|
+
isDefault: Boolean(request.payload.slot.isDefault)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
response = {
|
|
180
|
+
[`${getRootName(requestLocationType, true)}`]: await locationService.createLocation(payload)
|
|
102
181
|
};
|
|
103
182
|
}
|
|
104
|
-
// if (requestLocationType === "state") {
|
|
105
|
-
// let request = schemaRegionStateCreatePayload.parse({
|
|
106
|
-
// state: {
|
|
107
|
-
// countryId: req.body.payload.state?.country_id,
|
|
108
|
-
// stateName: req.body.payload.state?.state_name,
|
|
109
|
-
// status: req.body.payload.state?.status,
|
|
110
|
-
// },
|
|
111
|
-
// areas: req.body.payload?.area_items ? req.body.payload.area_items.map((i: any) => ({
|
|
112
|
-
// areaName: i.area_name,
|
|
113
|
-
// postcodeString: i.postcode_string,
|
|
114
|
-
// status: i?.status
|
|
115
|
-
// })) : []
|
|
116
|
-
// })
|
|
117
|
-
// let payload: LocationCreateProps = {
|
|
118
|
-
// locationType: requestLocationType,
|
|
119
|
-
// data: {
|
|
120
|
-
// state: {
|
|
121
|
-
// countryId: Number(request.state.countryId),
|
|
122
|
-
// stateName: request.state.stateName,
|
|
123
|
-
// status: Boolean(request.state.status)
|
|
124
|
-
// },
|
|
125
|
-
// areas: request.areas.length ? request.areas.map(i => ({
|
|
126
|
-
// areaName: i.areaName,
|
|
127
|
-
// postcodeString: i.postcodeString,
|
|
128
|
-
// status: Boolean(i.status)
|
|
129
|
-
// })) : []
|
|
130
|
-
// }
|
|
131
|
-
// }
|
|
132
|
-
// response = {
|
|
133
|
-
// state: await locationService.createLocation(payload)
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
// if (requestLocationType === "area") {
|
|
137
|
-
// let request = schemaRegionAreaCreatePayload.parse({
|
|
138
|
-
// area: {
|
|
139
|
-
// stateId: req.body?.payload?.area?.state_id,
|
|
140
|
-
// areaName: req.body?.payload?.area?.area_name,
|
|
141
|
-
// postcodeString: req.body?.payload?.area?.postcode_string,
|
|
142
|
-
// status: req.body?.payload?.area?.status
|
|
143
|
-
// }
|
|
144
|
-
// })
|
|
145
|
-
// let payload: LocationCreateProps = {
|
|
146
|
-
// locationType: requestLocationType,
|
|
147
|
-
// data: {
|
|
148
|
-
// area: {
|
|
149
|
-
// areaName: request.area.areaName,
|
|
150
|
-
// postcodeString: request.area.postcodeString,
|
|
151
|
-
// status: Boolean(request.area.status)
|
|
152
|
-
// }
|
|
153
|
-
// }
|
|
154
|
-
// }
|
|
155
|
-
// response = {
|
|
156
|
-
// state: await locationService.createLocation(payload)
|
|
157
|
-
// }
|
|
158
|
-
// }
|
|
159
183
|
(0, utils_1.sendSuccess)(res, response, `Location(${requestLocationType}) created successfully`);
|
|
160
184
|
}
|
|
161
185
|
catch (error) {
|
|
@@ -223,69 +247,91 @@ const updateLocation = async (req, res, next) => {
|
|
|
223
247
|
}
|
|
224
248
|
};
|
|
225
249
|
response = {
|
|
226
|
-
|
|
250
|
+
[`${getRootName(requestLocationType, true)}`]: await locationService.updateLocation(payload)
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (requestLocationType === "rack") {
|
|
254
|
+
let request = payload_1.schemaLocationRackUpdatePayload.parse({
|
|
255
|
+
scope: {
|
|
256
|
+
target: reqScope.target,
|
|
257
|
+
action: reqScope.action,
|
|
258
|
+
},
|
|
259
|
+
payload: {
|
|
260
|
+
rack: {
|
|
261
|
+
// locationId: reqPayload.rack.location_id,
|
|
262
|
+
rackType: reqPayload.rack.rack_type,
|
|
263
|
+
rackName: reqPayload.rack.rack_name,
|
|
264
|
+
sequence: reqPayload.rack.sequence,
|
|
265
|
+
isDefault: Boolean(reqPayload.rack.is_default),
|
|
266
|
+
status: Boolean(reqPayload.rack.status)
|
|
267
|
+
},
|
|
268
|
+
slots: reqPayload.slots.map((i) => ({
|
|
269
|
+
...(i?.slot_id ? { locationSlotId: i?.slot_id } : {}),
|
|
270
|
+
slotName: i.name,
|
|
271
|
+
sequence: i.sequence,
|
|
272
|
+
isDefault: Boolean(i.is_default),
|
|
273
|
+
status: Boolean(i.status)
|
|
274
|
+
}))
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
let payload = {
|
|
278
|
+
id: Number(id),
|
|
279
|
+
locationType: requestLocationType,
|
|
280
|
+
data: {
|
|
281
|
+
rack: {
|
|
282
|
+
// locationId: request.payload.rack.locationId,
|
|
283
|
+
rackName: request.payload.rack.rackName,
|
|
284
|
+
rackSequence: request.payload.rack.sequence,
|
|
285
|
+
rackType: request.payload.rack.rackType,
|
|
286
|
+
status: Boolean(request.payload.rack.status),
|
|
287
|
+
isDefault: Boolean(request.payload.rack.isDefault)
|
|
288
|
+
},
|
|
289
|
+
slots: request.payload.slots.map(i => ({
|
|
290
|
+
...(i.locationSlotId ? { locationSlotId: i.locationSlotId } : {}),
|
|
291
|
+
slotName: i.slotName,
|
|
292
|
+
slotSequence: i.sequence,
|
|
293
|
+
isDefault: i.isDefault,
|
|
294
|
+
status: i.status
|
|
295
|
+
}))
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
response = {
|
|
299
|
+
[`${getRootName(requestLocationType, true)}`]: await locationService.updateLocation(payload)
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if (requestLocationType === "slot") {
|
|
303
|
+
let request = payload_1.schemaLocationSlotUpdatePayload.parse({
|
|
304
|
+
scope: {
|
|
305
|
+
target: reqScope.target,
|
|
306
|
+
action: reqScope.action,
|
|
307
|
+
},
|
|
308
|
+
payload: {
|
|
309
|
+
slot: {
|
|
310
|
+
rackId: reqPayload.slot.rack_id,
|
|
311
|
+
slotName: reqPayload.slot.slot_name,
|
|
312
|
+
sequence: reqPayload.slot.sequence,
|
|
313
|
+
isDefault: Boolean(reqPayload.slot.is_default),
|
|
314
|
+
status: Boolean(reqPayload.slot.status)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
let payload = {
|
|
319
|
+
id: Number(id),
|
|
320
|
+
locationType: requestLocationType,
|
|
321
|
+
data: {
|
|
322
|
+
slot: {
|
|
323
|
+
// rackId: request.payload.slot.rackId,
|
|
324
|
+
slotName: request.payload.slot.slotName,
|
|
325
|
+
slotSequence: request.payload.slot.sequence,
|
|
326
|
+
status: Boolean(request.payload.slot.status),
|
|
327
|
+
isDefault: Boolean(request.payload.slot.isDefault)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
response = {
|
|
332
|
+
[`${getRootName(requestLocationType, true)}`]: await locationService.updateLocation(payload)
|
|
227
333
|
};
|
|
228
334
|
}
|
|
229
|
-
// if (requestLocationType === "state") {
|
|
230
|
-
// let request = schemaRegionStateUpdatePayload.parse({
|
|
231
|
-
// state: {
|
|
232
|
-
// // countryId: req.body.payload.state?.country_id,
|
|
233
|
-
// stateName: req.body.payload.state?.state_name,
|
|
234
|
-
// status: req.body.payload.state?.status,
|
|
235
|
-
// },
|
|
236
|
-
// areas: req.body.payload?.area_items ? req.body.payload.area_items.map((i: any) => ({
|
|
237
|
-
// areaId: i?.area_id ?? "",
|
|
238
|
-
// areaName: i.area_name,
|
|
239
|
-
// postcodeString: i.postcode_string,
|
|
240
|
-
// status: i?.status
|
|
241
|
-
// })) : []
|
|
242
|
-
// })
|
|
243
|
-
// let payload: LocationUpdateProps = {
|
|
244
|
-
// id: Number(id),
|
|
245
|
-
// locationType: requestLocationType,
|
|
246
|
-
// data: {
|
|
247
|
-
// state: {
|
|
248
|
-
// // countryId: Number(request.state.countryId),
|
|
249
|
-
// stateName: request.state.stateName,
|
|
250
|
-
// status: Boolean(request.state.status)
|
|
251
|
-
// },
|
|
252
|
-
// areas: request.areas.length ? request.areas.map(i => ({
|
|
253
|
-
// ...(i?.areaId ? { areaId: Number(i.areaId) } : {}),
|
|
254
|
-
// areaName: i.areaName,
|
|
255
|
-
// postcodeString: i.postcodeString,
|
|
256
|
-
// status: Boolean(i.status)
|
|
257
|
-
// })) : []
|
|
258
|
-
// }
|
|
259
|
-
// }
|
|
260
|
-
// response = {
|
|
261
|
-
// state: await locationService.updateLocation(payload)
|
|
262
|
-
// }
|
|
263
|
-
// }
|
|
264
|
-
// if (requestLocationType === "area") {
|
|
265
|
-
// let request = schemaRegionAreaUpdatePayload.parse({
|
|
266
|
-
// area: {
|
|
267
|
-
// id,
|
|
268
|
-
// stateId: req.body?.payload?.area?.state_id,
|
|
269
|
-
// areaName: req.body?.payload?.area?.area_name,
|
|
270
|
-
// postcodeString: req.body?.payload?.area?.postcode_string,
|
|
271
|
-
// status: req.body?.payload?.area?.status
|
|
272
|
-
// }
|
|
273
|
-
// })
|
|
274
|
-
// let payload: LocationUpdateProps = {
|
|
275
|
-
// id: Number(id),
|
|
276
|
-
// locationType: requestLocationType,
|
|
277
|
-
// data: {
|
|
278
|
-
// area: {
|
|
279
|
-
// areaName: request.area.areaName,
|
|
280
|
-
// postcodeString: request.area.postcodeString,
|
|
281
|
-
// status: Boolean(request.area.status)
|
|
282
|
-
// }
|
|
283
|
-
// }
|
|
284
|
-
// }
|
|
285
|
-
// response = {
|
|
286
|
-
// state: await locationService.updateLocation(payload)
|
|
287
|
-
// }
|
|
288
|
-
// }
|
|
289
335
|
(0, utils_1.sendSuccess)(res, response, `Location(${requestLocationType}) updated successfully`);
|
|
290
336
|
}
|
|
291
337
|
catch (error) {
|
|
@@ -13,6 +13,9 @@ const getRootName = (requestUserType, toSingular) => {
|
|
|
13
13
|
case "customer":
|
|
14
14
|
rootName = toSingular ? "customer" : "customers";
|
|
15
15
|
break;
|
|
16
|
+
case "retailer":
|
|
17
|
+
rootName = toSingular ? "retailer" : "retailers";
|
|
18
|
+
break;
|
|
16
19
|
case "worker":
|
|
17
20
|
rootName = toSingular ? "worker" : "workers";
|
|
18
21
|
break;
|
|
@@ -208,6 +211,60 @@ const createUser = async (req, res, next) => {
|
|
|
208
211
|
[`${getRootName(requestUserType, true)}`]: await userService.createUser(payload)
|
|
209
212
|
};
|
|
210
213
|
}
|
|
214
|
+
if (requestUserType === "retailer") {
|
|
215
|
+
let request = payload_1.schemaUserRetailerCreatePayload.parse({
|
|
216
|
+
scope: {
|
|
217
|
+
target: reqScope.target,
|
|
218
|
+
action: reqScope.action
|
|
219
|
+
},
|
|
220
|
+
payload: {
|
|
221
|
+
credential: {
|
|
222
|
+
username: reqPayload.credential.username,
|
|
223
|
+
password: reqPayload.credential.password,
|
|
224
|
+
firstname: reqPayload.credential.firstname,
|
|
225
|
+
lastname: reqPayload.credential.lastname,
|
|
226
|
+
contact: reqPayload.credential.contact,
|
|
227
|
+
email: reqPayload.credential.email,
|
|
228
|
+
address: reqPayload.credential.address,
|
|
229
|
+
status: reqPayload.credential.status
|
|
230
|
+
},
|
|
231
|
+
retailer: {
|
|
232
|
+
code: reqPayload.retailer.code,
|
|
233
|
+
accountCode: reqPayload.retailer.account_code,
|
|
234
|
+
companyName: reqPayload.retailer.company_name,
|
|
235
|
+
regNo: reqPayload.retailer.reg_no,
|
|
236
|
+
gstNo: reqPayload.retailer.gst_no,
|
|
237
|
+
remark: reqPayload.retailer.remark,
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
let payload = {
|
|
242
|
+
userType: requestUserType,
|
|
243
|
+
data: {
|
|
244
|
+
user: {
|
|
245
|
+
loginUsername: request.payload.credential.username,
|
|
246
|
+
loginPassword: request.payload.credential.password,
|
|
247
|
+
address: request.payload.credential.address,
|
|
248
|
+
contact: request.payload.credential.contact,
|
|
249
|
+
email: request.payload.credential.email,
|
|
250
|
+
firstname: request.payload.credential.firstname,
|
|
251
|
+
lastname: request.payload.credential.lastname,
|
|
252
|
+
status: request.payload.credential.status === 1
|
|
253
|
+
},
|
|
254
|
+
retailer: {
|
|
255
|
+
code: request.payload.retailer.code,
|
|
256
|
+
accountCode: request.payload.retailer.accountCode,
|
|
257
|
+
companyName: request.payload.retailer.companyName,
|
|
258
|
+
regNo: request.payload.retailer.regNo,
|
|
259
|
+
remark: request.payload.retailer.remark,
|
|
260
|
+
gstNo: request.payload.retailer.gstNo
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
response = {
|
|
265
|
+
[`${getRootName(requestUserType, true)}`]: await userService.createUser(payload)
|
|
266
|
+
};
|
|
267
|
+
}
|
|
211
268
|
(0, utils_1.sendSuccess)(res, response, `User(${requestUserType}) created successfully`);
|
|
212
269
|
}
|
|
213
270
|
catch (error) {
|
|
@@ -390,6 +447,61 @@ const updateUser = async (req, res, next) => {
|
|
|
390
447
|
[`${getRootName(requestUserType, true)}`]: await userService.updateUser(payload)
|
|
391
448
|
};
|
|
392
449
|
}
|
|
450
|
+
if (requestUserType === "retailer") {
|
|
451
|
+
let request = payload_1.schemaUserRetailerUpdatePayload.parse({
|
|
452
|
+
scope: {
|
|
453
|
+
target: reqScope.target,
|
|
454
|
+
action: reqScope.action
|
|
455
|
+
},
|
|
456
|
+
payload: {
|
|
457
|
+
credential: {
|
|
458
|
+
// username: reqPayload.credential.username,
|
|
459
|
+
password: reqPayload.credential.password,
|
|
460
|
+
firstname: reqPayload.credential.firstname,
|
|
461
|
+
lastname: reqPayload.credential.lastname,
|
|
462
|
+
contact: reqPayload.credential.contact,
|
|
463
|
+
email: reqPayload.credential.email,
|
|
464
|
+
address: reqPayload.credential.address,
|
|
465
|
+
status: reqPayload.credential.status
|
|
466
|
+
},
|
|
467
|
+
retailer: {
|
|
468
|
+
code: reqPayload.retailer.code,
|
|
469
|
+
accountCode: reqPayload.retailer.account_code,
|
|
470
|
+
companyName: reqPayload.retailer.company_name,
|
|
471
|
+
regNo: reqPayload.retailer.reg_no,
|
|
472
|
+
gstNo: reqPayload.retailer.gst_no,
|
|
473
|
+
remark: reqPayload.retailer.remark,
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
let payload = {
|
|
478
|
+
id: Number(userId),
|
|
479
|
+
userType: requestUserType,
|
|
480
|
+
data: {
|
|
481
|
+
user: {
|
|
482
|
+
loginUsername: request.payload.credential.username,
|
|
483
|
+
...(request.payload.credential.password ? { loginPassword: request.payload.credential.password } : {}),
|
|
484
|
+
address: request.payload.credential.address,
|
|
485
|
+
contact: request.payload.credential.contact,
|
|
486
|
+
email: request.payload.credential.email,
|
|
487
|
+
firstname: request.payload.credential.firstname,
|
|
488
|
+
lastname: request.payload.credential.lastname,
|
|
489
|
+
status: request.payload.credential.status === 1
|
|
490
|
+
},
|
|
491
|
+
retailer: {
|
|
492
|
+
code: request.payload.retailer.code,
|
|
493
|
+
accountCode: request.payload.retailer.accountCode,
|
|
494
|
+
companyName: request.payload.retailer.companyName,
|
|
495
|
+
regNo: request.payload.retailer.regNo,
|
|
496
|
+
remark: request.payload.retailer.remark,
|
|
497
|
+
gstNo: request.payload.retailer.gstNo
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
response = {
|
|
502
|
+
[`${getRootName(requestUserType, true)}`]: await userService.updateUser(payload)
|
|
503
|
+
};
|
|
504
|
+
}
|
|
393
505
|
(0, utils_1.sendSuccess)(res, response, `User(${requestUserType}) updated successfully`);
|
|
394
506
|
}
|
|
395
507
|
catch (error) {
|