修复错误

--AgentVoicePrintServiceImpl.java
 1.修复事务处理过程出错,返回错误无法被前端页面处理
 2.修复更新声纹方法,更正错误sql
This commit is contained in:
JianYu Zheng
2025-07-08 15:48:20 +08:00
parent 10b7259b13
commit 601a90981e
@@ -65,9 +65,13 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
// 发送注册声纹请求 // 发送注册声纹请求
registerVoicePrint(entity.getId(), resource); registerVoicePrint(entity.getId(), resource);
return true; return true;
} catch (Exception e) { } catch (RenException e) {
status.setRollbackOnly(); // 标记事务回滚 status.setRollbackOnly(); // 标记事务回滚
throw e; throw e;
} catch (Exception e) {
status.setRollbackOnly(); // 标记事务回滚
log.error("保存声纹错误原因:{}",e.getMessage());
throw new RenException("保存声纹错误,请联系管理员");
} }
})); }));
} }
@@ -87,9 +91,13 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
} }
cancelVoicePrint(voicePrintId); cancelVoicePrint(voicePrintId);
return true; return true;
} catch (Exception e) { } catch (RenException e) {
status.setRollbackOnly(); // 标记事务回滚 status.setRollbackOnly(); // 标记事务回滚
throw e; throw e;
} catch (Exception e) {
status.setRollbackOnly(); // 标记事务回滚
log.error("删除声纹错误原因:{}",e.getMessage());
throw new RenException("删除声纹错误,请联系管理员");
} }
})); }));
} }
@@ -112,7 +120,7 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
@Override @Override
public boolean update(Long userId, AgentVoicePrintUpdateDTO dto) { public boolean update(Long userId, AgentVoicePrintUpdateDTO dto) {
Long l = baseMapper.selectCount(new LambdaQueryWrapper<AgentVoicePrintEntity>() Long l = baseMapper.selectCount(new LambdaQueryWrapper<AgentVoicePrintEntity>()
.eq(AgentVoicePrintEntity::getAgentId, dto.getId()) .eq(AgentVoicePrintEntity::getId, dto.getId())
.eq(AgentVoicePrintEntity::getCreator, userId)); .eq(AgentVoicePrintEntity::getCreator, userId));
if (l != 1) { if (l != 1) {
return false; return false;
@@ -143,9 +151,13 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
registerVoicePrint(id, resource); registerVoicePrint(id, resource);
} }
return true; return true;
} catch (Exception e) { } catch (RenException e) {
status.setRollbackOnly(); // 标记事务回滚 status.setRollbackOnly(); // 标记事务回滚
throw e; throw e;
} catch (Exception e) {
status.setRollbackOnly(); // 标记事务回滚
log.error("修改声纹错误原因:{}",e.getMessage());
throw new RenException("修改声纹错误,请联系管理员");
} }
})); }));
} }