fix: 兼容获取appKey和version
This commit is contained in:
@@ -148,6 +148,19 @@ app
|
||||
if (!files || !files.length) {
|
||||
throw new CustomError('files is required');
|
||||
}
|
||||
let am = await AppModel.findOne({ where: { key: appKey, uid: tokenUser.id } });
|
||||
if (!am) {
|
||||
am = await AppModel.create({
|
||||
user: tokenUser.username,
|
||||
key: appKey,
|
||||
uid: tokenUser.id,
|
||||
version: '0.0.0',
|
||||
title: appKey,
|
||||
data: {
|
||||
files: [],
|
||||
},
|
||||
});
|
||||
}
|
||||
let app = await AppListModel.findOne({ where: { version: version, key: appKey, uid: tokenUser.id } });
|
||||
if (!app) {
|
||||
// throw new CustomError('app not found');
|
||||
|
||||
@@ -114,6 +114,7 @@ app
|
||||
const list = await AppListModel.findAll({ where: { key: am.key, uid: tokenUser.id } });
|
||||
await am.destroy({ force: true });
|
||||
await Promise.all(list.map((item) => item.destroy({ force: true })));
|
||||
ctx.body = 'success';
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
Reference in New Issue
Block a user