修复删除挂载点失败的问题

This commit is contained in:
2026-06-04 10:37:37 +08:00
parent b85c368f8d
commit edeb90ebcd
4 changed files with 14 additions and 6 deletions

View File

@@ -156,9 +156,9 @@ class HomeController extends Controller {
} }
// 根据删除结果返回响应 // 根据删除结果返回响应
if (result) { if (result) {
setResponse(ctx, 200, '修改挂载点名称成功', "none"); setResponse(ctx, 200, '删除挂载点成功', "none");
} else { } else {
setResponse(ctx, 404, '修改挂载点名称失败', "none"); setResponse(ctx, 404, '删除挂载点失败', "none");
} }
} catch (error) { } catch (error) {
// 记录异常日志 // 记录异常日志

View File

@@ -54,6 +54,8 @@ class HomeService extends Service {
mountpoint.push(body.mountpoint); mountpoint.push(body.mountpoint);
await redis.get(redisType[uidLastCode]).set(redisKey + 'mountpoint', JSON.stringify(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 result = await model[uidLastCode].create(form);
const systemForm = { const systemForm = {
mountpoint: body.mountpoint, mountpoint: body.mountpoint,
@@ -236,11 +238,13 @@ class HomeService extends Service {
"C": ctx.model2.CNtripRecord, "C": ctx.model2.CNtripRecord,
"T": ctx.model4.TNtripRecord "T": ctx.model4.TNtripRecord
}; };
const result = await ctx.model3.Mountpoint.destroy({ where });
if (result == 0) return false;
const resetList = await modelType[uidLastCode].destroy({ where }); const resetList = await modelType[uidLastCode].destroy({ where });
await modelName[uidLastCode].destroy({ where }); await modelName[uidLastCode].destroy({ where });
await model[uidLastCode].destroy({ where }); await model[uidLastCode].destroy({ where });
await modelRecord[uidLastCode].destroy({ where }); await modelRecord[uidLastCode].destroy({ where });
return resetList.length == 0 ? false : resetList; return resetList == 0 ? false : resetList;
} catch (error) { } catch (error) {
const blockName = fileName + "--" + "delMountpoint"; const blockName = fileName + "--" + "delMountpoint";
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);
@@ -363,7 +367,6 @@ class HomeService extends Service {
async viewPassword(uid, body) { async viewPassword(uid, body) {
const { ctx } = this; const { ctx } = this;
try { try {
const { mountpoint } = body;
const uidLastCode = shunt(uid); const uidLastCode = shunt(uid);
const model = { const model = {
"B": ctx.model.BNtripClient, "B": ctx.model.BNtripClient,
@@ -371,7 +374,7 @@ class HomeService extends Service {
"T": ctx.model4.TNtripClient "T": ctx.model4.TNtripClient
}; };
const attributes = ['base']; 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 }); const user = await model[uidLastCode].findOne({ attributes, where });
return user || false; return user || false;
} catch (error) { } catch (error) {
@@ -617,7 +620,7 @@ class HomeService extends Service {
"T": ctx.model4.BNtripMsg "T": ctx.model4.BNtripMsg
}; };
const resetList = await modelName[uidLastCode].destroy({ where }); const resetList = await modelName[uidLastCode].destroy({ where });
return resetList.length == 0 ? false : resetList; return resetList == 0 ? false : resetList;
} catch (error) { } catch (error) {
const blockName = fileName + "--" + "delHistoryMsg"; const blockName = fileName + "--" + "delHistoryMsg";
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);

View File

@@ -0,0 +1 @@
[2026-6-4>>>9:46:13]>>>home--saveMountpoint>>>>SequelizeUniqueConstraintError: Validation error

4
serviceLog/2026/6/4.txt Normal file
View File

@@ -0,0 +1,4 @@
[2026-6-4>>>9:42:32]>>>home--saveMountpoint>>>>SequelizeUniqueConstraintError: Validation error
[2026-6-4>>>9:44:54]>>>home--saveMountpoint>>>>SequelizeUniqueConstraintError: Validation error
[2026-6-4>>>9:49:49]>>>home--saveMountpoint>>>>SequelizeUniqueConstraintError: Validation error
[2026-6-4>>>9:53:3]>>>home--saveMountpoint>>>>SequelizeUniqueConstraintError: Validation error