diff --git a/system/Tnb.Systems/System/DataInterfaceService.cs b/system/Tnb.Systems/System/DataInterfaceService.cs index b1d66fc8..5b3829fa 100644 --- a/system/Tnb.Systems/System/DataInterfaceService.cs +++ b/system/Tnb.Systems/System/DataInterfaceService.cs @@ -354,6 +354,51 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController return JsEngineUtil.CallFunction(scriptStr, output.ToJsonString(CommonConst.options));//此处时间非时间戳 } } + + /// + /// 不走js脚本 + /// + /// + /// + /// + public async Task PreviewWithOutJs(string id, [FromBody] DataInterfacePreviewInput input) + { + _configId = _userManager.TenantId; + _dbName = _userManager.TenantDbName; + object output = null; + var info = await GetInfo(id); + var dicParameters = new Dictionary(); + if (input.paramList.IsNotEmptyOrNull() && input.paramList.Count > 0) + { + dicParameters = input.paramList.ToDictionary(x => x.field, y => y.defaultValue); + } + if (!string.IsNullOrEmpty(info.Path) && !info.Path.StartsWith("http")) + { + info.Path = $"{App.HttpContext.Request.Scheme}://{App.HttpContext.Request.Host}{info.Path}"; + } + VerifyRequired(info, dicParameters); + ReplaceParameterValue(info, dicParameters); + if (info?.DataType == 1) + { + output = await GetData(info); + } + else if (info?.DataType == 2) + { + output = info.Query.ToObject(); + } + else + { + output = await GetApiDataByTypePreview(info); + } + if (info is null || info.DataProcessing.IsNullOrEmpty()) + { + return output; + } + else + { + return output.ToJsonString(CommonConst.options); + } + } /// /// 访问接口 选中 回写. @@ -578,7 +623,23 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController } catch (Exception e) { - throw Oops.Oh(ErrorCode.COM1020); + if (e.Message == "TypeError: Method or property not found") + { + try + { + var result = await PreviewWithOutJs(id, input); + List> list = JsonConvert.DeserializeObject>>(result.ToString()); + return list.FirstOrDefault()?.Keys.ToList() ?? Enumerable.Empty(); + } + catch (Exception exception) + { + throw Oops.Oh(ErrorCode.COM1020); + } + } + else + { + throw Oops.Oh(ErrorCode.COM1020); + } } } #endregion