各种账户导入功能
# 导入jd第三方书城账户
function parseXlsx(filePath) {
const obj = xlsx.parse(filePath);
return obj[0].data;
}
export function batchImport(req, res) {
const {path} = req.file;
const obj = parseXlsx(path);
const num = obj.length;
const pms = [];
for(let i = 0; i < num - 1; i++) {
const element = obj[i + 1];
const data = {
account: element[0],
password: element[1],
email: element[2],
active: true,
};
pms.push(ThirdPartyAccount.findOrCreate(data.email, data));
}
return Promise.all(pms)
.then(respondWithResult(res, 201))
.catch(handleError(res));
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
上次更新: 2023/11/17, 05:08:18