1.去掉编译条件

2.重写业务导入功能
This commit is contained in:
FanLian
2023-08-09 17:49:27 +08:00
parent 7913642d3d
commit 1bbb30f135
7 changed files with 127 additions and 89 deletions

View File

@@ -9,6 +9,7 @@ using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Extension;
using JNPF.DependencyInjection;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Entitys.Dto.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Http;
@@ -28,5 +29,6 @@ namespace JNPF.VisualDev
public Func<VisualDevModelDataBatchDelInput, Task>? DeleteRangeAsync { get; set; } = null;
public Func<VisualDevModelListQueryInput, Task<dynamic>>? ExportAsync { get; set; } = null;
public Func<IFormFile, Task<dynamic>>? ImportAsync { get; set; } = null;
}
public Func<VisualDevImportDataInput, Task<dynamic>>? ImportDataAsync { get; set; } = null;
}
}

View File

@@ -204,7 +204,7 @@ namespace JNPF.VisualDev
[HttpGet("{modelId}/{id}")]
public async Task<dynamic> GetInfo(string id, string modelId)
{
// modified by PhilPan 2023-04-12 重写接口
// modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.GetAsync != null)
{
@@ -216,8 +216,8 @@ namespace JNPF.VisualDev
// 有表
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
// modified by PhilPan 2023-04-12 返回值不序列化成字符串
return new { id = id, data = (await _runService.GetHaveTableInfo(id, templateEntity)) };
else
return new { id = id, data = (await _runService.GetHaveTableInfo(id, templateEntity)) };
else
return null;
}
@@ -230,7 +230,7 @@ namespace JNPF.VisualDev
[HttpGet("{modelId}/{id}/DataChange")]
public async Task<dynamic> GetDetails(string id, string modelId)
{
//modified by PhilPan 2023-04-12 重写接口
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.GetDetailsAsync != null)
{
@@ -306,7 +306,7 @@ namespace JNPF.VisualDev
[HttpPost("{modelId}/List")]
public async Task<dynamic> List(string modelId, [FromBody] VisualDevModelListQueryInput input)
{
//modified by PhilPan 2023-04-12 重写接口
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.GetListAsync != null)
{
@@ -342,7 +342,7 @@ namespace JNPF.VisualDev
[HttpPost("{modelId}")]
public async Task Create(string modelId, [FromBody] VisualDevModelDataCrInput visualdevModelDataCrForm)
{
//modified by PhilPan 2023-04-12 重写接口
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.CreateAsync != null)
{
@@ -365,7 +365,7 @@ namespace JNPF.VisualDev
[HttpPut("{modelId}/{id}")]
public async Task Update(string modelId, string id, [FromBody] VisualDevModelDataUpInput visualdevModelDataUpForm)
{
//modified by PhilPan 2023-04-12 重写接口
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.UpdateAsync != null)
{
@@ -387,7 +387,7 @@ namespace JNPF.VisualDev
[HttpDelete("{modelId}/{id}")]
public async Task Delete(string id, string modelId)
{
//modified by PhilPan 2023-04-12 重写接口
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.DeleteAsync != null)
{
@@ -409,7 +409,7 @@ namespace JNPF.VisualDev
[HttpPost("batchDelete/{modelId}")]
public async Task BatchDelete(string modelId, [FromBody] VisualDevModelDataBatchDelInput input)
{
//modified by PhilPan 2023-04-12 重写接口
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.DeleteRangeAsync != null)
{
@@ -749,7 +749,7 @@ namespace JNPF.VisualDev
resData.ForEach(items =>
{
foreach(var item in items)
foreach (var item in items)
{
var vmodel = tInfo.AllFieldsModel.FirstOrDefault(x => x.__vModel__.Equals(item.Key));
if (vmodel != null && vmodel.__config__.jnpfKey.Equals(JnpfKeyConst.DATE) && item.Value.IsNotEmptyOrNull()) items[item.Key] = item.Value + " ";
@@ -796,18 +796,27 @@ namespace JNPF.VisualDev
[UnitOfWork]
public async Task<dynamic> ImportData(string modelId, [FromBody] VisualDevImportDataInput list)
{
var tInfo = await GetUploaderTemplateInfoAsync(modelId);
object[]? res = await ImportMenuData(tInfo, list.list, tInfo.visualDevEntity);
var addlist = res.First() as List<Dictionary<string, object>>;
var errorlist = res.Last() as List<Dictionary<string, object>>;
var result = new VisualDevImportDataOutput()
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.CreateAsync != null)
{
snum = addlist.Count,
fnum = errorlist.Count,
failResult = errorlist,
resultType = errorlist.Count < 1 ? 0 : 1
};
await overideSvc.OverideFuncs.ImportDataAsync(list);
}
else
{
var tInfo = await GetUploaderTemplateInfoAsync(modelId);
object[]? res = await ImportMenuData(tInfo, list.list, tInfo.visualDevEntity);
var addlist = res.First() as List<Dictionary<string, object>>;
var errorlist = res.Last() as List<Dictionary<string, object>>;
result = new VisualDevImportDataOutput()
{
snum = addlist.Count,
fnum = errorlist.Count,
failResult = errorlist,
resultType = errorlist.Count < 1 ? 0 : 1
};
}
return result;
}
@@ -1204,7 +1213,7 @@ namespace JNPF.VisualDev
for (var i = 1; i < vlist.Count; i++)
{
var errorTxt = tInfo.AllFieldsModel.Find(x => x.__vModel__.Equals(uniqueKey)).__config__.label + ": 值不能重复";
if (!ctItemErrors.Any(x=>x.Equals(errorTxt))) ctItemErrors.Add(errorTxt);
if (!ctItemErrors.Any(x => x.Equals(errorTxt))) ctItemErrors.Add(errorTxt);
}
}
}
@@ -1524,7 +1533,7 @@ namespace JNPF.VisualDev
foreach (var it in dictionaryDataList)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
if(propsValue.Equals("id")) dictionary.Add(it.Id, it.FullName);
if (propsValue.Equals("id")) dictionary.Add(it.Id, it.FullName);
if (propsValue.Equals("enCode")) dictionary.Add(it.EnCode, it.FullName);
addItem.Add(dictionary);
}
@@ -1735,7 +1744,7 @@ namespace JNPF.VisualDev
Dictionary<string, string> dic = new Dictionary<string, string>();
dic[data.Value<string>(propsValue)] = data.Value<string>(propsLabel);
list.Add(dic);
if (children!=null && data.Value<object>(children) != null && data.Value<object>(children).ToString().IsNotEmptyOrNull())
if (children != null && data.Value<object>(children) != null && data.Value<object>(children).ToString().IsNotEmptyOrNull())
list.AddRange(GetDynamicInfiniteData(data.Value<object>(children).ToString(), item.props.props));
}
}
@@ -2661,7 +2670,7 @@ namespace JNPF.VisualDev
}
}
if(newDataItems.ContainsKey(errorKey))
if (newDataItems.ContainsKey(errorKey))
{
if (dataItems.ContainsKey(errorKey)) dataItems[errorKey] = newDataItems[errorKey].ToString();
else dataItems.Add(errorKey, newDataItems[errorKey]);
@@ -2955,7 +2964,7 @@ namespace JNPF.VisualDev
/// <returns></returns>
private VisualDevModelDataConfigOutput GetVisualDevModelDataConfig(VisualDevEntity config)
{
if(config.WebType.Equals(4)) return config.Adapt<VisualDevModelDataConfigOutput>();
if (config.WebType.Equals(4)) return config.Adapt<VisualDevModelDataConfigOutput>();
var tInfo = new TemplateParsingBase(config);
if (tInfo.AllFieldsModel.Any(x => (x.__config__.defaultCurrent) && (x.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) || x.__config__.jnpfKey.Equals(JnpfKeyConst.DEPSELECT))))
{