@steedos/data-import 2.1.37 → 2.1.38
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/lib/importRecords.router.js +29 -7
- package/lib/importRecords.router.js.map +1 -1
- package/lib/objectImport.js +100 -59
- package/lib/objectImport.js.map +1 -1
- package/package.json +4 -4
- package/src/importRecords.router.ts +41 -17
- package/src/objectImport.ts +646 -546
|
@@ -14,29 +14,53 @@ import _ from 'lodash';
|
|
|
14
14
|
// declare var Meteor: any;
|
|
15
15
|
declare var Steedos: any;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @param req
|
|
19
|
+
* @param res
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
17
22
|
const initiateImport = async function (req, res) {
|
|
18
23
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
const userSession = req.user;
|
|
25
|
+
// const spaceId = userSession.spaceId;
|
|
26
|
+
let { importObjId, importObjectHistoryId } = req.body;
|
|
27
|
+
let fileId = null;
|
|
28
|
+
const isSpaceAdmin = req.user.is_space_admin;
|
|
29
|
+
//传入了importObjId参数,必须是工作区管理员权限
|
|
30
|
+
if (importObjId && !isSpaceAdmin) {
|
|
31
|
+
return res
|
|
32
|
+
.status(401)
|
|
33
|
+
.send({ status: "error", message: "Permission denied" });
|
|
34
|
+
}
|
|
21
35
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
if (importObjectHistoryId) {
|
|
37
|
+
const record = await getObject('queue_import_history').findOne(importObjectHistoryId);
|
|
38
|
+
if(!record){
|
|
39
|
+
throw new Error(
|
|
40
|
+
`can not find queue_import_history record with given id "${importObjectHistoryId}"`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if(!record.file){
|
|
44
|
+
throw new Error(`Upload excel file, please.`);
|
|
45
|
+
}
|
|
46
|
+
fileId = record.file
|
|
47
|
+
importObjId = record.queue_import
|
|
48
|
+
}
|
|
26
49
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const importObjId = req.body.importObjId;
|
|
31
|
-
try {
|
|
32
|
-
let result = await importWithCmsFile(importObjId, userSession);
|
|
33
|
-
return res.status(200).send({ status: 'success', result });
|
|
34
|
-
} catch (error) {
|
|
35
|
-
return res.status(500).send({ status: 'failed', message: error.message });
|
|
36
|
-
}
|
|
50
|
+
// if (!Steedos.hasFeature('metadata_api', spaceId)) {
|
|
51
|
+
// return res.status(403).send({ status: 'error', message: 'Please upgrade the platform license to Enterprise Edition' });
|
|
52
|
+
// }
|
|
37
53
|
|
|
54
|
+
try {
|
|
55
|
+
let result = await importWithCmsFile(importObjId, userSession, importObjectHistoryId, fileId);
|
|
56
|
+
return res.status(200).send({ status: "success", result });
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return res
|
|
59
|
+
.status(500)
|
|
60
|
+
.send({ status: "failed", message: error.message });
|
|
61
|
+
}
|
|
38
62
|
} catch (error) {
|
|
39
|
-
|
|
63
|
+
return res.status(500).send({ status: "failed", error: error.message });
|
|
40
64
|
}
|
|
41
65
|
}
|
|
42
66
|
|