fix: 兼容获取appKey和version

This commit is contained in:
2024-10-10 01:16:51 +08:00
parent 44d8a831c2
commit 15e8c9eea9
4 changed files with 63 additions and 6 deletions

View File

@@ -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');

View File

@@ -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);