|
|
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
@@ -770,10 +771,9 @@ public class LiveServiceImpl implements ILiveService
|
|
|
if (live.getIsShow() != 1) {
|
|
|
return R.error("您未拥有直播权限");
|
|
|
}
|
|
|
- SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("living.config");
|
|
|
- Map<String, String> livingConfigMap = JSON.parseObject(sysConfig.getConfigValue(), Map.class);
|
|
|
+ Map<String, String> livingConfigMap = getLivingConfigMap(live.getCompanyId());
|
|
|
if (livingConfigMap == null || livingConfigMap.isEmpty()) {
|
|
|
- return R.error("缺失直播配置");
|
|
|
+ return R.error("缺失直播配置,请在系统参数中完善 living.config");
|
|
|
}
|
|
|
String rtmpPushUrl = generateRtmpPushUrl(livingConfigMap.get("domain"), livingConfigMap.get("app"), liveId.toString());
|
|
|
String hlvPlayUrl = generateHlvPlayUrl(livingConfigMap.get("http"), livingConfigMap.get("app"), liveId.toString());
|
|
|
@@ -994,15 +994,10 @@ public class LiveServiceImpl implements ILiveService
|
|
|
return R.error("您没有权限操作此直播间");
|
|
|
}
|
|
|
|
|
|
- SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("living.config");
|
|
|
- if (sysConfig == null || StringUtils.isEmpty(sysConfig.getConfigValue())) {
|
|
|
- log.error("直播配置不存在或为空, liveId: {}", live.getLiveId());
|
|
|
- return R.error("直播配置不存在,请联系管理员配置");
|
|
|
- }
|
|
|
- Map<String, String> livingConfigMap = JSON.parseObject(sysConfig.getConfigValue(), Map.class);
|
|
|
+ Map<String, String> livingConfigMap = getLivingConfigMap(exist.getCompanyId());
|
|
|
if (livingConfigMap == null || livingConfigMap.isEmpty()) {
|
|
|
- log.error("直播配置解析失败, liveId: {}, configValue: {}", live.getLiveId(), sysConfig.getConfigValue());
|
|
|
- return R.error("直播配置解析失败");
|
|
|
+ log.error("直播配置不存在或为空, liveId: {}", live.getLiveId());
|
|
|
+ return R.error("直播配置不存在或为空,请在系统参数中完善 living.config");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(livingConfigMap.get("domain")) || StringUtils.isEmpty(livingConfigMap.get("app"))) {
|
|
|
log.error("直播配置缺少必要参数, liveId: {}, configMap: {}", live.getLiveId(), livingConfigMap);
|
|
|
@@ -1558,6 +1553,45 @@ public class LiveServiceImpl implements ILiveService
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private Map<String, String> getLivingConfigMap(Long companyId) {
|
|
|
+ SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("living.config");
|
|
|
+ if (sysConfig == null || StringUtils.isEmpty(sysConfig.getConfigValue())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return resolveLivingConfigMap(sysConfig.getConfigValue(), companyId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private Map<String, String> resolveLivingConfigMap(String configValue, Long companyId) {
|
|
|
+ String trimmed = configValue.trim();
|
|
|
+ try {
|
|
|
+ if (trimmed.startsWith("[")) {
|
|
|
+ JSONArray configArray = JSON.parseArray(trimmed);
|
|
|
+ if (configArray == null || configArray.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (companyId != null) {
|
|
|
+ for (int i = 0; i < configArray.size(); i++) {
|
|
|
+ JSONObject item = configArray.getJSONObject(i);
|
|
|
+ if (item != null && companyId.equals(item.getLong("companyId"))) {
|
|
|
+ return item.toJavaObject(Map.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject first = configArray.getJSONObject(0);
|
|
|
+ return first == null ? null : first.toJavaObject(Map.class);
|
|
|
+ }
|
|
|
+ if (trimmed.startsWith("{")) {
|
|
|
+ return JSON.parseObject(trimmed, Map.class);
|
|
|
+ }
|
|
|
+ log.warn("living.config 格式不支持: {}", trimmed);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析 living.config 失败, configValue: {}", configValue, e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static String generateRtmpPushUrl(String domain, String app, String liveId) {
|
|
|
Date now = new Date();
|
|
|
now.setTime(now.getTime() + 24 * 3600 * 1000);
|