v3.4.6
This commit is contained in:
@@ -54,7 +54,7 @@ public static class CodeGenExportDataHelper
|
||||
|
||||
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
|
||||
|
||||
if (len > 0)
|
||||
if (len != null && len > 0)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
|
||||
@@ -160,6 +160,79 @@ public static class CodeGenHelper
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表生成树形表格.
|
||||
/// </summary>
|
||||
/// <param name="realList">数据列表.</param>
|
||||
/// <param name="parentField">树形父级字段.</param>
|
||||
/// <param name="treeShowField">树形显示字段.</param>
|
||||
/// <returns></returns>
|
||||
public static List<Dictionary<string, object>> GetTreeList(List<Dictionary<string, object>> realList, string parentField, string treeShowField)
|
||||
{
|
||||
var res = new List<Dictionary<string, object>>();
|
||||
if (realList.Any())
|
||||
{
|
||||
var parentFieldId = SnowflakeIdHelper.NextId();
|
||||
|
||||
foreach (var item in realList)
|
||||
{
|
||||
if (realList.Any(x => x["id"].Equals(item[parentField]))) item[parentFieldId] = item[parentField];
|
||||
else item[parentFieldId] = null;
|
||||
item[parentField] = realList.Find(x => x["id"] == item["id"])[treeShowField];
|
||||
}
|
||||
var parentFieldRep = parentField.Substring(0, parentField.Length - 4);
|
||||
for (int i = 0; i < realList.Count; i++)
|
||||
{
|
||||
if (realList[i][parentFieldId].IsNullOrEmpty())
|
||||
{
|
||||
if (realList[i][parentFieldRep] == null) realList[i][parentFieldRep] = realList[i][treeShowField];
|
||||
var childList = realList.Where(x => x[parentFieldId] != null && x[parentFieldId].Equals(realList[i]["id"])).ToList();
|
||||
if (childList.Any()) GetTreeList(realList, realList[i], parentFieldId);
|
||||
res.Add(realList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void GetTreeList(List<Dictionary<string, object>> allList, Dictionary<string, object> currentItem, string pId)
|
||||
{
|
||||
var childList = allList.Where(x => x[pId] != null && x[pId].Equals(currentItem["id"])).ToList();
|
||||
if (childList.Any()) childList.ForEach(x => GetTreeList(allList, x, pId));
|
||||
if (childList.Any())
|
||||
{
|
||||
var item = allList.Find(x => x["id"].Equals(currentItem["id"]));
|
||||
item["children"] = childList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据集合捞取所有子集id.
|
||||
/// </summary>
|
||||
/// <param name="allList">key : 主键Id , value : 父亲Id.</param>
|
||||
/// <param name="currentId">当前id.</param>
|
||||
/// <param name="resList">res.</param>
|
||||
public static List<string> GetChildIdList(Dictionary<string, string> allList, string currentId, List<string> resList)
|
||||
{
|
||||
if (resList == null) resList = new List<string>() { currentId };
|
||||
else resList.Add(currentId);
|
||||
if (allList.Any())
|
||||
{
|
||||
var cItemList = allList.Where(x => x.Value.IsNotEmptyOrNull() && x.Value.Equals(currentId)).ToList();
|
||||
if (cItemList.Any())
|
||||
{
|
||||
foreach (var item in cItemList)
|
||||
{
|
||||
var cIdList = GetChildIdList(allList, item.Key, resList);
|
||||
resList.Add(item.Key);
|
||||
if (cIdList.Any()) resList.AddRange(cIdList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取排序真实字段.
|
||||
/// </summary>
|
||||
@@ -190,7 +263,7 @@ public static class CodeGenHelper
|
||||
field = entityInfo.Columns.Find(it => it.PropertyName.Equals(sort.ToUpperCase()))?.DbColumnName;
|
||||
break;
|
||||
}
|
||||
return string.IsNullOrEmpty(field) ? "" : field;
|
||||
return string.IsNullOrEmpty(field) ? null : field;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using JNPF.Common.Helper;
|
||||
using JNPF.Common.Models.NPOI;
|
||||
using JNPF.DependencyInjection;
|
||||
using NPOI.HPSF;
|
||||
@@ -9,8 +8,6 @@ using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.SS.Util;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using Spire.Doc;
|
||||
using static Microsoft.AspNetCore.Razor.Language.TagHelperMetadata;
|
||||
|
||||
namespace JNPF.Common.Security;
|
||||
|
||||
|
||||
@@ -49,6 +49,17 @@ public static class JsonHelper
|
||||
return _jsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JSON 字符串转 Object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">动态类型.</typeparam>
|
||||
/// <param name="json">对象.</param>
|
||||
/// <returns></returns>
|
||||
public static T ToObjectOld<T>(this string json)
|
||||
{
|
||||
return _ = JsonConvert.DeserializeObject<T>(json) ?? default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JSON 字符串转 Object.
|
||||
/// </summary>
|
||||
|
||||
@@ -28,7 +28,9 @@ public static class NetHelper
|
||||
string result = string.Empty;
|
||||
if (App.HttpContext != null)
|
||||
result = GetWebClientIp();
|
||||
return result.Equals("::1") ? "127.0.0.1" : result;
|
||||
result = result.Equals("::1") ? "127.0.0.1" : result;
|
||||
result = result.Replace(":", string.Empty).Replace("ffff", string.Empty);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -4,11 +4,11 @@ namespace JNPF.Common.Security;
|
||||
|
||||
public static class XmlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 反序列化
|
||||
/// </summary>
|
||||
/// <param name="type">类型</param>
|
||||
/// <param name="xml">XML字符串</param>
|
||||
/// <summary>
|
||||
/// 反序列化.
|
||||
/// </summary>
|
||||
/// <param name="type">类型.</param>
|
||||
/// <param name="xml">XML字符串.</param>
|
||||
/// <returns></returns>
|
||||
public static object Deserialize(Type type, string xml)
|
||||
{
|
||||
@@ -19,13 +19,12 @@ public static class XmlHelper
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="xml"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化.
|
||||
/// </summary>
|
||||
/// <param name="type">类型.</param>
|
||||
/// <param name="stream">XML流.</param>
|
||||
/// <returns></returns>
|
||||
public static object Deserialize(Type type, Stream stream)
|
||||
{
|
||||
XmlSerializer xmldes = new XmlSerializer(type);
|
||||
|
||||
Reference in New Issue
Block a user