From 4f0567c2e02d1bbdfe497dad9b948d3ecf4d3c3a Mon Sep 17 00:00:00 2001
From: liaoxujun@qq.com <liaoxujun@qq.com>
Date: 星期三, 26 七月 2023 16:03:13 +0800
Subject: [PATCH] 增加配置文件,增加数据库codefirst

---
 Document.Unility/NLogProvider.cs                                     |   59 +++++++++++
 DocumentServiceAPI.Web.Entry/appsettings.json                        |    2 
 .gitignore                                                           |    8 +
 Document.Unility/PageBaseSearch.cs                                   |   28 +++++
 DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj               |    2 
 Document.Unility/Document.Unility.csproj                             |   19 +++
 DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj |    4 
 DocumentServiceAPI.Application/GlobalUsings.cs                       |    2 
 Document.Model/Document.Model.csproj                                 |   17 +++
 Document.Unility/PageResult.cs                                       |   35 +++++++
 Document.Unility/NLog.config                                         |   27 +++++
 DocumentServiceAPI.Web.Core/Startup.cs                               |    6 
 Document.Model/SQL/Document_UserInfo.cs                              |   32 ++++++
 .vs/DocumentServiceAPI/DesignTimeBuild/.dtbcache.v2                  |    0 
 DocumentServiceAPI.Application/System/Services/SystemService.cs      |    4 
 15 files changed, 234 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3bc926b..a3476e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,11 @@
 DocumentServiceAPI.Web.Entry/obj/
 DocumentServiceAPI.Model/bin/
 DocumentServiceAPI.Utility/bin/
+Document.Model/obj/Document.Model.csproj.nuget.dgspec.json
+Document.Model/obj/Document.Model.csproj.nuget.g.props
+Document.Model/obj/project.assets.json
+Document.Model/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs
+Document.Model/obj/Debug/net6.0/Document.Model.AssemblyInfo.cs
+Document.Model/obj/Debug/net6.0/Document.Model.AssemblyInfoInputs.cache
+Document.Model/obj/
+Document.Unility/obj/
diff --git a/.vs/DocumentServiceAPI/DesignTimeBuild/.dtbcache.v2 b/.vs/DocumentServiceAPI/DesignTimeBuild/.dtbcache.v2
index c7708cb..0ec8f8e 100644
--- a/.vs/DocumentServiceAPI/DesignTimeBuild/.dtbcache.v2
+++ b/.vs/DocumentServiceAPI/DesignTimeBuild/.dtbcache.v2
Binary files differ
diff --git a/Document.Model/Document.Model.csproj b/Document.Model/Document.Model.csproj
new file mode 100644
index 0000000..b825ed2
--- /dev/null
+++ b/Document.Model/Document.Model.csproj
@@ -0,0 +1,17 @@
+<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.93" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="DTO\" />
+  </ItemGroup>
+
+</Project>
diff --git a/Document.Model/SQL/Document_UserInfo.cs b/Document.Model/SQL/Document_UserInfo.cs
new file mode 100644
index 0000000..323e4f4
--- /dev/null
+++ b/Document.Model/SQL/Document_UserInfo.cs
@@ -0,0 +1,32 @@
+锘縰sing SqlSugar;
+
+namespace Document.Model
+{
+    [SugarTable("Document_UserInfo")]
+    public class Document_UserInfo
+    {
+        /// <summary>
+        /// 璐﹀彿
+        /// </summary>
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "璐﹀彿")]
+        public int UserId { get; set; }
+
+        /// <summary>
+        /// 鐢ㄦ埛鍚嶇О
+        /// </summary>
+        [SugarColumn(Length = 50, ColumnDescription = "鐢ㄦ埛鍚嶇О")]
+        public string UserName { get; set; }
+
+        /// <summary>
+        /// 鏄惁绠$悊鍛�
+        /// </summary>
+        [SugarColumn(ColumnDescription = "鏄惁绠$悊鍛�")]
+        public int IsManager { get; set; }
+
+        /// <summary>
+        /// 鏄惁鍚敤
+        /// </summary>
+        [SugarColumn(ColumnDescription = "鏄惁鍚敤")]
+        public int IsUsed { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/Document.Unility/Document.Unility.csproj b/Document.Unility/Document.Unility.csproj
new file mode 100644
index 0000000..0706e06
--- /dev/null
+++ b/Document.Unility/Document.Unility.csproj
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="NLog" Version="5.2.2" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <None Update="NLog.config">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+
+</Project>
diff --git a/Document.Unility/NLog.config b/Document.Unility/NLog.config
new file mode 100644
index 0000000..a891ee6
--- /dev/null
+++ b/Document.Unility/NLog.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
+
+  <targets>
+
+	  <target xsi:type="File" name="info_file" fileName="${basedir}/logs/${shortdate}_info.log" layout="${longdate} ${uppercase:${level}} ${message}"/>
+	  <target xsi:type="File" name="error_file" fileName="${basedir}/logs/${shortdate}_error.log" layout="${longdate} ${uppercase:${level}} ${message} ${exception:stacktrace}" />	  
+
+	  <!--
+    Write events to a file with the date in the filename.
+    <target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
+            layout="${longdate} ${uppercase:${level}} ${message}" />
+    -->
+  </targets>
+
+  <rules>
+	  <logger name="*" minlevel="Info" maxlevel="Info" writeTo="info_file" />
+	  <logger name="*" minlevel="Error" maxlevel="Error" writeTo="error_file" />
+
+    <!--
+    Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace)  to "f"
+    <logger name="*" minlevel="Debug" writeTo="f" />
+    -->
+  </rules>
+</nlog>
diff --git a/Document.Unility/NLogProvider.cs b/Document.Unility/NLogProvider.cs
new file mode 100644
index 0000000..372e086
--- /dev/null
+++ b/Document.Unility/NLogProvider.cs
@@ -0,0 +1,59 @@
+锘縰sing NLog;
+
+namespace Document.Unility
+{
+    public class NLogProvider
+    {
+
+        private NLogProvider()
+        {
+            logger = LogManager.GetLogger("Logger");//.GetCurrentClassLogger();
+        }
+
+        private readonly Logger logger = null;
+        private static NLogProvider logProvider = null;
+
+        /// <summary>
+        /// 闈欐�佸疄渚�
+        /// </summary>
+        /// <returns></returns>
+        public static NLogProvider GetInstance()
+        {
+            if (logProvider == null)
+            {
+                logProvider = new NLogProvider();
+            }
+            return logProvider;
+        }
+
+        /// <summary>
+        /// Info
+        /// </summary>
+        /// <param name="txt"></param>
+        public void Info(string txt)
+        {
+            if (logger != null)
+                logger.Info(txt);
+        }
+
+        /// <summary>
+        /// Error
+        /// </summary>
+        /// <param name="er"></param>
+        public void Error(Exception er)
+        {
+            if (logger != null)
+                logger.Error(er);
+        }
+
+        /// <summary>
+        /// Error
+        /// </summary>
+        /// <param name="str"></param>
+        public void Error(string str)
+        {
+            if (logger != null)
+                logger.Error(str);
+        }
+    }
+}
diff --git a/Document.Unility/PageBaseSearch.cs b/Document.Unility/PageBaseSearch.cs
new file mode 100644
index 0000000..f1f184c
--- /dev/null
+++ b/Document.Unility/PageBaseSearch.cs
@@ -0,0 +1,28 @@
+锘縩amespace Document.Unility
+{
+    /// <summary>
+    /// 鍒嗛〉鏌ヨ鏉′欢鍩虹被
+    /// </summary>
+    public class PageBaseSearch
+    {
+        /// <summary>
+        /// 椤电爜
+        /// </summary>
+        public int PageIndex { get; set; } = 1;
+
+        /// <summary>
+        /// 鍒嗛〉澶у皬
+        /// </summary>
+        public int PageSize { get; set; } = 20;
+
+        /// <summary>
+        /// 寮�濮嬫棩鏈�
+        /// </summary>
+        public DateTime? StartTime { get; set; }
+
+        /// <summary>
+        /// 缁撴潫鏃ユ湡
+        /// </summary>
+        public DateTime? EndTime { get; set; }
+    }
+}
diff --git a/Document.Unility/PageResult.cs b/Document.Unility/PageResult.cs
new file mode 100644
index 0000000..712fc7d
--- /dev/null
+++ b/Document.Unility/PageResult.cs
@@ -0,0 +1,35 @@
+锘縩amespace Document.Unility
+{
+    /// <summary>
+    /// 鍒嗛〉鏁版嵁淇℃伅
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public class PageResult<T>
+    {
+        /// <summary>
+        /// 椤电爜
+        /// </summary>
+        public int PageIndex { get; set; }
+
+        /// <summary>
+        /// 鍒嗛〉澶у皬
+        /// </summary>
+        public int PageSize { get; set; }
+
+        /// <summary>
+        /// 椤垫�绘暟
+        /// </summary>
+        public int TotalPage { get; set; }
+
+        /// <summary>
+        /// 璁板綍鎬绘暟
+        /// </summary>
+        public int TotalCount { get; set; }
+
+        /// <summary>
+        /// 璁板綍闆嗗悎
+        /// </summary>
+        public List<T> Items { get; set; } = new();
+
+    }
+}
\ No newline at end of file
diff --git a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj
index 5a91029..81b3285 100644
--- a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj
+++ b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj
@@ -25,8 +25,4 @@
 		<ProjectReference Include="..\DocumentServiceAPI.Core\DocumentServiceAPI.Core.csproj" />
 	</ItemGroup>
 
-	<ItemGroup>
-		<Folder Include="System\Services\" />
-	</ItemGroup>
-
 </Project>
diff --git a/DocumentServiceAPI.Application/GlobalUsings.cs b/DocumentServiceAPI.Application/GlobalUsings.cs
index 1f0aacd..81a78ec 100644
--- a/DocumentServiceAPI.Application/GlobalUsings.cs
+++ b/DocumentServiceAPI.Application/GlobalUsings.cs
@@ -12,4 +12,4 @@
 global using Microsoft.AspNetCore.Mvc;
 global using Microsoft.CodeAnalysis;
 global using System.ComponentModel.DataAnnotations;
-global using SqlSugar;
\ No newline at end of file
+global using SqlSugar;
diff --git a/DocumentServiceAPI.Application/System/Services/SystemService.cs b/DocumentServiceAPI.Application/System/Services/SystemService.cs
index f4a583e..5a04507 100644
--- a/DocumentServiceAPI.Application/System/Services/SystemService.cs
+++ b/DocumentServiceAPI.Application/System/Services/SystemService.cs
@@ -1,4 +1,6 @@
-锘縩amespace DocumentServiceAPI.Application;
+锘縰sing DocumentServiceAPI.Core;
+
+namespace DocumentServiceAPI.Application;
 
 public class SystemService : ISystemService, ITransient
 {
diff --git a/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj b/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj
index d9e2dd7..f061aea 100644
--- a/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj
+++ b/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj
@@ -17,7 +17,7 @@
 		<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.38" />
 		<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.38" />
 		<PackageReference Include="Furion.Pure" Version="4.8.8.38" />
-		<PackageReference Include="SqlSugarCore" Version="5.1.4.89" />
+		<PackageReference Include="SqlSugarCore" Version="5.1.4.93" />
 	</ItemGroup>
 
 	<ItemGroup>
diff --git a/DocumentServiceAPI.Web.Core/Startup.cs b/DocumentServiceAPI.Web.Core/Startup.cs
index 012346f..bc0d34b 100644
--- a/DocumentServiceAPI.Web.Core/Startup.cs
+++ b/DocumentServiceAPI.Web.Core/Startup.cs
@@ -1,4 +1,5 @@
-锘縰sing Furion;
+锘縰sing DocumentServiceAPI.Core;
+using Furion;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.Extensions.DependencyInjection;
@@ -12,6 +13,7 @@
     {
         services.AddConsoleFormatter();
         services.AddJwt<JwtHandler>();
+   
 
         services.AddCorsAccessor();
 
@@ -31,7 +33,7 @@
         app.UseRouting();
 
         app.UseCorsAccessor();
-
+        
         app.UseAuthentication();
         app.UseAuthorization();
 
diff --git a/DocumentServiceAPI.Web.Entry/appsettings.json b/DocumentServiceAPI.Web.Entry/appsettings.json
index b8028f9..b0992fc 100644
--- a/DocumentServiceAPI.Web.Entry/appsettings.json
+++ b/DocumentServiceAPI.Web.Entry/appsettings.json
@@ -18,7 +18,6 @@
 
     }
   ],
-
   //swags 鍚嶇О閰嶇疆 榛樿鍒嗙粍
   "[openapi:Default]": {
     "Title": "鏍囦功绠$悊绯荤粺鏈嶅姟",
@@ -50,6 +49,5 @@
     "ClockSkew": 5, // 杩囨湡鏃堕棿瀹归敊鍊硷紝long 绫诲瀷锛屽崟浣嶇锛岄粯璁� 5绉�
     "Algorithm": "HS256" // 鍔犲瘑绠楁硶锛宻tring 绫诲瀷锛岄粯璁� HS256
   }
-
 
 }
\ No newline at end of file

--
Gitblit v1.9.1