feat(stream-proxy): 添加应用名修改时的唯一性验证
修改内容: - update() 方法中添加 app+stream 唯一性检查 - 检测用户是否修改了 app 或 stream 字段 - 如果修改后与其他记录冲突,抛出友好的错误提示 - 错误消息:"应用名 [xxx] 下的流ID [yyy] 已存在" 场景示例: 原记录:大堂/001 用户修改为:停车场/001 系统检查:停车场下是否已有 001 - 如果已存在 → 抛出错误提示 - 如果不存在 → 允许修改 防止问题: - 避免修改应用名后产生重复的 app+stream 组合 - 保持数据库唯一约束的完整性 - 提供清晰的用户反馈
This commit is contained in:
@@ -235,6 +235,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
if (streamProxyInDb == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "代理不存在");
|
||||
}
|
||||
|
||||
// 检查 app+stream 唯一性(如果修改了app或stream)
|
||||
if (!streamProxyInDb.getApp().equals(streamProxy.getApp()) ||
|
||||
!streamProxyInDb.getStream().equals(streamProxy.getStream())) {
|
||||
StreamProxy duplicate = streamProxyMapper.selectOneByAppAndStream(
|
||||
streamProxy.getApp(), streamProxy.getStream());
|
||||
if (duplicate != null && !duplicate.getId().equals(streamProxy.getId())) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(),
|
||||
"应用名 [" + streamProxy.getApp() + "] 下的流ID [" + streamProxy.getStream() + "] 已存在");
|
||||
}
|
||||
}
|
||||
|
||||
int updateResult = streamProxyMapper.update(streamProxy);
|
||||
if (updateResult > 0 && !ObjectUtils.isEmpty(streamProxy.getGbDeviceId())) {
|
||||
if (streamProxy.getGbId() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user