From f1b2338a3b846e219a99638dce82055e72b31d1a Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期二, 08 十月 2024 16:30:47 +0800 Subject: [PATCH] 清理项目 --- /dev/null | 49 ------------------------------------------------- 1 files changed, 0 insertions(+), 49 deletions(-) diff --git a/Core/Class1.cs b/Core/Class1.cs deleted file mode 100644 index 033b06b..0000000 --- a/Core/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -锘縩amespace Core -{ - public class Class1 - { - - } -} diff --git a/Core/Core.csproj b/Core/Core.csproj deleted file mode 100644 index b49e18d..0000000 --- a/Core/Core.csproj +++ /dev/null @@ -1,13 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <ImplicitUsings>enable</ImplicitUsings> - <Nullable>enable</Nullable> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="SqlSugarCore" Version="5.1.4.146" /> - </ItemGroup> - -</Project> diff --git a/Core/DataBase/SqlSugarExtention.cs b/Core/DataBase/SqlSugarExtention.cs deleted file mode 100644 index 3227325..0000000 --- a/Core/DataBase/SqlSugarExtention.cs +++ /dev/null @@ -1,236 +0,0 @@ -锘縰sing SqlSugar; -using Web.Core.Entities.Response; -using Web.Core.Exceptions; - -namespace Web.Core.DataBase -{ - public static class SqlSugarExtention - { - #region 鍚屾 - - /// <summary> - /// - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="query"></param> - /// <param name="page"></param> - /// <returns></returns> - /// <exception cref="BizException"></exception> - public static PageListModel<T> GetPageResult<T>(this ISugarQueryable<T> query, PageInput page) where T : class, new() - { - int count = 0; - - #region 鑷畾涔夋帓搴� - - string orderSql = string.Empty; - //璁剧疆鎺掑簭鏂瑰紡 - if (!string.IsNullOrWhiteSpace(page.SortFileId)) - { - query.QueryBuilder.OrderByValue = null;// 绉婚櫎鑷畾涔夋帓搴� - string[] fieldArr = page.SortFileId.ToLower().Split(','); - string[] typeArr; - if (string.IsNullOrWhiteSpace(page.SortType)) - { - typeArr = new string[fieldArr.Length]; - for (int i = 0; i < typeArr.Length; i++) - { - typeArr[i] = "asc"; - } - } - else - { - typeArr = page.SortType.ToLower().Split(","); - } - - if (fieldArr.Length > 0 && fieldArr.Length <= 0) - { - foreach (var item in fieldArr) - { - orderSql += item + "asc,"; - } - } - else - { - if (fieldArr.Length > 0 && fieldArr.Length != typeArr.Length) - { - throw new BizException("鎺掑簭鍙傛暟寮傚父"); - } - for (int i = 0; i < fieldArr.Length; i++) - { - orderSql += fieldArr[i] + $"{typeArr[i]},"; - } - } - } - - #endregion 鑷畾涔夋帓搴� - - #region 鏈夋帓搴� - - if (!string.IsNullOrWhiteSpace(orderSql)) - { - orderSql = orderSql.Trim(','); - string sqlTemplate = "SELECT * FROM ({0}) ORDER BY {1}"; - string sql = query.ToSql().Key; - var paramLst = query.ToSql().Value; - foreach (var item in paramLst) - { - if (item.Value == null) - { - continue; - } - if (item.DbType.ToString() == "DateTime") - { - DateTime dtime = (DateTime)item.Value; - sql = sql.Replace(item.ParameterName, "'" + dtime.ToString("yyyy-MM-dd") + "'"); - continue; - } - sql = sql.Replace(item.ParameterName, "'" + item.Value?.ToString() + "'"); - } - - var orderLst = query.Context.SqlQueryable<T>(string.Format(sqlTemplate, sql, orderSql)).ToPageList(page.PageIndex, page.PageRows, ref count); - return new PageListModel<T>() - { - PageList = orderLst, - Total = count - }; - } - - #endregion 鏈夋帓搴� - - List<T> lst = query.ToPageList(page.PageIndex, page.PageRows, ref count); - return new PageListModel<T>() - { - PageList = lst, - Total = count - }; - } - - #endregion 鍚屾 - - #region 寮傛 - - /// <summary> - /// - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="query"></param> - /// <param name="page"></param> - /// <returns></returns> - /// <exception cref="BizException"></exception> - public static async Task<PageListModel<T>> GetPageResultAsync<T>(this ISugarQueryable<T> query, PageInput page) where T : class, new() - { - RefAsync<int> count = 0; - - #region 鑷畾涔夋帓搴� - - string orderSql = string.Empty; - if (!string.IsNullOrWhiteSpace(page.SortFileId)) - { - query.QueryBuilder.OrderByValue = null;// 绉婚櫎榛樿鎺掑簭 - string[] fieldArr = page.SortFileId.ToLower().Split(','); - string[] typeArr; - if (string.IsNullOrWhiteSpace(page.SortType)) - { - typeArr = new string[fieldArr.Length]; - for (int i = 0; i < fieldArr.Length; i++) - { - typeArr[i] = "asc"; - } - } - else - { - typeArr = page.SortType.ToLower().Split(","); - } - // 灞炴�ф牎楠岋紝淇濊瘉杩斿洖瀹炰綋瀛樺湪褰撳墠瀛楁 - List<string> fileds = typeof(T).GetProperties().Select(i => i.Name.ToLower()).ToList(); - if (fieldArr.Length > 0 && typeArr.Length <= 0) - { - foreach (var item in fieldArr) - { - if (fileds.Contains(item)) - { - orderSql += item + "asc,"; - } - } - } - else - { - if (fieldArr.Length > 0 && fieldArr.Length != typeArr.Length) - { - throw new BizException("鎺掑簭鍙傛暟寮傚父"); - } - for (int i = 0; i < fieldArr.Length; i++) - { - if (fileds.Contains(fieldArr[i])) - { - orderSql += fieldArr[i] + $"{typeArr[i]}"; - } - } - } - } - - #endregion 鑷畾涔夋帓搴� - - if (!string.IsNullOrWhiteSpace(orderSql)) - { - orderSql = orderSql.Trim(','); - string sqlTemplate = "SELECT * FROM ({0}) ORDER BY {1}"; - string sql = query.ToSql().Key; - var parmLst = query.ToSql().Value; - foreach (var item in parmLst) - { - if (item.Value == null) - { - continue; - } - if (item.DbType == System.Data.DbType.DateTime) - { - DateTime dtime = (DateTime)item.Value; - sql = sql.Replace(item.ParameterName, "'" + dtime.ToString("yyyy-MM-dd") + "'"); - continue; - } - else if (item.DbType == System.Data.DbType.String) - { - if (item.Value.ToString().Contains("'")) - { - throw new BizException($"鍙傛暟鍊笺�恵item.Value}銆戝惈鏈夐潪娉曞瓧绗︼紝鏃犳硶鏌ヨ锛�"); - } - } - sql = sql.Replace(item.ParameterName, "'" + item.Value?.ToString() + "'"); - } - - var orderLst = await query.Context.SqlQueryable<T>(string.Format(sqlTemplate, sql, orderSql)).ToPageListAsync(page.PageIndex, page.PageRows, count); - return new PageListModel<T>() - { - PageList = orderLst, - Total = count - }; - } - - List<T> lst = await query.ToPageListAsync(page.PageIndex, page.PageRows, count); - return new PageListModel<T>() - { - PageList = lst, - Total = count - }; - } - - #endregion 寮傛 - - #region 鑱斿悎鏌ヨ - - /// <summary> - /// - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="queryable"></param> - /// <param name="unionQueryables"></param> - /// <returns></returns> - public static ISugarQueryable<T> Union<T>(this ISugarQueryable<T> queryable, params ISugarQueryable<T>[] unionQueryables) - { - return queryable.Union(unionQueryables); - } - - #endregion 鑱斿悎鏌ヨ - } -} \ No newline at end of file diff --git a/Core/Entities/Response/PageInput.T.cs b/Core/Entities/Response/PageInput.T.cs deleted file mode 100644 index e8d9eeb..0000000 --- a/Core/Entities/Response/PageInput.T.cs +++ /dev/null @@ -1,14 +0,0 @@ -锘縩amespace Web.Core.Entities.Response -{ - /// <summary> - /// - /// </summary> - /// <typeparam name="T"></typeparam> - public class PageInput<T> : PageInput where T : new() - { - /// <summary> - ///鍙傛暟鍒悕/涓氬姟缁撴瀯浣� - /// </summary> - public T Search { get; set; } = new T(); - } -} \ No newline at end of file diff --git a/Core/Entities/Response/PageInput.cs b/Core/Entities/Response/PageInput.cs deleted file mode 100644 index 96f9b75..0000000 --- a/Core/Entities/Response/PageInput.cs +++ /dev/null @@ -1,37 +0,0 @@ -锘縰sing System.ComponentModel; - -namespace Web.Core.Entities.Response -{ - public class PageInput - { - /// <summary> - /// - /// </summary> - [Description("褰撳墠椤电爜")] - public int PageIndex { get; set; } = 1; - - /// <summary> - /// - /// </summary> - [Description("姣忛〉琛屾暟")] - public int PageRows { get; set; } = int.MaxValue; - - /// <summary> - /// - /// </summary> - [Description("鎺掑簭鍒�")] - public string? SortFileId { get; set; } - - /// <summary> - /// - /// </summary> - [Description("鎺掑簭绫诲瀷")] - public string? SortType { get; set; } - - /// <summary> - /// - /// </summary> - [Description("鏈烘瀯缂栫爜")] - public List<string>? OrgCode { get; set; } - } -} \ No newline at end of file diff --git a/Core/Entities/Response/PageListModel.cs b/Core/Entities/Response/PageListModel.cs deleted file mode 100644 index 6bdf86b..0000000 --- a/Core/Entities/Response/PageListModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -锘縩amespace Web.Core.Entities.Response -{ - public class PageListModel<T> - { - public static PageListModel<T> Default - { - get - { - return new PageListModel<T>() - { - Total = 0, - PageList = Enumerable.Empty<T>() - }; - } - } - - /// <summary> - /// 鎬昏褰曟暟 - /// </summary> - public int Total { get; set; } - - /// <summary> - /// 鏁版嵁瀹炰綋 - /// </summary> - public IEnumerable<T> PageList { get; set; } - } -} \ No newline at end of file diff --git a/Core/Exceptions/BizException.cs b/Core/Exceptions/BizException.cs deleted file mode 100644 index b465ec6..0000000 --- a/Core/Exceptions/BizException.cs +++ /dev/null @@ -1,49 +0,0 @@ -锘縩amespace Web.Core.Exceptions -{ - public class BizException : Exception - { - /// <summary> - /// 閿欒鐮� - /// </summary> - public int ErrorCode { get; set; } - - /// <summary> - /// - /// </summary> - public object BizData { get; set; } - - public BizException() - { - } - - /// <summary> - /// 鏋勯�犲嚱鏁� - /// </summary> - /// <param name="message"></param> - public BizException(string message) : base(message) - { - } - - /// <summary> - /// 鏋勯�犲嚱鏁� - /// </summary> - /// <param name="message">閿欒淇℃伅</param> - /// <param name="errorCode">閿欒浠g爜</param> - public BizException(string message, int errorCode) : base(message) - { - ErrorCode = errorCode; - } - - /// <summary> - /// - /// </summary> - /// <param name="message"></param> - /// <param name="errorCode"></param> - /// <param name="data"></param> - public BizException(string message, int errorCode, object data) : base(message) - { - ErrorCode = errorCode; - BizData = data; - } - } -} \ No newline at end of file -- Gitblit v1.9.3