525 lines
27 KiB
C#
525 lines
27 KiB
C#
using JNPF.Common.Const;
|
|
using JNPF.Common.Extension;
|
|
using JNPF.Common.Manager;
|
|
using JNPF.Common.Security;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.Systems.Entitys.Permission;
|
|
using JNPF.VisualDev.Engine;
|
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
|
using JNPF.VisualDev.Entitys;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using Newtonsoft.Json.Linq;
|
|
using SqlSugar;
|
|
using JNPF.Systems.Entitys.System;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using JNPF.RemoteRequest.Extensions;
|
|
using JNPF.Systems.Entitys.Model.DataInterFace;
|
|
using JNPF.Common.Core.Manager;
|
|
|
|
namespace JNPF.Common.CodeGen.DataParsing;
|
|
|
|
public class ControlParsing : ITransient
|
|
{
|
|
/// <summary>
|
|
/// 服务基础仓储.
|
|
/// </summary>
|
|
private readonly ISqlSugarRepository<UserEntity> _repository;
|
|
|
|
/// <summary>
|
|
/// 缓存管理.
|
|
/// </summary>
|
|
private readonly ICacheManager _cacheManager;
|
|
|
|
/// <summary>
|
|
/// 用户管理.
|
|
/// </summary>
|
|
private readonly IUserManager _userManager;
|
|
|
|
/// <summary>
|
|
/// 数据接口.
|
|
/// </summary>
|
|
private readonly IDataInterfaceService _dataInterfaceService;
|
|
|
|
/// <summary>
|
|
/// 构造函数.
|
|
/// </summary>
|
|
public ControlParsing(
|
|
IUserManager userManager,
|
|
ISqlSugarRepository<UserEntity> repositoryRepository,
|
|
IDataInterfaceService dataInterfaceService,
|
|
ICacheManager cacheManager)
|
|
{
|
|
_userManager = userManager;
|
|
_repository = repositoryRepository;
|
|
_cacheManager = cacheManager;
|
|
_dataInterfaceService = dataInterfaceService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 解析控件数据.
|
|
/// </summary>
|
|
/// <param name="oldDatas">原数据集合.</param>
|
|
/// <param name="vModelStr">解析的字段集合 多个需以 ,号隔开.</param>
|
|
/// <param name="jnpfKeyConst">控件类型 (JnpfKeyConst).</param>
|
|
/// <param name="tenantId">租户Id.</param>
|
|
/// <param name="vModelAttr">控件属性 (vModel ,属性字符串).</param>
|
|
/// <returns></returns>
|
|
public async Task<List<Dictionary<string, object>>> GetParsDataList(List<Dictionary<string, object>> oldDatas, string vModelStr, string jnpfKeyConst, string tenantId, List<FieldsModel>? vModelAttr = null)
|
|
{
|
|
var vModels = new Dictionary<string, object>();
|
|
var vModelList = vModelStr.Split(',');
|
|
oldDatas.ForEach(items =>
|
|
{
|
|
foreach (var item in items)
|
|
{
|
|
if (vModelList.Contains(item.Key) && !vModels.ContainsKey(item.Key)) vModels.Add(item.Key, jnpfKeyConst);
|
|
|
|
// 子表
|
|
if (item.Value != null && item.Key.ToLower().Contains("tablefield") && (item.Value is List<Dictionary<string, object>> || item.Value.GetType().Name.Equals("JArray")))
|
|
{
|
|
var ctOldDatas = item.Value.ToObject<List<Dictionary<string, object>>>(CommonConst.options);
|
|
ctOldDatas.ForEach(ctItems =>
|
|
{
|
|
foreach (var ctItem in ctItems)
|
|
{
|
|
if ((vModelList.Contains(item.Key + "-" + ctItem.Key) || vModelList.Contains(item.Key + "-" + ctItem.Key + "_name")) && !vModels.ContainsKey(item.Key + "-" + ctItem.Key))
|
|
vModels.Add(item.Key + "-" + ctItem.Key, jnpfKeyConst);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
return await GetParsDataByList(vModelAttr, oldDatas, vModels, tenantId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取解析数据.
|
|
/// </summary>
|
|
/// <param name="fields">模板集合.</param>
|
|
/// <param name="oldDatas">原数据集合.</param>
|
|
/// <param name="vModels">需解析的字段 (字段名,JnpfKeyConst/子表dictionary).</param>
|
|
/// <param name="tenantId">租户Id.</param>
|
|
/// <returns></returns>
|
|
private async Task<List<Dictionary<string, object>>> GetParsDataByList(List<FieldsModel> fields, List<Dictionary<string, object>> oldDatas, Dictionary<string, object> vModels, string tenantId)
|
|
{
|
|
var cacheData = await GetCaCheData(vModels, tenantId);
|
|
var usersselectDatas = cacheData.Where(t => t.Key.Equals(CommonConst.CodeGenDynamic + "_usersSelect_" + tenantId)).FirstOrDefault().Value.ToObject<Dictionary<string, string>>(); // 用户组件
|
|
|
|
foreach (var items in oldDatas)
|
|
{
|
|
for (var i = 0; i < items.Count; i++)
|
|
{
|
|
var item = items.ToList()[i];
|
|
|
|
if (vModels.Any(x => x.Key.Equals(item.Key)) && items[item.Key] != null)
|
|
{
|
|
FieldsModel model = fields.Any(x => x.__vModel__.Equals(item.Key)) ? fields.Find(x => x.__vModel__.Equals(item.Key)) : (fields.Any(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) ? fields.Find(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) : new FieldsModel());
|
|
model.separator = ",";
|
|
var jnpfKey = vModels.FirstOrDefault(x => x.Key.Equals(item.Key)).Value;
|
|
switch (jnpfKey)
|
|
{
|
|
case JnpfKeyConst.USERSSELECT:
|
|
{
|
|
var itemValue = item.Value;
|
|
if (itemValue == null && items.ContainsKey(item.Key.Replace("_name", string.Empty))) itemValue = items[item.Key.Replace("_name", string.Empty)];
|
|
if (itemValue != null)
|
|
{
|
|
var vList = new List<string>();
|
|
if (itemValue.ToString().Contains("[")) vList = itemValue.ToString().ToObject<List<string>>();
|
|
else vList.Add(itemValue.ToString());
|
|
var itemValues = new List<string>();
|
|
vList.ForEach(it =>
|
|
{
|
|
if (usersselectDatas.ContainsKey(it)) itemValues.Add(usersselectDatas[it]);
|
|
});
|
|
if (itemValues.Any()) items[item.Key] = string.Join(",", itemValues);
|
|
}
|
|
}
|
|
|
|
break;
|
|
case JnpfKeyConst.POPUPSELECT: // 弹窗选择
|
|
{
|
|
if (model.interfaceId.IsNullOrEmpty()) continue;
|
|
List<Dictionary<string, string>> popupselectDataList = new List<Dictionary<string, string>>();
|
|
|
|
// 获取远端数据
|
|
var dynamic = await _dataInterfaceService.GetInfo(model.interfaceId);
|
|
var redisName = CommonConst.CodeGenDynamic + "_" + model.interfaceId + "_" + tenantId;
|
|
if (_cacheManager.Exists(redisName))
|
|
{
|
|
popupselectDataList = _cacheManager.Get(redisName).ToObject<List<Dictionary<string, string>>>();
|
|
}
|
|
else
|
|
{
|
|
if (dynamic == null) break;
|
|
switch (dynamic.DataType)
|
|
{
|
|
case 1: // SQL数据
|
|
{
|
|
_dataInterfaceService.ReplaceParameterValue(dynamic, new Dictionary<string, string>());
|
|
var pObj = await _dataInterfaceService.GetData(dynamic);
|
|
popupselectDataList = pObj.ToJsonString().ToObject<List<Dictionary<string, string>>>();
|
|
}
|
|
break;
|
|
case 2: // 静态数据
|
|
{
|
|
var children = model.props.props.children;
|
|
foreach (var data in JValue.Parse(dynamic.Query))
|
|
{
|
|
popupselectDataList.Add(new Dictionary<string, string>() { { data.Value<string>(model.props.props.value), data.Value<string>(model.props.props.label) } });
|
|
if (data.Value<object>(children) != null && data.Value<object>(children).ToString() != "")
|
|
popupselectDataList.AddRange(GetDynamicInfiniteData(data.Value<object>(children).ToString(), model.props.props));
|
|
}
|
|
}
|
|
break;
|
|
case 3: // Api数据
|
|
{
|
|
var result = await GetApiDataByTypePreview(dynamic); // 请求接口
|
|
popupselectDataList = result.ContainsKey("list") ? result["list"].ToObject<List<Dictionary<string, string>>>() : new List<Dictionary<string, string>>();
|
|
if ((popupselectDataList == null || !popupselectDataList.Any()) && result.ContainsKey("data"))
|
|
popupselectDataList = result["data"].ToObject<Dictionary<string, object>>().ContainsKey("list") ? result["data"]["list"].ToObject<List<Dictionary<string, string>>>() : new List<Dictionary<string, string>>();
|
|
}
|
|
break;
|
|
}
|
|
_cacheManager.Set(redisName, popupselectDataList.ToList(), TimeSpan.FromMinutes(10)); // 缓存10分钟
|
|
popupselectDataList = _cacheManager.Get(redisName).ToObject<List<Dictionary<string, string>>>();
|
|
}
|
|
|
|
switch (dynamic.DataType)
|
|
{
|
|
case 1: // SQL数据
|
|
{
|
|
var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
|
if (specificData != null)
|
|
{
|
|
// 要用模板的 “显示字段 - relationField”来展示数据
|
|
items[model.__vModel__ + "_id"] = items[item.Key];
|
|
items[item.Key] = specificData[model.relationField];
|
|
|
|
// 弹窗选择属性
|
|
if (model.relational.IsNotEmptyOrNull())
|
|
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = specificData[fItem];
|
|
}
|
|
}
|
|
break;
|
|
case 2: // 静态数据
|
|
{
|
|
var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
|
if (vara != null)
|
|
{
|
|
items[model.__vModel__ + "_id"] = items[item.Key];
|
|
items[item.Key] = vara[items[item.Key].ToString()];
|
|
|
|
// 弹窗选择属性
|
|
if (model.relational.IsNotEmptyOrNull())
|
|
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = vara[fItem];
|
|
}
|
|
}
|
|
break;
|
|
case 3: // Api数据
|
|
{
|
|
var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
|
if (vara != null)
|
|
{
|
|
items[model.__vModel__ + "_id"] = items[item.Key];
|
|
items[item.Key] = vara[items[item.Key].ToString()];
|
|
|
|
// 弹窗选择属性
|
|
if (model.relational.IsNotEmptyOrNull())
|
|
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = vara[fItem];
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case JnpfKeyConst.RELATIONFORM: // 关联表单
|
|
{
|
|
if (model.modelId.IsNullOrEmpty()) continue;
|
|
List<Dictionary<string, object>> relationFormDataList = new List<Dictionary<string, object>>();
|
|
|
|
var redisName = CommonConst.CodeGenDynamic + "_" + model.modelId + "_" + tenantId;
|
|
if (_cacheManager.Exists(redisName))
|
|
{
|
|
relationFormDataList = _cacheManager.Get(redisName).ToObject<List<Dictionary<string, object>>>();
|
|
}
|
|
else
|
|
{
|
|
// 根据可视化功能ID获取该模板全部数据
|
|
var relationFormModel = await _repository.AsSugarClient().Queryable<VisualDevEntity>().FirstAsync(v => v.Id == model.modelId);
|
|
var newFieLdsModelList = relationFormModel.FormData.ToObject<FormDataModel>().fields.FindAll(x => model.relationField.Equals(x.__vModel__));
|
|
VisualDevModelListQueryInput listQueryInput = new VisualDevModelListQueryInput
|
|
{
|
|
dataType = "1",
|
|
pageSize = 999999
|
|
};
|
|
|
|
Scoped.Create((_, scope) =>
|
|
{
|
|
var services = scope.ServiceProvider;
|
|
var _runService = App.GetService<IRunService>(services);
|
|
var res = _runService.GetRelationFormList(relationFormModel, listQueryInput).WaitAsync(TimeSpan.FromMinutes(2)).Result;
|
|
_cacheManager.Set(redisName, res.list.ToList(), TimeSpan.FromMinutes(10)); // 缓存10分钟
|
|
});
|
|
var cacheStr = _cacheManager.Get(redisName);
|
|
if (cacheStr.IsNotEmptyOrNull()) relationFormDataList = _cacheManager.Get(redisName).ToObject<List<Dictionary<string, object>>>();
|
|
}
|
|
|
|
var relationFormRealData = relationFormDataList.Where(it => it["id"].Equals(items[item.Key])).FirstOrDefault();
|
|
if (relationFormRealData != null && relationFormRealData.Count > 0)
|
|
{
|
|
items[model.__vModel__ + "_id"] = relationFormRealData["id"];
|
|
items[item.Key] = relationFormRealData.ContainsKey(model.relationField) ? relationFormRealData[model.relationField] : string.Empty;
|
|
|
|
// 关联表单属性
|
|
if (model.relational.IsNotEmptyOrNull())
|
|
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = relationFormRealData[fItem];
|
|
}
|
|
else
|
|
{
|
|
items[item.Key] = string.Empty;
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 子表
|
|
if (item.Value != null && item.Key.ToLower().Contains("tablefield") && (item.Value is List<Dictionary<string, object>> || item.Value.GetType().Name.Equals("JArray")))
|
|
{
|
|
var ctList = item.Value.ToObject<List<Dictionary<string, object>>>(CommonConst.options);
|
|
var ctVModels = new Dictionary<string, object>();
|
|
foreach (var ctItem in vModels.Where(x => x.Key.Contains(item.Key)).ToList())
|
|
{
|
|
ctVModels.Add(ctItem.Key.Split("-").LastOrDefault(), ctItem.Value);
|
|
var ctFields = fields.Find(x => x.__vModel__.Equals(ctItem.Key.Split("-").FirstOrDefault())).__config__.children;
|
|
if (ctList.Any()) items[item.Key] = await GetParsDataByList(ctFields, ctList, ctVModels, tenantId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return oldDatas;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取解析数据缓存.
|
|
/// </summary>
|
|
/// <param name="vModels"></param>
|
|
/// <param name="tenantId"></param>
|
|
/// <returns></returns>
|
|
private async Task<Dictionary<string, object>> GetCaCheData(Dictionary<string, object> vModels, string tenantId)
|
|
{
|
|
var res = new Dictionary<string, object>();
|
|
|
|
if (vModels.Where(x => x.Value.Equals(JnpfKeyConst.USERSSELECT)).Any())
|
|
{
|
|
string? userCacheKey = CommonConst.CodeGenDynamic + "_usersSelect_" + tenantId;
|
|
if (_cacheManager.Exists(userCacheKey))
|
|
{
|
|
res.Add(userCacheKey, _cacheManager.Get(userCacheKey).ToObject<Dictionary<string, object>>());
|
|
}
|
|
else
|
|
{
|
|
var addList = new Dictionary<string, string>();
|
|
(await _repository.AsSugarClient().Queryable<UserEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.RealName, x.Account }).ToListAsync()).ForEach(item => addList.Add(item.Id + "--user", item.RealName + "/" + item.Account));
|
|
(await _repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
|
|
{
|
|
addList.Add(item.Id + "--company", item.FullName);
|
|
addList.Add(item.Id + "--department", item.FullName);
|
|
});
|
|
(await _repository.AsSugarClient().Queryable<RoleEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item => addList.Add(item.Id + "--role", item.FullName));
|
|
(await _repository.AsSugarClient().Queryable<PositionEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item => addList.Add(item.Id + "--position", item.FullName));
|
|
(await _repository.AsSugarClient().Queryable<GroupEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item => addList.Add(item.Id + "--group", item.FullName));
|
|
|
|
// 缓存5分钟
|
|
_cacheManager.Set(userCacheKey, addList, TimeSpan.FromMinutes(5));
|
|
res.Add(userCacheKey, addList);
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户组件查询条件组装.
|
|
/// </summary>
|
|
/// <param name="key">字段名.</param>
|
|
/// <param name="values">查询值.</param>
|
|
/// <returns></returns>
|
|
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, string values)
|
|
{
|
|
if (values.IsNotEmptyOrNull()) return GetUsersSelectQueryWhere(key, new List<string>() { values });
|
|
else return new List<IConditionalModel>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户组件查询条件组装.
|
|
/// </summary>
|
|
/// <param name="key">字段名.</param>
|
|
/// <param name="values">查询值.</param>
|
|
/// <returns></returns>
|
|
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, string values, bool isMultiple = false)
|
|
{
|
|
return GetUsersSelectQueryWhere(key, values);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户组件查询条件组装.
|
|
/// </summary>
|
|
/// <param name="key">字段名.</param>
|
|
/// <param name="values">查询值.</param>
|
|
/// <returns></returns>
|
|
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, List<string> values)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
if (values.IsNullOrEmpty() || !values.Any()) return conModels;
|
|
var userIds = values.Select(x => x.Replace("--user", string.Empty)).ToList();
|
|
var rIdList = _repository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => userIds.Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList();
|
|
var objIdList = values;
|
|
rIdList.ForEach(x =>
|
|
{
|
|
if (x.ObjectType.Equals("Organize"))
|
|
{
|
|
objIdList.Add(x.ObjectId + "--company");
|
|
objIdList.Add(x.ObjectId + "--department");
|
|
}
|
|
else
|
|
{
|
|
objIdList.Add(x.ObjectId + "--" + x.ObjectType.ToLower());
|
|
}
|
|
});
|
|
|
|
var whereList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
for (var i = 0; i < objIdList.Count(); i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
|
{
|
|
FieldName = key,
|
|
ConditionalType = ConditionalType.Like,
|
|
FieldValue = objIdList[i]
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
|
|
{
|
|
FieldName = key,
|
|
ConditionalType = ConditionalType.Like,
|
|
FieldValue = objIdList[i]
|
|
}));
|
|
}
|
|
}
|
|
|
|
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
|
{
|
|
FieldName = key,
|
|
ConditionalType = ConditionalType.IsNot,
|
|
FieldValue = null
|
|
}));
|
|
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
|
{
|
|
FieldName = key,
|
|
ConditionalType = ConditionalType.IsNot,
|
|
FieldValue = string.Empty
|
|
}));
|
|
conModels.Add(new ConditionalCollections() { ConditionalList = whereList });
|
|
return conModels;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成查询多选条件.
|
|
/// </summary>
|
|
/// <param name="key">数据库列名称.</param>
|
|
/// <param name="list"></param>
|
|
/// <returns></returns>
|
|
public List<IConditionalModel> GenerateMultipleSelectionCriteriaForQuerying(string key, List<string>? list)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
var addItems = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
for (int i = 0; i < list?.Count; i++)
|
|
{
|
|
var add = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel
|
|
{
|
|
FieldName = key,
|
|
ConditionalType = ConditionalType.Like,
|
|
FieldValue = list[i]
|
|
});
|
|
addItems.Add(add);
|
|
}
|
|
if (addItems?.Count > 0)
|
|
conModels.Add(new ConditionalCollections() { ConditionalList = addItems });
|
|
return conModels;
|
|
}
|
|
|
|
#region 私有方法
|
|
|
|
/// <summary>
|
|
/// 获取动态无限级数据.
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <param name="props"></param>
|
|
/// <returns></returns>
|
|
private List<Dictionary<string, string>> GetDynamicInfiniteData(string data, PropsBeanModel props)
|
|
{
|
|
List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
|
|
string? value = props.value;
|
|
string? label = props.label;
|
|
string? children = props.children;
|
|
foreach (JToken? info in JToken.Parse(data))
|
|
{
|
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
dic[info.Value<string>(value)] = info.Value<string>(label);
|
|
list.Add(dic);
|
|
if (info.Value<object>(children) != null && info.Value<object>(children).ToString() != string.Empty)
|
|
list.AddRange(GetDynamicInfiniteData(info.Value<object>(children).ToString(), props));
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据不同规则请求接口(预览).
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
private async Task<JObject> GetApiDataByTypePreview(DataInterfaceEntity entity)
|
|
{
|
|
var result = new JObject();
|
|
var parameters = entity.RequestParameters.ToObject<List<DataInterfaceReqParameter>>();
|
|
var parametersHerader = entity.RequestHeaders.ToObject<List<DataInterfaceReqParameter>>();
|
|
var dic = new Dictionary<string, object>();
|
|
var dicHerader = new Dictionary<string, object>();
|
|
dicHerader.Add("JNPF_API", true);
|
|
if (_userManager.ToKen != null && !_userManager.ToKen.Contains("::"))
|
|
dicHerader.Add("Authorization", _userManager.ToKen);
|
|
foreach (var key in parameters)
|
|
{
|
|
dic.Add(key.field, key.defaultValue);
|
|
}
|
|
|
|
foreach (var key in parametersHerader)
|
|
{
|
|
dicHerader[key.field] = key.defaultValue;
|
|
}
|
|
|
|
switch (entity.RequestMethod)
|
|
{
|
|
case "6":
|
|
result = (await entity.Path.SetHeaders(dicHerader).SetQueries(dic).GetAsStringAsync()).ToObject<JObject>();
|
|
break;
|
|
case "7":
|
|
result = (await entity.Path.SetHeaders(dicHerader).SetBody(dic).PostAsStringAsync()).ToObject<JObject>();
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
} |