修复删除挂载点失败的问题
This commit is contained in:
@@ -156,9 +156,9 @@ class HomeController extends Controller {
|
||||
}
|
||||
// 根据删除结果返回响应
|
||||
if (result) {
|
||||
setResponse(ctx, 200, '修改挂载点名称成功', "none");
|
||||
setResponse(ctx, 200, '删除挂载点成功', "none");
|
||||
} else {
|
||||
setResponse(ctx, 404, '修改挂载点名称失败', "none");
|
||||
setResponse(ctx, 404, '删除挂载点失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
// 记录异常日志
|
||||
|
||||
@@ -54,6 +54,8 @@ class HomeService extends Service {
|
||||
mountpoint.push(body.mountpoint);
|
||||
await redis.get(redisType[uidLastCode]).set(redisKey + 'mountpoint', JSON.stringify(mountpoint));
|
||||
}
|
||||
const findMountpoint = await model[uidLastCode].findOne({ where: { mountpoint: body.mountpoint } });
|
||||
if (findMountpoint) return false; // 挂载点已存在
|
||||
const result = await model[uidLastCode].create(form);
|
||||
const systemForm = {
|
||||
mountpoint: body.mountpoint,
|
||||
@@ -236,11 +238,13 @@ class HomeService extends Service {
|
||||
"C": ctx.model2.CNtripRecord,
|
||||
"T": ctx.model4.TNtripRecord
|
||||
};
|
||||
const result = await ctx.model3.Mountpoint.destroy({ where });
|
||||
if (result == 0) return false;
|
||||
const resetList = await modelType[uidLastCode].destroy({ where });
|
||||
await modelName[uidLastCode].destroy({ where });
|
||||
await model[uidLastCode].destroy({ where });
|
||||
await modelRecord[uidLastCode].destroy({ where });
|
||||
return resetList.length == 0 ? false : resetList;
|
||||
return resetList == 0 ? false : resetList;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "delMountpoint";
|
||||
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);
|
||||
@@ -363,7 +367,6 @@ class HomeService extends Service {
|
||||
async viewPassword(uid, body) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const { mountpoint } = body;
|
||||
const uidLastCode = shunt(uid);
|
||||
const model = {
|
||||
"B": ctx.model.BNtripClient,
|
||||
@@ -371,7 +374,7 @@ class HomeService extends Service {
|
||||
"T": ctx.model4.TNtripClient
|
||||
};
|
||||
const attributes = ['base'];
|
||||
const where = { user_uid: uid, mountpoint };
|
||||
const where = { user_uid: uid, mountpoint: body.mountpoint };
|
||||
const user = await model[uidLastCode].findOne({ attributes, where });
|
||||
return user || false;
|
||||
} catch (error) {
|
||||
@@ -617,7 +620,7 @@ class HomeService extends Service {
|
||||
"T": ctx.model4.BNtripMsg
|
||||
};
|
||||
const resetList = await modelName[uidLastCode].destroy({ where });
|
||||
return resetList.length == 0 ? false : resetList;
|
||||
return resetList == 0 ? false : resetList;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "delHistoryMsg";
|
||||
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);
|
||||
|
||||
Reference in New Issue
Block a user