/// <summary>
///
/// </summary>
/// <param name="mkey"></param>
/// <param name="resField"></param>
/// <param name="jparams"></param>
/// <param name="httpContext"></param>
/// <returns></returns>
public async Task<IActionResult> ListUsed(string mkey, string resField, JToken jparams, HttpContext httpContext)
{
var pf = new PFGlobalParameter { OwnerId = RequestPFUtil.GetOwnerId(httpContext), SysId = RequestPFUtil.GetSysId(httpContext) };
Dictionary<string, object> dictionaryUrl = RequestPFUtil.ConvertHTByReqFormOrParamsD(httpContext);
dictionaryUrl["rmt"] = RequestModuleType.List.ToString().ToLower();
dictionaryUrl["_rmt"] = RequestModuleType.List.ToString().ToLower();
dictionaryUrl["_mkey"] = mkey;
dictionaryUrl["_resField"] = resField;
_authProvider.SetAuthParams(pf, dictionaryUrl);
pf.RequestModuleType = RequestModuleType.List;
pf.ModuleKey = mkey;
pf.ReponseField = resField;
//读取文件的配置数据
SqlConfig sqlConfig = _sqlConfigService.BuildUseSqlConfigMapper(true, pf, mkey, resField);
if (sqlConfig.ResponseFieldTemp.DataFromType == DataFromType.Api)
{
return await _nodeApiService.Query(httpContext, dictionaryUrl, mkey, resField, null, RequestModuleType.List, sqlConfig.ResponseFieldTemp.NjcResult, sqlConfig.ResponseFieldTemp.NjcArgs);
}
else if (sqlConfig.ResponseFieldTemp.DataFromType == DataFromType.ConfigFile)
{
#region 读取文件的配置数据
JToken resultCache = new JObject();
resultCache["success"] = false;
StringBuilder sb = new StringBuilder();
string detailPath = sqlConfig.ResponseFieldTemp?.Mock?.List;
RequestModuleType rmt = RequestModuleType.List;
if (!string.IsNullOrEmpty(detailPath))
{
sb.Append(detailPath);
foreach (string key in dictionaryUrl.Keys)
{
if (detailPath.Contains($"{key}"))
{
sb.Replace($"{key}", dictionaryUrl[key]?.ToString());
}
}
}
if (!string.IsNullOrEmpty(detailPath))
{
var str = FileUtil.ReadFileAndContentByVirUrl(sb.ToString());
if (string.IsNullOrEmpty(str))
{
throw new BizException(ErrorCodeConst.FILE_17010.ErrorCode, $"【{sb.ToString()}】未读取到内容");
}
dictionaryUrl = await NodeJsUtil.SetRequestParams(pf, _configurationBuilderService, _nodeServices, dictionaryUrl, httpContext, mkey, resField, rmt, sqlConfig.ResponseFieldTemp.NjcArgs);
resultCache = JsonUtil.Deserialize<JToken>(str);
}
else
{
throw new BizException(ErrorCodeConst.FILE_17010.ErrorCode, $"【responseField:key:mock:{rmt.ToString().ToLower()}】未配置");
}
//end读取文件的配置数据
#endregion
return await NodeJsUtil.ResponseRequestResult(pf, _configurationBuilderService, _nodeServices, dictionaryUrl, httpContext, mkey, resField, resultCache, rmt, sqlConfig.ResponseFieldTemp.NjcResult);
}
else
{
string cacheKey = _quDataResultCache.GetCacheKey(pf, dictionaryUrl);
// string cacheKeyTemp = MD5.MD5Encrypt(JsonUtil.Serialize(dictionaryUrl));
if (!string.IsNullOrEmpty(cacheKey)) dictionaryUrl["_cache"] = cacheKey;
var resultCache = new ResultObject<DataTable> { Success = false };// _quDataResultCache.Get<ResultObject<DataTable>>(pf, dictionaryUrl, out cacheKey);
if (resultCache == null || resultCache.Success == false)
{
dictionaryUrl = await NodeJsUtil.SetRequestParams(pf, _configurationBuilderService, _nodeServices, dictionaryUrl, httpContext, mkey, resField, RequestModuleType.List, sqlConfig.ResponseFieldTemp.NjcArgs);
resultCache = ListJson(pf, mkey, resField, dictionaryUrl);
}
if (resultCache != null || resultCache.Success != false)
{
_quDataResultCache.Set<ResultObject<DataTable>>(pf, dictionaryUrl, cacheKey, resultCache);
}
return await NodeJsUtil.ResponseRequestResult(pf, _configurationBuilderService, _nodeServices, dictionaryUrl, httpContext, mkey, resField, resultCache, RequestModuleType.List, sqlConfig.ResponseFieldTemp.NjcResult);
}
}
文档更新时间: 2021-07-04 08:00 作者:admin