简化WEB库

This commit is contained in:
2025-09-23 10:38:35 +08:00
parent 9a89a138dd
commit c6037c51ed
17 changed files with 165 additions and 780 deletions

View File

@@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace .Utility.ResponseModels
{
/// <summary>
/// 通用AJAX请求响应数据格式模型。
/// </summary>
public class AjaxResult
{
public AjaxResult(ResultType state, string message, object data = null)
{
this.state = state;
this.message = message;
this.data = data;
}
/// <summary>
/// 结果类型。
/// </summary>
public ResultType state { get; set; }
/// <summary>
/// 消息内容。
/// </summary>
public string message { get; set; }
/// <summary>
/// 返回数据。
/// </summary>
public object data { get; set; }
}
/// <summary>
/// 结果类型枚举。
/// </summary>
public enum ResultType
{
/// <summary>
/// 警告。
/// </summary>
Warning = 0,
/// <summary>
/// 成功。
/// </summary>
Success = 1,
/// <summary>
/// 异常。
/// </summary>
Error = 2,
/// <summary>
/// 消息。
/// </summary>
Info = 6
}
}

View File

@@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace .Utility.ResponseModels
{
/// <summary>
/// 菜单视图模型。
/// </summary>
public class LayNavbar
{
/// <summary>
/// 标题
/// </summary>
public string title { get; set; }
/// <summary>
/// 图标
/// </summary>
public string icon { get; set; }
/// <summary>
/// 是否展开
/// </summary>
public bool spread { get; set; }
/// <summary>
/// 子级菜单集合
/// </summary>
public List<LayChildNavbar> children { get; set; }
}
/// <summary>
/// 子级菜单模型。
/// </summary>
public class LayChildNavbar
{
/// <summary>
/// 标题
/// </summary>
public string title { get; set; }
/// <summary>
/// 图标
/// </summary>
public string icon { get; set; }
/// <summary>
/// 链接
/// </summary>
public string href { get; set; }
}
}

View File

@@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace .Utility.ResponseModels
{
/// <summary>
/// Laytpl + Laypage 分页模型。
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public class LayPadding<TEntity> where TEntity : class
{
public int code { get; set; }
/// <summary>
/// 获取结果。
/// </summary>
public bool result { get; set; }
/// <summary>
/// 备注信息。
/// </summary>
public string msg { get; set; }
/// <summary>
/// 数据列表。
/// </summary>
public List<TEntity> list { get; set; }
public string backgroundImage { get; set; }
/// <summary>
/// 记录条数。
/// </summary>
public long count { get; set; }
}
}

View File

@@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace .Utility.ResponseModels
{
public class LayPaddingDataTable
{
public int code { get; set; }
/// <summary>
/// 获取结果。
/// </summary>
public bool result { get; set; }
/// <summary>
/// 备注信息。
/// </summary>
public string msg { get; set; }
/// <summary>
/// 数据列表。
/// </summary>
public DataTable list { get; set; }
public string backgroundImage { get; set; }
/// <summary>
/// 记录条数。
/// </summary>
public long count { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace .Utility.ResponseModels
{
public class RetStr
{
public string Data { get; set; }
}
}

View File

@@ -1,55 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Newtonsoft.Json;
namespace .Utility.ResponseModels
{
/// <summary>
/// Select2树形下拉列表模型。
/// </summary>
public class TreeSelect
{
public string id { get; set; }
public string text { get; set; }
public string parentId { get; set; }
public object data { get; set; }
}
public static class TreeSelectHelper
{
public static string ToTreeSelectJson(this List<TreeSelect> data)
{
StringBuilder sb = new StringBuilder();
sb.Append("[");
sb.Append(ToTreeSelectJson(data, "0", ""));
sb.Append("]");
return sb.ToString();
}
private static string ToTreeSelectJson(List<TreeSelect> data, string parentId, string blank)
{
StringBuilder sb = new StringBuilder();
var childList = data.FindAll(t => t.parentId == parentId);
var tabline = "";
if (parentId != "0")
{
tabline = "  ";
}
if (childList.Count > 0)
{
tabline = tabline + blank;
}
foreach (TreeSelect entity in childList)
{
entity.text = tabline + entity.text;
string strJson = JsonConvert.SerializeObject(entity);
sb.Append(strJson);
sb.Append(ToTreeSelectJson(data, entity.id, tabline));
}
return sb.ToString().Replace("}{", "},{");
}
}
}

View File

@@ -1,34 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace .Utility.ResponseModels
{
/// <summary>
/// zTree单层节点数据模型。
/// </summary>
public class ZTreeNode
{
/// <summary>
/// 节点ID。
/// </summary>
public string id { get; set; }
/// <summary>
/// 父节点ID。
/// </summary>
public string pId { get; set; }
/// <summary>
/// 节点名称。
/// </summary>
public string name { get; set; }
/// <summary>
/// 是否展开。
/// </summary>
public bool open { get; set; }
/// <summary>
/// 是否选中。
/// </summary>
public bool @checked { get; set; }
}
}

View File

@@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace .Utility.Web
{
public class WithExtensionMultipartFormDataStreamProvider : MultipartFormDataStreamProvider
{
public string guid { get; set; }
public string OriginalName { get; set; }
public string Ext { get; set; }
public WithExtensionMultipartFormDataStreamProvider(string rootPath, string guidStr) : base(rootPath)
{
guid = guidStr;
}
public override string GetLocalFileName(System.Net.Http.Headers.HttpContentHeaders headers)
{
OriginalName = !string.IsNullOrWhiteSpace(headers.ContentDisposition.FileName) ? GetValidFileName(headers.ContentDisposition.FileName) : "";
Ext = !string.IsNullOrWhiteSpace(OriginalName) ? Path.GetExtension(GetValidFileName(OriginalName)) : "";
return guid + Ext;
}
private string GetValidFileName(string filePath)
{
char[] invalids = System.IO.Path.GetInvalidFileNameChars();
return string.Join("_", filePath.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
}
}
}