优化代码空字符串判断

This commit is contained in:
648540858
2022-10-17 09:39:21 +08:00
parent 4a0037d128
commit c4fc4abf7c
4 changed files with 5 additions and 57 deletions

View File

@@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.async.DeferredResult;
import com.alibaba.fastjson.JSON;
@@ -405,12 +407,11 @@ public class PlayServiceImpl implements IPlayService {
if (device == null) {
return null;
}
String mediaServerId = device.getMediaServerId();
MediaServerItem mediaServerItem;
if (mediaServerId == null || "".equals(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
} else {
mediaServerItem = mediaServerService.getOne(mediaServerId);
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
}
if (mediaServerItem == null) {
logger.warn("点播时未找到可使用的ZLM...");

View File

@@ -98,7 +98,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Override
public StreamInfo save(StreamProxyItem param) {
MediaServerItem mediaInfo;
if (param.getMediaServerId() == null || "".equals(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
}else {
mediaInfo = mediaServerService.getOne(param.getMediaServerId());