From 91080ee02985869b0dc6b70156f299016d550d73 Mon Sep 17 00:00:00 2001
From: liujiaqiang <1448951783@qq.com>
Date: Tue, 13 Jun 2023 17:59:13 +0800
Subject: [PATCH] =?UTF-8?q?24=E5=B0=8F=E6=97=B6=E4=B8=80=E4=BD=93=E6=9C=BA?=
=?UTF-8?q?=E5=90=8E=E7=AB=AF=E6=96=B0=E5=BB=BA=E5=8F=8A=E5=B7=A5=E4=BD=9C?=
=?UTF-8?q?=E5=8F=B0=E8=8F=9C=E5=8D=95=EF=BC=8C=E7=94=A8=E6=88=B7=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=EF=BC=8C=E5=8D=95=E4=BD=8D=E7=AE=A1=E7=90=86=EF=BC=8C?=
=?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86=EF=BC=8C=E8=A7=92=E8=89=B2?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=8C=E8=A7=92=E8=89=B2=E8=8F=9C=E5=8D=95?=
=?UTF-8?q?=EF=BC=8C=E8=A7=92=E8=89=B2=E7=94=A8=E6=88=B7=EF=BC=8C=E9=A2=84?=
=?UTF-8?q?=E7=BA=A6=E6=8E=A5=E5=BE=85=EF=BC=8C=E8=8F=9C=E5=8D=95=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.dockerignore | 25 +
.filenesting.json | 3 +
.gitignore | 71 ++
24Hour.sln | 43 +
24Hour/24Hour.csproj | 22 +
24Hour/24Hour.csproj.user | 7 +
.../Common/ReservationController.cs | 200 ++++
.../Controllers/Common/StagingController.cs | 243 ++++
.../Controllers/Common/WebSocketController.cs | 24 +
24Hour/Controllers/LoginController.cs | 189 +++
.../Controllers/WeatherForecastController.cs | 43 +
.../system/SystemControllerController.cs | 1065 +++++++++++++++++
24Hour/Elight.Entity.csproj.user | 6 +
24Hour/Program.cs | 169 +++
24Hour/Properties/launchSettings.json | 31 +
24Hour/WeatherForecast.cs | 13 +
24Hour/appsettings.Development.json | 8 +
24Hour/appsettings.json | 32 +
.../logs/Logs/ExceptionLog/20230613/10.log | 12 +
Elight.Entity/AppMode/App_ReceptionModel.cs | 78 ++
Elight.Entity/AppMode/StagingModel.cs | 72 ++
Elight.Entity/AppMode/StagingNumModel.cs | 54 +
Elight.Entity/Elight.Entity.csproj | 13 +
.../SystemModel/App_Sys_DepartModel.cs | 68 ++
.../SystemModel/App_Sys_MenuModel.cs | 113 ++
.../SystemModel/App_Sys_RoleMenuModel.cs | 60 +
.../SystemModel/App_Sys_RoleModel.cs | 60 +
.../SystemModel/App_Sys_RoleUserModel.cs | 60 +
.../SystemModel/App_Sys_UnitModel.cs | 69 ++
.../SystemModel/App_Sys_UserModel.cs | 138 +++
.../Func_Dossier_LogRecordModel.cs | 107 ++
Elight.Logic/CurrencyDelete.cs | 28 +
Elight.Logic/Elight.Logic.csproj | 18 +
Elight.Logic/Model/App_ReceptionInput.cs | 68 ++
Elight.Logic/Model/StagingInput.cs | 52 +
Elight.Logic/Model/StagingNumInput.cs | 53 +
.../SystemModel/App_Sys_DepartInput.cs | 43 +
Elight.Logic/SystemModel/App_Sys_MenuInput.cs | 87 ++
Elight.Logic/SystemModel/App_Sys_RoleInput.cs | 34 +
.../SystemModel/App_Sys_RoleMenuInput.cs | 31 +
.../SystemModel/App_Sys_RoleUserInput.cs | 34 +
Elight.Logic/SystemModel/App_Sys_UnitInput.cs | 43 +
Elight.Logic/SystemModel/App_Sys_UnitTree.cs | 73 ++
Elight.Logic/SystemModel/App_Sys_UserInput.cs | 105 ++
Elight.Logic/WriteSysLog.cs | 59 +
Elight.Utility/BasicAuthenticationHandler.cs | 101 ++
Elight.Utility/Elight.Utility.csproj | 21 +
Elight.Utility/Encrypt/AES.cs | 58 +
Elight.Utility/Encrypt/Md5.cs | 73 ++
.../Enum/CustomizedStatusCodeEnum.cs | 53 +
Elight.Utility/Enum/EnumExtension.cs | 60 +
Elight.Utility/Enum/LogLevel.cs | 64 +
Elight.Utility/Extensions/StringExtension.cs | 655 ++++++++++
Elight.Utility/Paging.cs | 166 +++
Elight.Utility/QueryResult.cs | 48 +
Elight.Utility/Result.cs | 61 +
Elight.Utility/TextWriter.cs | 188 +++
Elight.Utility/User.cs | 41 +
Elight.Utility/WebSocketMiddleware.cs | 68 ++
Elight.Utility/logs/LogService.cs | 258 ++++
README.md | 3 +
desktop.ini | 4 +
62 files changed, 5748 insertions(+)
create mode 100644 .dockerignore
create mode 100644 .filenesting.json
create mode 100644 .gitignore
create mode 100644 24Hour.sln
create mode 100644 24Hour/24Hour.csproj
create mode 100644 24Hour/24Hour.csproj.user
create mode 100644 24Hour/Controllers/Common/ReservationController.cs
create mode 100644 24Hour/Controllers/Common/StagingController.cs
create mode 100644 24Hour/Controllers/Common/WebSocketController.cs
create mode 100644 24Hour/Controllers/LoginController.cs
create mode 100644 24Hour/Controllers/WeatherForecastController.cs
create mode 100644 24Hour/Controllers/system/SystemControllerController.cs
create mode 100644 24Hour/Elight.Entity.csproj.user
create mode 100644 24Hour/Program.cs
create mode 100644 24Hour/Properties/launchSettings.json
create mode 100644 24Hour/WeatherForecast.cs
create mode 100644 24Hour/appsettings.Development.json
create mode 100644 24Hour/appsettings.json
create mode 100644 24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230613/10.log
create mode 100644 Elight.Entity/AppMode/App_ReceptionModel.cs
create mode 100644 Elight.Entity/AppMode/StagingModel.cs
create mode 100644 Elight.Entity/AppMode/StagingNumModel.cs
create mode 100644 Elight.Entity/Elight.Entity.csproj
create mode 100644 Elight.Entity/SystemModel/App_Sys_DepartModel.cs
create mode 100644 Elight.Entity/SystemModel/App_Sys_MenuModel.cs
create mode 100644 Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs
create mode 100644 Elight.Entity/SystemModel/App_Sys_RoleModel.cs
create mode 100644 Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs
create mode 100644 Elight.Entity/SystemModel/App_Sys_UnitModel.cs
create mode 100644 Elight.Entity/SystemModel/App_Sys_UserModel.cs
create mode 100644 Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs
create mode 100644 Elight.Logic/CurrencyDelete.cs
create mode 100644 Elight.Logic/Elight.Logic.csproj
create mode 100644 Elight.Logic/Model/App_ReceptionInput.cs
create mode 100644 Elight.Logic/Model/StagingInput.cs
create mode 100644 Elight.Logic/Model/StagingNumInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_DepartInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_MenuInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_RoleInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_RoleMenuInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_RoleUserInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_UnitInput.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_UnitTree.cs
create mode 100644 Elight.Logic/SystemModel/App_Sys_UserInput.cs
create mode 100644 Elight.Logic/WriteSysLog.cs
create mode 100644 Elight.Utility/BasicAuthenticationHandler.cs
create mode 100644 Elight.Utility/Elight.Utility.csproj
create mode 100644 Elight.Utility/Encrypt/AES.cs
create mode 100644 Elight.Utility/Encrypt/Md5.cs
create mode 100644 Elight.Utility/Enum/CustomizedStatusCodeEnum.cs
create mode 100644 Elight.Utility/Enum/EnumExtension.cs
create mode 100644 Elight.Utility/Enum/LogLevel.cs
create mode 100644 Elight.Utility/Extensions/StringExtension.cs
create mode 100644 Elight.Utility/Paging.cs
create mode 100644 Elight.Utility/QueryResult.cs
create mode 100644 Elight.Utility/Result.cs
create mode 100644 Elight.Utility/TextWriter.cs
create mode 100644 Elight.Utility/User.cs
create mode 100644 Elight.Utility/WebSocketMiddleware.cs
create mode 100644 Elight.Utility/logs/LogService.cs
create mode 100644 README.md
create mode 100644 desktop.ini
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..3729ff0
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,25 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/charts
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+LICENSE
+README.md
\ No newline at end of file
diff --git a/.filenesting.json b/.filenesting.json
new file mode 100644
index 0000000..0b71966
--- /dev/null
+++ b/.filenesting.json
@@ -0,0 +1,3 @@
+{
+ "help":"https://go.microsoft.com/fwlink/?linkid=866610"
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b132abf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,71 @@
+# ---> C
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
+
+/.vs
+/24Hour/bin
+/24Hour/obj
+/Elight.Entity/bin
+/Elight.Entity/obj
+/Elight.Logic/bin
+/Elight.Logic/obj
+/Elight.Utility/bin
+/Elight.Utility/obj
+/Elight.Utility/Extension/ServiceConverter.cs
+/24Hour/wwwroot/File
+/24Hour/wwwroot/CaseFile/User
+/24Hour/wwwroot/CaseFile/Detectionscheme/~$230301193901426.docx
+/24Hour/wwwroot/CaseFile/Detectionscheme/20230301195021869.docx
+/24Hour/wwwroot/CaseFile/Detectionscheme/20230301194942291.docx
+/24Hour/wwwroot/CaseFile/Detectionscheme/20230301193901426.docx
+/24Hour/24Hour.xml
diff --git a/24Hour.sln b/24Hour.sln
new file mode 100644
index 0000000..2caa291
--- /dev/null
+++ b/24Hour.sln
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32901.215
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "24Hour", "24Hour\24Hour.csproj", "{9CC60D58-CC75-4BF7-A854-3220E725CD8C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elight.Entity", "Elight.Entity\Elight.Entity.csproj", "{DC5487D6-C400-4D8A-B44C-F4BE05AA4659}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elight.Logic", "Elight.Logic\Elight.Logic.csproj", "{DE4F1117-9E0E-4570-885A-3E852CB96CB9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elight.Utility", "Elight.Utility\Elight.Utility.csproj", "{A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9CC60D58-CC75-4BF7-A854-3220E725CD8C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DC5487D6-C400-4D8A-B44C-F4BE05AA4659}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DE4F1117-9E0E-4570-885A-3E852CB96CB9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A5CD41A8-3970-4BE0-B8CB-E827C2B00D15}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {DF93D9CD-387C-4698-B374-B03D65624202}
+ EndGlobalSection
+EndGlobal
diff --git a/24Hour/24Hour.csproj b/24Hour/24Hour.csproj
new file mode 100644
index 0000000..1e713dd
--- /dev/null
+++ b/24Hour/24Hour.csproj
@@ -0,0 +1,22 @@
+
+
+
+ net6.0
+ enable
+ enable
+ _24Hour
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/24Hour/24Hour.csproj.user b/24Hour/24Hour.csproj.user
new file mode 100644
index 0000000..e4f6e71
--- /dev/null
+++ b/24Hour/24Hour.csproj.user
@@ -0,0 +1,7 @@
+
+
+
+ MvcControllerEmptyScaffolder
+ root/Common/MVC/Controller
+
+
\ No newline at end of file
diff --git a/24Hour/Controllers/Common/ReservationController.cs b/24Hour/Controllers/Common/ReservationController.cs
new file mode 100644
index 0000000..6e256dd
--- /dev/null
+++ b/24Hour/Controllers/Common/ReservationController.cs
@@ -0,0 +1,200 @@
+using Elight.Entity;
+using Elight.Logic;
+using Elight.Utility;
+using Elight.Utility.Code;
+using Elight.Utility.Extensions;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+
+namespace _24Hour.Controllers.Common
+{
+ [Authorize]
+ [ApiController]
+ [Route("api/reception")]
+ public class ReservationController : Controller
+ {
+ #region Identity
+ private readonly SqlSugarClient _db;//数据库
+ private readonly WriteSysLog _logs;//操作日志
+ App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户
+ private readonly ILogger _logger;//日志
+ Result result = new Result();
+ public ReservationController(ILogger logger, SqlSugarClient db, WriteSysLog logs, User user)
+ {
+ _logger = logger;
+ _db = db;
+ _logs = logs;
+ _userdata = user.Userdata();
+ }
+
+ #endregion
+
+
+ #region 预约接待管理
+ ///
+ /// 预约接待分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryReception")]
+ public async Task QueryReception(App_ReceptionInput Reception)
+ {
+ var Receptionlist = new List();
+ //获取工作台信息
+ var app_staging = await _db.Queryable().Where(w => w.IsDelete == 0).ToListAsync();
+ //查询预约接待记录
+ var list = await _db.Queryable()
+ .WhereIF(!string.IsNullOrEmpty(Reception.depart), q => q.depart.Contains(Reception.depart))
+ .WhereIF(!string.IsNullOrEmpty(Reception.createusername), q => q.createusername.Contains(Reception.createusername))
+ .WhereIF(!string.IsNullOrEmpty(Reception.receptionId), q => q.receptionId.Contains(Reception.receptionId))
+ .WhereIF(Reception.state != null, q => q.state == Reception.state)
+ .Where(q => q.IsDelete == 0).ToPageListAsync(Reception.PageIndex, Reception.PageSize);
+ list.ForEach(q =>
+ {
+ var data = app_staging.Where(a => a.Id == q.receptionId).First();
+ if (data != null)
+ {
+ q.receptionId = data.title;
+ Receptionlist.Add(q);
+ }
+ });
+ var data = new QueryResult(Reception, Receptionlist.OrderByDescending(q => q.creationtime).ToList());
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+ ///
+ /// 添加预约接待
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddReception")]
+ public async Task AddReception(App_ReceptionModel Receptiondata)
+ {
+ try
+ {
+ _db.BeginTran();
+ Receptiondata.Id = Guid.NewGuid().ToString();
+ Receptiondata.createuserId = _userdata.Id.ToString();
+ Receptiondata.createusername = _userdata.name;
+ var num = await _db.Insertable(Receptiondata).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("预约管理", "添加预约接待信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改预约接待
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateReception")]
+ public async Task UpdateReception(App_ReceptionModel Receptiondata)
+ {
+ try
+ {
+ _db.BeginTran();
+ var num = await _db.Updateable(Receptiondata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("预约管理", "修改预约接待", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除预约接待
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteReception")]
+ public async Task DeleteReception(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var Receptionlist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ Receptionlist.ForEach(q =>
+ {
+ q.IsDelete = 1;
+ });
+ var num = await _db.Updateable(Receptionlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("预约管理", "删除预约接待", result,_db);
+ return result;
+ }
+
+
+ ///
+ /// 办理预约接待
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateReception_state")]
+ public async Task UpdateReception_state(CurrencyDelete Currency)
+ {
+ try
+ {
+ var Receptionlist = await _db.Queryable().Where(q => Currency.id.Contains(q.Id)).ToListAsync();
+ Receptionlist.ForEach(q => { q.state = 1; });
+ _db.BeginTran();
+ var num = await _db.Updateable(Receptionlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "办理成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("预约管理", "办理预约接待", result,_db);
+ return result;
+ }
+ #endregion
+ }
+}
diff --git a/24Hour/Controllers/Common/StagingController.cs b/24Hour/Controllers/Common/StagingController.cs
new file mode 100644
index 0000000..df5f763
--- /dev/null
+++ b/24Hour/Controllers/Common/StagingController.cs
@@ -0,0 +1,243 @@
+using Elight.Entity;
+using Elight.Logic;
+using Elight.Utility;
+using Elight.Utility.Code;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+
+namespace _24Hour.Controllers.Common
+{
+ [Authorize]
+ [ApiController]
+ [Route("api/Staging")]
+ public class StagingController : Controller
+ {
+ #region Identity
+ private readonly SqlSugarClient _db;//数据库
+ private readonly WriteSysLog _logs;//操作日志
+ App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户
+ private readonly ILogger _logger;//日志
+ Result result = new Result();
+ public StagingController(ILogger logger, SqlSugarClient db, WriteSysLog logs, User user)
+ {
+ _logger = logger;
+ _db = db;
+ _logs = logs;
+ _userdata = user.Userdata();
+ }
+
+ #endregion
+
+ #region 工作台管理
+ ///
+ /// 工作台分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryStaging")]
+ public async Task QueryStaging(StagingInput Staging)
+ {
+ var list = await _db.Queryable()
+ .WhereIF(!string.IsNullOrEmpty(Staging.title), q => q.title.Contains(Staging.title))
+ .WhereIF(!string.IsNullOrEmpty(Staging.titletype), q => q.titletype.Contains(Staging.titletype))
+ .Where(q => q.IsDelete == 0).ToPageListAsync(Staging.PageIndex, Staging.PageSize);
+ var data = new QueryResult(Staging, list);
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+ ///
+ /// 添加工作台
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddStaging")]
+ public async Task AddStaging(StagingModel Stagingdata)
+ {
+ try
+ {
+ _db.BeginTran();
+ Stagingdata.Id = Guid.NewGuid().ToString();
+ Stagingdata.userId = _userdata.Id.ToString();
+ Stagingdata.username = _userdata.name;
+ var num = await _db.Insertable(Stagingdata).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("工作台添加", "添加工作台", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改工作台
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateStaging")]
+ public async Task UpdateStaging(StagingModel Stagingdata)
+ {
+ try
+ {
+ _db.BeginTran();
+ var num = await _db.Updateable(Stagingdata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("工作台", "修改工作台信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除工作台
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteStaging")]
+ public async Task DeleteStaging(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var Staginglist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ Staginglist.ForEach(q =>
+ {
+ q.IsDelete = 1;
+ });
+ var num = await _db.Updateable(Staginglist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("工作台", "删除工作台信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 添加工作台使用次数
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("AddStagingnum")]
+ public async Task AddStagingnum(string id)
+ {
+ try
+ {
+ var Stagingdata = await _db.Queryable().Where(q => q.Id == id).FirstAsync();
+ if (Stagingdata != null)
+ {
+ var Stagingnumdata = await _db.Queryable().Where(q => q.userId == _userdata.Id.ToString() && q.stagingId == id).FirstAsync();
+ if (Stagingnumdata != null)
+ {
+ Stagingnumdata.num++;
+ Stagingnumdata.creationtime = DateTime.Now;
+ _db.BeginTran();
+ var num = await _db.Updateable(Stagingnumdata).UpdateColumns(it => new { it.num }).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "";
+ }
+ }
+ else
+ {
+ _db.BeginTran();
+ var da = new StagingNumModel();
+ da.Id = Guid.NewGuid().ToString();
+ da.stagingId = id;
+ da.num = 1;
+ da.userId = _userdata.Id;
+ da.username = _userdata.name;
+ var num = _db.Insertable(da).ExecuteCommand();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "";
+ }
+ }
+ }
+ else
+ {
+
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("工作台_使用数据", "更新或则添加使用次数", result,_db);
+ return result;
+ }
+ ///
+ /// 获取工作台信息
+ ///
+ ///
+ [HttpGet]
+ [Route("GetStaginglist")]
+ public async Task GetStaginglist()
+ {
+ var nulist = new List();
+ var Staginglist = await _db.Queryable().Where(q => q.IsDelete == 0).ToListAsync();
+ var Staginggrlist = Staginglist.GroupBy(q => q.titletype).Select(x => new { type = x.Key, data = x.ToList() }).ToList();
+ var Numlist = await _db.Queryable().Where(q => q.IsDelete == 0 && q.userId == _userdata.Id).ToListAsync();
+ if (Numlist.Count > 0)
+ {
+ //获取常用工作台菜单
+ var da = Numlist.OrderByDescending(q => q.creationtime).Take(10).Select(q => q.stagingId);
+ var dalist = Staginglist.Where(q => da.Contains(q.Id)).ToList();
+ Staginggrlist.Insert(0, new { type = "我的", data = dalist });
+
+ //获取使用次数最多4个常用工作台菜单
+ var Numda = Numlist.OrderByDescending(q => q.num).Take(4).Select(q => q.stagingId);
+ nulist = Staginglist.Where(q => Numda.Contains(q.Id)).ToList();
+ nulist.AddRange(Staginglist.Where(q => !Numda.Contains(q.Id)).Take(4 - nulist.Count()).ToList());
+ }
+ else
+ {
+ nulist = Staginglist.Take(4).ToList();
+ }
+ result.IsSucceed = true;
+ result.result = new { typelist = Staginggrlist, numlist = nulist };
+ return result;
+ }
+ #endregion
+ }
+}
diff --git a/24Hour/Controllers/Common/WebSocketController.cs b/24Hour/Controllers/Common/WebSocketController.cs
new file mode 100644
index 0000000..d6865c4
--- /dev/null
+++ b/24Hour/Controllers/Common/WebSocketController.cs
@@ -0,0 +1,24 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace _24Hour.Controllers.Common
+{
+ [Authorize]
+ public class WebSocketController : Controller
+ {
+ [HttpGet("/ws")]
+ public async Task WebSocketServer()
+ {
+ if (HttpContext.WebSockets.IsWebSocketRequest)
+ {
+ try
+ {
+ var socket = await HttpContext.WebSockets.AcceptWebSocketAsync();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
+ }
+}
diff --git a/24Hour/Controllers/LoginController.cs b/24Hour/Controllers/LoginController.cs
new file mode 100644
index 0000000..adfe8bc
--- /dev/null
+++ b/24Hour/Controllers/LoginController.cs
@@ -0,0 +1,189 @@
+using Elight.Entity;
+using Elight.Utility.Code;
+using Elight.Utility.Encrypt;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.IdentityModel.Tokens;
+using Newtonsoft.Json;
+using SqlSugar;
+using System.IdentityModel.Tokens.Jwt;
+using System.Runtime.Serialization;
+using System.Security.Claims;
+using System.Text;
+
+namespace _24Hour.Controllers
+{
+ ///
+ /// ¼
+ ///
+ [ApiController]
+ [Route("api/Login")]
+ public class LoginController : ControllerBase
+ {
+ private readonly IConfiguration _configuration;
+ private readonly SqlSugarClient _db;//ݿ
+ private readonly ILogger _logger;//־
+ Result ret = new Result();
+ public LoginController(ILogger logger, SqlSugarClient db, IConfiguration configuration)
+ {
+ _logger = logger;
+ _db = db;
+ _configuration = configuration;
+ }
+ [HttpPost]
+ [Route("Login")]
+ public async Task Login(UserLogin login)
+ {
+ var Passmd5 = Md5.Encrypt32(login.Password).ToLower();
+ var date = await _db.Queryable().Where(q => q.IsDeleted == 0 && q.isdeactivate == 0 && q.phone == login.phone).FirstAsync();
+ if (date != null)
+ {
+ if (Passmd5 != date.Password)
+ {
+ ret.IsSucceed = false;
+ ret.Message = "˺Ż";
+ return ret;
+ }
+ else if (date.usertype == 1 && date.audit == null)
+ {
+ ret.IsSucceed = false;
+ ret.Message = "˺У";
+ return ret;
+ }
+ else if (date.usertype == 1 && date.audit == 1)
+ {
+ ret.IsSucceed = false;
+ ret.Message = $"˺δͨԭ{date.describe}";
+ return ret;
+ }
+ else if (date.usertype == 0 && date.becurrent == 1)
+ {
+ ret.IsSucceed = false;
+ ret.Message = $"˺δȨ¼ϵԱ";
+ return ret;
+ }
+ #region jwttoken
+ var tokenHandler = new JwtSecurityTokenHandler();
+ var claims =new Claim[]
+ {
+ new Claim(ClaimTypes.UserData,JsonConvert.SerializeObject(date)),
+ };
+
+ var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_configuration.GetSection("JwtConfiguration:Jwtkey").Value));
+ var signingCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
+ //Token
+ var jwttoken = new JwtSecurityToken(
+ issuer: "https://127.0.0.1:7246",
+ audience: "https://127.0.0.1:7246",
+ claims: claims,
+ notBefore: DateTime.Now,
+ expires: DateTime.Now.AddDays(1),
+ signingCredentials: signingCredentials
+ );
+ //var token = new JwtSecurityTokenHandler().CreateToken(jwttoken);
+ var tokenString = new JwtSecurityTokenHandler().WriteToken(jwttoken);
+ ret.result = new
+ {
+ name = date.name,
+ sex = date.sex,
+ phone = date.phone,
+ photo = date.photo,
+ duties = date.duties,
+ unitCode = "",
+ department = "",
+ token = tokenString
+ };
+ #endregion
+ ret.IsSucceed = true;
+ }
+ else
+ {
+ ret.IsSucceed = false;
+ ret.Message = "˺Ųڣ";
+ }
+ return ret;
+ }
+
+ ///
+ /// Ȩ¼
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("WeChatLogin")]
+ public async Task WeChatLogin(string openId)
+ {
+ var date = await _db.Queryable().Where(q => q.IsDeleted == 0 && q.isdeactivate == 0 && q.wechatId == openId).FirstAsync();
+ if (date != null)
+ {
+ if (date.usertype == 1 && date.audit == null)
+ {
+ ret.IsSucceed = false;
+ ret.Message = "˺У";
+ return ret;
+ }
+ else if (date.usertype == 1 && date.audit == 1)
+ {
+ ret.IsSucceed = false;
+ ret.Message = $"˺δͨԭ{date.describe}";
+ return ret;
+ }
+ else if (date.usertype == 0 && date.becurrent == 1)
+ {
+ ret.IsSucceed = false;
+ ret.Message = $"˺δȨ¼ϵԱ";
+ return ret;
+ }
+ #region jwttoken
+ var tokenHandler = new JwtSecurityTokenHandler();
+ var claims = new Claim[]
+ {
+ new Claim(ClaimTypes.UserData,JsonConvert.SerializeObject(date)),
+ };
+
+ var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_configuration.GetSection("JwtConfiguration:Jwtkey").Value));
+ var signingCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
+ //Token
+ var jwttoken = new JwtSecurityToken(
+ issuer: "https://127.0.0.1:7246",
+ audience: "https://127.0.0.1:7246",
+ claims: claims,
+ notBefore: DateTime.Now,
+ expires: DateTime.Now.AddDays(1),
+ signingCredentials: signingCredentials
+ );
+ //var token = new JwtSecurityTokenHandler().CreateToken(jwttoken);
+ var tokenString = new JwtSecurityTokenHandler().WriteToken(jwttoken);
+ ret.result = new
+ {
+ name = date.name,
+ sex = date.sex,
+ phone = date.phone,
+ photo = date.photo,
+ duties = date.duties,
+ unitCode = "",
+ department = "",
+ token = tokenString
+ };
+ #endregion
+ ret.IsSucceed = true;
+ }
+ else
+ {
+ ret.IsSucceed = false;
+ ret.Message = "δȨ";
+ }
+ return ret;
+ }
+ }
+ public class UserLogin
+ {
+ [DataMember]
+ public string phone { get; set; }
+ ///
+ /// ¼
+ ///
+ [DataMember]
+ public string Password { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/24Hour/Controllers/WeatherForecastController.cs b/24Hour/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..9dc444c
--- /dev/null
+++ b/24Hour/Controllers/WeatherForecastController.cs
@@ -0,0 +1,43 @@
+using Elight.Entity;
+using Elight.Utility;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+
+namespace _24Hour.Controllers
+{
+ [Authorize]
+ [ApiController]
+ [Route("api/WeatherForecast")]
+ public class WeatherForecastController : ControllerBase
+ {
+ private readonly SqlSugarClient _db;
+ App_Sys_UserModel _userdata = new App_Sys_UserModel();//ǰû
+ private static readonly string[] Summaries = new[]
+ {
+ "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
+ };
+
+ private readonly ILogger _logger;
+
+ public WeatherForecastController(ILogger logger, SqlSugarClient db,User user)
+ {
+ _logger = logger;
+ _db = db;
+ _userdata = user.Userdata();
+ }
+
+ [HttpGet(Name = "GetWeatherForecast")]
+ public IEnumerable Get()
+ {
+ var ss = _userdata;
+ return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+ {
+ Date = DateTime.Now.AddDays(index),
+ TemperatureC = Random.Shared.Next(-20, 55),
+ Summary = Summaries[Random.Shared.Next(Summaries.Length)]
+ })
+ .ToArray();
+ }
+ }
+}
\ No newline at end of file
diff --git a/24Hour/Controllers/system/SystemControllerController.cs b/24Hour/Controllers/system/SystemControllerController.cs
new file mode 100644
index 0000000..4658b85
--- /dev/null
+++ b/24Hour/Controllers/system/SystemControllerController.cs
@@ -0,0 +1,1065 @@
+using Elight.Entity;
+using Elight.Logic;
+using Elight.Logic.SystemModel;
+using Elight.Utility;
+using Elight.Utility.Code;
+using Elight.Utility.Extensions;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+
+namespace _24Hour.Controllers.system
+{
+ ///
+ /// 系统设置
+ ///
+ [Authorize]
+ [ApiController]
+ [Route("api/system")]
+ public class SystemControllerController : Controller
+ {
+ #region Identity
+ private readonly SqlSugarClient _db;//数据库
+ private readonly WriteSysLog _logs;//操作日志
+ App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户
+ private readonly ILogger _logger;//日志
+ Result result = new Result();
+ public SystemControllerController(ILogger logger, SqlSugarClient db, WriteSysLog logs, User user)
+ {
+ _logger = logger;
+ _db = db;
+ _logs = logs;
+ _userdata = user.Userdata();
+ }
+ #endregion
+ #region 用户管理
+ ///
+ /// 系统用户分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryUser0")]
+ public async Task QueryUser0(App_Sys_UserInput UserModel)
+ {
+ var list = await _db.Queryable()
+ .WhereIF(!UserModel.name.IsNullOrEmpty(), q => q.name.Contains(UserModel.name))
+ .WhereIF(!UserModel.phone.IsNullOrEmpty(), q => q.phone.Contains(UserModel.phone))
+ .WhereIF(!UserModel.duties.IsNullOrEmpty(), q => q.duties.Contains(UserModel.duties))
+ .WhereIF(!UserModel.cardId.IsNullOrEmpty(), q => q.cardId.Contains(UserModel.cardId))
+ .Where(q => q.IsDeleted == 0 && q.usertype == 0)
+ .ToPageListAsync(UserModel.PageIndex, UserModel.PageSize);
+ var data = new QueryResult(UserModel, list);
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+
+ ///
+ /// app用户分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryUser1")]
+ public async Task QueryUser1(App_Sys_UserInput UserModel)
+ {
+ var list = await _db.Queryable()
+ .WhereIF(!UserModel.name.IsNullOrEmpty(), q => q.name.Contains(UserModel.name))
+ .WhereIF(!UserModel.phone.IsNullOrEmpty(), q => q.phone.Contains(UserModel.phone))
+ .WhereIF(!UserModel.duties.IsNullOrEmpty(), q => q.duties.Contains(UserModel.duties))
+ .WhereIF(!UserModel.cardId.IsNullOrEmpty(), q => q.cardId.Contains(UserModel.cardId))
+ .Where(q => q.IsDeleted == 0 && q.usertype == 1).ToPageListAsync(UserModel.PageIndex, UserModel.PageSize);
+ var data = new QueryResult(UserModel, list);
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+ ///
+ /// 系统添加用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddUser0")]
+ public async Task AddUser0(App_Sys_UserModel UserModel)
+ {
+ try
+ {
+ var data = await _db.Queryable().Where(q => q.phone == UserModel.phone).FirstAsync();
+ if (data != null)
+ {
+
+ result.IsSucceed = false;
+ result.Message = "电话号码已存在!";
+ return result;
+ }
+ _db.BeginTran();
+ UserModel.Id = Guid.NewGuid().ToString();
+ UserModel.createuserId = _userdata.Id.ToString();
+ UserModel.createusername = _userdata.name;
+ UserModel.usertype = 0;
+ //默认密码
+ UserModel.Password = Elight.Utility.Encrypt.Md5.Encrypt32($"mr123456").ToLower();
+ var num = await _db.Insertable(UserModel).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("用户管理", "添加系统用户信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// APP添加用户
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ [HttpPost]
+ [Route("AddUser1")]
+ public async Task AddUser1(App_Sys_UserModel UserModel)
+ {
+ try
+ {
+ var data = await _db.Queryable().Where(q => q.phone == UserModel.phone).FirstAsync();
+ if (data != null)
+ {
+ result.IsSucceed = false;
+ result.Message = "电话号码已存在!";
+ return result;
+ }
+ _db.BeginTran();
+ UserModel.Id = Guid.NewGuid().ToString();
+ UserModel.usertype = 1;
+ //默认密码
+ UserModel.Password = Elight.Utility.Encrypt.Md5.Encrypt32($"{UserModel.Password}").ToLower();
+ var num = await _db.Insertable(UserModel).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("用户管理", "添加APP端用户", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateUser")]
+ public async Task UpdateUser(App_Sys_UserModel UserModel)
+ {
+ try
+ {
+ _db.BeginTran();
+ var num = await _db.Updateable(UserModel).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("用户管理", "修改人员信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteUser")]
+ public async Task DeleteUser(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var userlist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ userlist.ForEach(q =>
+ {
+ q.IsDeleted = 1;
+ });
+ var num = await _db.Updateable(userlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("用户管理", "删除人员信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 角色管理
+ ///
+ /// 角色分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryRole")]
+ public async Task QueryRole(App_Sys_RoleInput roledata)
+ {
+ var totalCount = 0;
+ var list = await _db.Queryable()
+ .WhereIF(!string.IsNullOrEmpty(roledata.name), q => q.name.Contains(roledata.name))
+ .Where(q => q.IsDeleted == 0).ToPageListAsync(roledata.PageIndex, roledata.PageSize);
+ var data = new QueryResult(roledata, list);
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+
+ ///
+ /// 添加角色
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddRole")]
+ public async Task AddRole(App_Sys_RoleModel Roledata)
+ {
+ try
+ {
+ _db.BeginTran();
+ Roledata.Id = Guid.NewGuid().ToString();
+ Roledata.userId = _userdata.Id.ToString();
+ Roledata.username = _userdata.name;
+ var num = await _db.Insertable(Roledata).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "添加角色信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改角色
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateRole")]
+ public async Task UpdateRole(App_Sys_RoleModel Roledata)
+ {
+ try
+ {
+ _db.BeginTran();
+ var num = await _db.Updateable(Roledata).UpdateColumns(it => new { it.name }).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "修改角色信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除角色
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteRole")]
+ public async Task DeleteRole(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var userlist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ userlist.ForEach(q =>
+ {
+ q.IsDeleted = 1;
+ });
+ var num = await _db.Updateable(userlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "删除角色信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 角色菜单管理
+ ///
+ /// 获取角色下的所有菜单信息
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryRoleMenu")]
+ public async Task QueryRoleMenu(App_Sys_RoleMenuInput roledata)
+ {
+ var totalCount = 0;
+ var list = await _db.Queryable()
+ .WhereIF(!roledata.roleId.IsNullOrEmpty(), q => q.roleId == roledata.roleId)
+ .Where(q => q.IsDeleted == 0).Select(x => x.menuId).ToListAsync();
+ //roledata.PageCount = totalCount;
+ //var data = new QueryResult(roledata, list);
+ result.IsSucceed = true;
+ result.result = list;
+ return result;
+ }
+
+ ///
+ /// 添加角色菜单
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddRoleMenu")]
+ public async Task AddRoleMenu(List RoleMenulist)
+ {
+ try
+ {
+ _db.BeginTran();
+ RoleMenulist.ForEach(RoleMenudata =>
+ {
+ RoleMenudata.Id = Guid.NewGuid().ToString();
+ RoleMenudata.userId = _userdata.Id.ToString();
+ RoleMenudata.username = _userdata.name;
+ });
+ var num = await _db.Insertable(RoleMenulist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "添加角色菜单信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除角色菜单
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteRoleMenu")]
+ public async Task DeleteRoleMenu(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var userlist = await _db.Queryable().Where(q => q.roleId == Currency.tyId).In(q => q.menuId, Currency.id).ToListAsync();
+ userlist.ForEach(q =>
+ {
+ q.IsDeleted = 1;
+ });
+ var num = await _db.Updateable(userlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "删除角色菜单信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 角色用户管理
+ ///
+ /// 获取角色下的所有用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryRoleUser")]
+ public async Task QueryRoleUser(App_Sys_RoleUserInput roledata)
+ {
+ var totalCount = 0;
+ //获取角色下得所有用户id
+ var list = await _db.Queryable()
+ .WhereIF(!string.IsNullOrEmpty(roledata.roleId), q => q.roleId == roledata.roleId)
+ .Where(q => q.IsDeleted == 0).Select(x => x.roleuserId).ToListAsync();
+ //roledata.PageCount = totalCount;
+ //var data = new QueryResult(roledata, list);
+ result.IsSucceed = true;
+ result.result = list;
+ return result;
+ }
+
+ ///
+ /// 添加角色用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddRoleUser")]
+ public async Task AddRoleUser(List RoleUserlist)
+ {
+ try
+ {
+ _db.BeginTran();
+ RoleUserlist.ForEach(RoleMenudata =>
+ {
+ RoleMenudata.Id = Guid.NewGuid().ToString();
+ RoleMenudata.userId = _userdata.Id.ToString();
+ RoleMenudata.username = _userdata.name;
+ });
+ var num = await _db.Insertable(RoleUserlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "添加角色用户信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除角色用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteRoleUser")]
+ public async Task DeleteRoleUser(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var userlist = await _db.Queryable().Where(q => q.roleId == Currency.tyId).In(q => q.roleuserId, Currency.id).ToListAsync();
+ userlist.ForEach(q =>
+ {
+ q.IsDeleted = 1;
+ });
+ var num = await _db.Updateable(userlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("角色管理", "删除角色用户信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 单位管理
+ ///
+ /// 单位list集合
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryUnitlist")]
+ public async Task QueryUnitlist(App_Sys_UnitInput Unitdata)
+ {
+ var list = await _db.Queryable()
+ .WhereIF(!Unitdata.unitCode.IsNullOrEmpty(), q => q.unitCode.Contains(Unitdata.unitCode))
+ .WhereIF(!Unitdata.unitname.IsNullOrEmpty(), q => q.unitname.Contains(Unitdata.unitname))
+ .WhereIF(!Unitdata.unitjc.IsNullOrEmpty(), q => q.unitjc.Contains(Unitdata.unitjc))
+ .Where(q => q.IsDelete == 0).ToListAsync();
+ result.IsSucceed = true;
+ result.result = list;
+ return result;
+ }
+ ///
+ /// 单位树型查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryUnitTree")]
+ public async Task QueryUnitTree(App_Sys_UnitInput Unitdata)
+ {
+ var treelist = await _db.Queryable()
+ .WhereIF(!Unitdata.unitCode.IsNullOrEmpty(), q => q.unitCode.Contains(Unitdata.unitCode))
+ .WhereIF(!Unitdata.unitname.IsNullOrEmpty(), q => q.unitname.Contains(Unitdata.unitname))
+ .WhereIF(!Unitdata.unitjc.IsNullOrEmpty(), q => q.unitjc.Contains(Unitdata.unitjc))
+ .WhereIF(Unitdata.StartTime != null && Unitdata.EndTime != null, q => q.createtime >= Unitdata.StartTime && q.createtime < Unitdata.EndTime.Value.AddDays(1))
+ .Where(q => q.IsDelete == 0).ToTreeAsync(it => it.Child, it => it.pid, null);
+ result.IsSucceed = true;
+ result.result = treelist;
+ return result;
+ }
+
+ ///
+ /// 添加单位
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddUnit")]
+ public async Task AddUnit(App_Sys_UnitModel Unitdata)
+ {
+ try
+ {
+ //添加单位前判断单位编码是否重复
+ var data = await _db.Queryable().Where(q => q.unitCode == Unitdata.unitCode).FirstAsync();
+ if (data != null)
+ {
+
+ result.IsSucceed = false;
+ result.Message = "单位编码已存在!";
+ return result;
+ }
+ _db.BeginTran();
+ Unitdata.Id = Guid.NewGuid().ToString();
+ Unitdata.createuserId = _userdata.Id.ToString();
+ Unitdata.createusername = _userdata.name;
+ var num = await _db.Insertable(Unitdata).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("单位管理", "添加单位信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改单位
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateUnit")]
+ public async Task UpdateUnit(App_Sys_UnitModel Unitdata)
+ {
+ try
+ {
+ //判断单位编码是否已存在
+ var data = await _db.Queryable().Where(q => q.unitCode == Unitdata.unitCode).FirstAsync();
+ if (data != null)
+ {
+
+ result.IsSucceed = false;
+ result.Message = "单位编码已存在!";
+ return result;
+ }
+ _db.BeginTran();
+ var num = await _db.Updateable(Unitdata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("单位管理", "修改单位信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除单位
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteUnit")]
+ public async Task DeleteUnit(CurrencyDelete Currency)
+ {
+ try
+ {
+ //查询单位是否存在子级
+ var Unitpidlist = await _db.Queryable().In(q => q.pid, Currency.id).ToListAsync();
+ if (Unitpidlist.Count() > 0)
+ {
+ result.IsSucceed = false;
+ result.result = "删除单位存在子级数据!";
+ return result;
+ }
+ _db.BeginTran();
+ var Unitlist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ Unitlist.ForEach(q =>
+ {
+ q.IsDelete = 1;
+ });
+ var num = await _db.Updateable(Unitlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("单位管理", "删除单位信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 部门管理
+
+ ///
+ /// 通过单位ID查询部门
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("QueryDepart")]
+ public async Task QueryDepart(string unitId)
+ {
+ var totalCount = 0;
+ var list = await _db.Queryable()
+ .WhereIF(!unitId.IsNullOrEmpty(), q => q.unitId.Contains(unitId))
+ .Where(q => q.IsDelete == 0).ToListAsync();
+ result.IsSucceed = true;
+ result.result = list;
+ return result;
+ }
+ ///
+ /// 部门分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryDepart")]
+ public async Task QueryDepart(App_Sys_DepartInput Departdata)
+ {
+ var list = await _db.Queryable()
+ .WhereIF(!Departdata.departCode.IsNullOrEmpty(), q => q.departCode.Contains(Departdata.departCode))
+ .WhereIF(!Departdata.departjc.IsNullOrEmpty(), q => q.departjc.Contains(Departdata.departjc))
+ .WhereIF(!Departdata.departname.IsNullOrEmpty(), q => q.departname.Contains(Departdata.departname))
+ .WhereIF(!Departdata.unitId.IsNullOrEmpty(), q => q.unitId.Contains(Departdata.unitId))
+ .WhereIF(Departdata.StartTime != null && Departdata.EndTime != null, q => q.createtime >= Departdata.StartTime && q.createtime < Departdata.EndTime.Value.AddDays(1))
+ .Where(q => q.IsDelete == 0).ToPageListAsync(Departdata.PageIndex, Departdata.PageSize);
+ var data = new QueryResult(Departdata, list);
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+
+ ///
+ /// 添加部门
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddDepart")]
+ public async Task AddDepart(App_Sys_DepartModel Departdata)
+ {
+ try
+ {
+ //添加单位前判断单位编码是否重复
+ var data = await _db.Queryable().Where(q => q.departCode == Departdata.departCode).FirstAsync();
+ if (data != null)
+ {
+
+ result.IsSucceed = false;
+ result.Message = "部门编码已存在!";
+ return result;
+ }
+ _db.BeginTran();
+ Departdata.Id = Guid.NewGuid().ToString();
+ Departdata.createuserId = _userdata.Id.ToString();
+ Departdata.createusername = _userdata.name;
+ var num = await _db.Insertable(Departdata).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("部门管理", "添加部门信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改部门
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateDepart")]
+ public async Task UpdateDepart(App_Sys_DepartModel Departdata)
+ {
+ try
+ {
+ //判断单位编码是否已存在
+ var data = await _db.Queryable().Where(q => q.departCode == Departdata.departCode).FirstAsync();
+ if (data != null)
+ {
+
+ result.IsSucceed = false;
+ result.Message = "部门编码已存在!";
+ return result;
+ }
+ _db.BeginTran();
+ var num = await _db.Updateable(Departdata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("部门管理", "修改部门信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除部门
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteDepart")]
+ public async Task DeleteDepart(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var Departlist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ Departlist.ForEach(q =>
+ {
+ q.IsDelete = 1;
+ });
+ var num = await _db.Updateable(Departlist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("部门管理", "删除部门信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 菜单管理
+
+ ///
+ /// 获取父级菜单
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetQueryMenusssslist")]
+ public async Task GetQueryMenusssslist()
+ {
+ var list = await _db.Queryable().Where(q => q.IsDelete == 0 && !string.IsNullOrEmpty(q.pid)).Select(q => new { q.Id, q.name }).ToListAsync();
+ result.IsSucceed = true;
+ result.result = list;
+ return result;
+ }
+ ///
+ /// 菜单分页查询
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("QueryMenupage")]
+ public async Task QueryMenupage(App_Sys_MenuInput Menudata)
+ {
+ var totalCount = 0;
+ var list = await _db.Queryable()
+ .WhereIF(!Menudata.name.IsNullOrEmpty(), q => q.name.Contains(Menudata.name))
+ .WhereIF(!Menudata.pid.IsNullOrEmpty(), q => q.pid.Contains(Menudata.pid))
+ .Where(q => q.IsDelete == 0).ToPageListAsync(Menudata.PageIndex, Menudata.PageSize);
+ var data = new QueryResult(Menudata, list);
+ result.IsSucceed = true;
+ result.result = data;
+ return result;
+ }
+ ///
+ /// 添加菜单
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("AddMenu")]
+ public async Task AddMenu(App_Sys_MenuModel Menudata)
+ {
+ try
+ {
+ _db.BeginTran();
+ Menudata.Id = Guid.NewGuid().ToString();
+ Menudata.createuserId = _userdata.Id;
+ Menudata.createusername = _userdata.name;
+ var num = await _db.Insertable(Menudata).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "添加成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("菜单管理", "添加菜单信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 修改菜单
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateMenu")]
+ public async Task UpdateMenu(App_Sys_MenuModel Menudata)
+ {
+ try
+ {
+ _db.BeginTran();
+ var num = await _db.Updateable(Menudata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "修改成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("菜单管理", "修改菜单信息", result,_db);
+ return result;
+ }
+
+ ///
+ /// 删除菜单
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("DeleteMenu")]
+ public async Task DeleteMenu(CurrencyDelete Currency)
+ {
+ try
+ {
+ _db.BeginTran();
+ var Menulist = await _db.Queryable().In(q => q.Id, Currency.id).ToListAsync();
+ Menulist.ForEach(q =>
+ {
+ q.IsDelete = 1;
+ });
+ var num = await _db.Updateable(Menulist).ExecuteCommandAsync();
+ _db.CommitTran();
+ if (num > 0)
+ {
+ result.IsSucceed = true;
+ result.result = "删除成功";
+ }
+ }
+ catch (System.Exception ex)
+ {
+ _db.RollbackTran();
+ result.IsSucceed = false;
+ result.Message = ex.Message;
+ }
+ _logs.WriteSysLogadd("菜单管理", "删除菜单信息", result,_db);
+ return result;
+ }
+ #endregion
+
+ #region 根据用户获取该用户菜单
+ ///
+ /// 根据当前用户获取该用户菜单
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetroleMenu")]
+ public async Task GetroleMenu()
+ {
+ var list = new List();
+ //获取父级菜单
+ var pidlist = await _db.Queryable().Where(q => q.IsDelete == 0).ToListAsync();
+ //联表查询该用户菜单
+ var menulist = await _db.Queryable().Where(q => q.roleuserId == _userdata.Id)
+ .LeftJoin((o, cus) => o.roleId == cus.roleId)
+ .LeftJoin((o, cus, menu) => o.roleId == cus.roleId)
+ .Where((o, cus, menu) => o.IsDeleted == 0 && cus.IsDeleted == 0 && menu.IsDelete == 0)
+ .Select((o, cus, menu) => menu)
+ .ToListAsync();
+ //通过分组父级菜单
+ var datalist = menulist.GroupBy(q => q.pid).Select(q => new { pid = q.Key, dalist = q.ToList() }).ToList();
+
+ datalist.ForEach(item =>
+ {
+ var data = pidlist.Where(q => q.Id == item.pid).First();
+ if (data != null)
+ {
+ var childrenlist = new List();
+ //添加子菜单
+ item.dalist.ForEach(it =>
+ {
+ childrenlist.Add(new
+ {
+ path = it.path,
+ name = it.name,
+ component = it.component,
+ //redirect = it.redirect,
+ meta = new
+ {
+ title = it.title,
+ //hideMenu = it.hideMenu,
+ //hideBreadcrumb = it.hideBreadcrumb,
+ //currentActiveMenu = it.currentActiveMenu,
+ icon = it.icon,
+ },
+ });
+ });
+
+ //添加父级菜单
+ list.Add(new
+ {
+ path = data.path,
+ name = data.name,
+ component = data.component,
+ //redirect = data.redirect,
+ meta = new
+ {
+ title = data.title,
+ //hideChildrenInMenu = data.hideChildrenInMenu,
+ icon = data.icon,
+ },
+ children = childrenlist
+ });
+ }
+ });
+
+ result.IsSucceed = true;
+ result.result = list;
+ return result;
+ }
+ #endregion
+ }
+}
diff --git a/24Hour/Elight.Entity.csproj.user b/24Hour/Elight.Entity.csproj.user
new file mode 100644
index 0000000..966b4ff
--- /dev/null
+++ b/24Hour/Elight.Entity.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ true
+
+
\ No newline at end of file
diff --git a/24Hour/Program.cs b/24Hour/Program.cs
new file mode 100644
index 0000000..de60b1e
--- /dev/null
+++ b/24Hour/Program.cs
@@ -0,0 +1,169 @@
+using Elight.Logic;
+using Elight.Utility;
+using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using Microsoft.IdentityModel.Tokens;
+using Microsoft.OpenApi.Models;
+using SqlSugar;
+using System.Data;
+using System.Text;
+
+#region builder
+
+var builder = WebApplication.CreateBuilder(args);
+
+var Configuration = builder.Configuration;
+
+// Add services to the container.
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen(c =>
+{
+ c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
+
+ //Jwt֤
+ c.AddSecurityRequirement(new OpenApiSecurityRequirement()
+ {
+ {
+ new OpenApiSecurityScheme
+ {
+ Reference = new OpenApiReference
+ {
+ Id = "Bearer",
+ Type = ReferenceType.SecurityScheme
+ }
+ },
+ new List()
+ }
+ });
+
+ c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
+ {
+ Description = "Value: Bearer {token}",
+ Name = "Authorization",
+ In = ParameterLocation.Header,
+ Type = SecuritySchemeType.ApiKey
+ });
+});
+// ֤
+builder.Services.AddAuthentication(options =>
+{
+ options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
+ options.DefaultChallengeScheme = nameof(ResponseAuthenticationHandler); //401
+ options.DefaultForbidScheme = nameof(ResponseAuthenticationHandler); //403
+})
+.AddJwtBearer(options =>
+{
+ // JWT֤ѡ
+ options.TokenValidationParameters = new TokenValidationParameters
+ {
+ ValidateIssuer = true,
+ ValidateAudience = true,
+ ValidateLifetime = true,
+ ValidateIssuerSigningKey = true,
+ ValidIssuer = Configuration.GetSection("JwtConfiguration:Issuer").Value,
+ ValidAudience = Configuration.GetSection("JwtConfiguration:Audience").Value,
+ IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetSection("JwtConfiguration:Jwtkey").Value)),
+ ClockSkew = TimeSpan.Zero
+ };
+
+ ////صжSignalR·(https://www.cnblogs.com/fger/p/11811190.html)
+ options.Events = new JwtBearerEvents
+ {
+ OnMessageReceived = (context) =>
+ {
+ if (!context.HttpContext.Request.Path.HasValue) return Task.CompletedTask;
+ //صжSignalR·
+ var accessToken = context.HttpContext.Request.Query["access_token"];
+ var path = context.HttpContext.Request.Path;
+ if (string.IsNullOrWhiteSpace(accessToken) || !path.StartsWithSegments("/ws")) return Task.CompletedTask;
+
+ context.Token = accessToken;
+ return Task.CompletedTask;
+ },
+
+ //˴ΪȨ֤ʧܺ¼
+ OnChallenge = context =>
+ {
+ //˴Ϊֹ.Net CoreĬϵķͺݽҪŶ
+ context.HandleResponse();
+ //ԶԼҪصݽҪصJsonͨNewtonsoft.Jsonת
+ var payload = new { StatusCode = 0, Message = "֤ʧܣ" };
+ //Զ巵ص
+ context.Response.ContentType = "application/json";
+ //Զ巵״̬룬ĬΪ401 ij 200
+ context.Response.StatusCode = StatusCodes.Status200OK;
+ //context.Response.StatusCode = StatusCodes.Status401Unauthorized;
+ //Jsonݽ
+ context.Response.WriteAsync(Convert.ToString(payload));
+ return Task.FromResult(0);
+ }
+ };
+
+}).AddScheme(nameof(ResponseAuthenticationHandler), o => { });
+
+builder.Services.AddAuthorization();
+builder.Services.AddHttpContextAccessor();
+builder.Services.TryAddSingleton(); //jwt
+builder.Services.TryAddSingleton(); //WriteSysLog
+builder.Services.AddScoped(sp =>
+{
+ var connectionString = Configuration.GetSection("ConnectionStrings:MySQLConnString").Value;
+ var db = new SqlSugarClient(new ConnectionConfig
+ {
+ ConnectionString = connectionString,
+ DbType = SqlSugar.DbType.MySql,
+ IsAutoCloseConnection = true,
+ InitKeyType = InitKeyType.Attribute
+ });
+ return db;
+});
+
+
+
+#endregion
+
+#region APP
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.UseHttpsRedirection();
+//·
+app.UseRouting();
+app.UseAuthentication(); // ֤м
+app.UseAuthorization(); // Ȩм
+//app.MapControllers();
+app.UseEndpoints(endpoints =>
+{
+ endpoints.MapControllers();
+});
+#region swagger
+app.UseSwagger();// Swaggerм
+app.UseSwaggerUI(c =>
+{
+ c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
+ c.RoutePrefix = string.Empty;
+});
+#endregion
+
+#region websockets
+app.UseWebSockets(new WebSocketOptions
+{
+ KeepAliveInterval = TimeSpan.FromMinutes(120)
+});
+//app.UseMiddleware();
+#endregion
+
+
+app.Run();
+#endregion
diff --git a/24Hour/Properties/launchSettings.json b/24Hour/Properties/launchSettings.json
new file mode 100644
index 0000000..a5e4ad0
--- /dev/null
+++ b/24Hour/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:54036",
+ "sslPort": 44381
+ }
+ },
+ "profiles": {
+ "_24Hour": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7246",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/24Hour/WeatherForecast.cs b/24Hour/WeatherForecast.cs
new file mode 100644
index 0000000..eab76a6
--- /dev/null
+++ b/24Hour/WeatherForecast.cs
@@ -0,0 +1,13 @@
+namespace _24Hour
+{
+ public class WeatherForecast
+ {
+ public DateTime Date { get; set; }
+
+ public int TemperatureC { get; set; }
+
+ public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
+
+ public string? Summary { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/24Hour/appsettings.Development.json b/24Hour/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/24Hour/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/24Hour/appsettings.json b/24Hour/appsettings.json
new file mode 100644
index 0000000..95caff8
--- /dev/null
+++ b/24Hour/appsettings.json
@@ -0,0 +1,32 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+ "ConnectionStrings": {
+ "DBType": "MySQL",
+ "MySQLConnString": "server=192.168.0.251;Database=equipmentrearend;Uid=root;Pwd=sa@admin;Allow User Variables=True;",
+ },
+ //JwtConfig
+ "JwtConfiguration": {
+ /*JwtConfig Issuer=http://127.0.0.1:api本地端口*/
+ //发行者
+ "Issuer": "https://127.0.0.1:7246",
+ /* JwtConfig Audience=http://127.0.0.1:api本地端口*/
+ //订阅者
+ "Audience": "https://127.0.0.1:7246",
+ //RefreshToken受众
+ "RefreshTokenAudience": null,
+ //加密Key
+ "Jwtkey": "ertJKl#521*a@790asD&1#",
+ //有效期(分钟) 120 = 24小时
+ "Expires": 1440,
+ //RefreshToken过期时间(分钟) 1440 = 1天
+ "RefreshTokenExpires": 1440,
+ //时间歪斜,单位秒
+ "ClockSkew": 1
+ }
+}
diff --git a/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230613/10.log b/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230613/10.log
new file mode 100644
index 0000000..f29ef04
--- /dev/null
+++ b/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230613/10.log
@@ -0,0 +1,12 @@
+日志时间:2023-06-13 10:49:46
+************************Exception Start********************************
+Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常
+Exception Date:2023/6/13 10:49:46
+Exception Type:MySqlConnector.MySqlException
+Exception Message:Unknown column 'SerialNumber' in 'field list'
+Exception Source:SqlSugar
+Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters)
+ at SqlSugar.InsertableProvider`1.ExecuteCommand()
+ at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in C:\Users\Administrator\Desktop\24Hour\Elight.Logic\WriteSysLog.cs:line 51
+************************Exception End************************************
+
diff --git a/Elight.Entity/AppMode/App_ReceptionModel.cs b/Elight.Entity/AppMode/App_ReceptionModel.cs
new file mode 100644
index 0000000..4b07a51
--- /dev/null
+++ b/Elight.Entity/AppMode/App_ReceptionModel.cs
@@ -0,0 +1,78 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Entity
+{
+ ///
+ /// 预约接待
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_reception")]
+ public class App_ReceptionModel
+ {
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string? Id { get; set; }
+
+ ///
+ /// 预约时间
+ ///
+ [DataMember]
+ public DateTime? receptiontime { get; set; }
+
+ ///
+ /// 部门
+ ///
+ [DataMember]
+ public string? depart { get; set; }
+
+ ///
+ /// 接待人
+ ///
+ [DataMember]
+ public string? receptionuser { get; set; }
+
+ ///
+ /// 事由
+ ///
+ [DataMember]
+ public string? matter { get; set; }
+
+ ///
+ /// 预约接待类型
+ ///
+ [DataMember]
+ public string? receptionId { get; set; }
+
+ ///
+ /// 0:代办,1已完成
+ ///
+ [DataMember]
+ public int state { get; set; }
+
+
+ [DataMember]
+ public string createusername { get; set; }
+
+ [DataMember]
+ public string createuserId { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除:0:未删除、1:删除
+ ///
+ [DataMember]
+ public int IsDelete { get; set; } = 0;
+ }
+}
diff --git a/Elight.Entity/AppMode/StagingModel.cs b/Elight.Entity/AppMode/StagingModel.cs
new file mode 100644
index 0000000..0fa2adb
--- /dev/null
+++ b/Elight.Entity/AppMode/StagingModel.cs
@@ -0,0 +1,72 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Entity
+{
+ ///
+ /// 工作台
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_staging")]
+ public class StagingModel
+ {
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 跳转地址
+ ///
+ [DataMember]
+ public string path { get; set; }
+
+ ///
+ /// 图标地址
+ ///
+ [DataMember]
+ public string icon { get; set; }
+
+ ///
+ /// 颜色
+ ///
+ [DataMember]
+ public string color { get; set; }
+
+ ///
+ /// 名称
+ ///
+ [DataMember]
+ public string title { get; set; }
+
+ ///
+ /// 类型
+ ///
+ [DataMember]
+ public string titletype { get; set; }
+
+
+ [DataMember]
+ public string username { get; set; }
+
+ [DataMember]
+ public string userId { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除:0:未删除、1:删除
+ ///
+ [DataMember]
+ public int IsDelete { get; set; } = 0;
+ }
+}
diff --git a/Elight.Entity/AppMode/StagingNumModel.cs b/Elight.Entity/AppMode/StagingNumModel.cs
new file mode 100644
index 0000000..74b58e1
--- /dev/null
+++ b/Elight.Entity/AppMode/StagingNumModel.cs
@@ -0,0 +1,54 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Entity
+{
+ ///
+ /// 工作台使用数据
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_staging_num")]
+ public class StagingNumModel
+ {
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 工作台Id
+ ///
+ [DataMember]
+ public string stagingId { get; set; }
+
+ ///
+ /// 使用数
+ ///
+ [DataMember]
+ public int num { get; set; }
+ [DataMember]
+ public string username { get; set; }
+ ///
+ /// 用户Id
+ ///
+ [DataMember]
+ public string userId { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除:0:未删除、1:删除
+ ///
+ [DataMember]
+ public int IsDelete { get; set; } = 0;
+ }
+}
diff --git a/Elight.Entity/Elight.Entity.csproj b/Elight.Entity/Elight.Entity.csproj
new file mode 100644
index 0000000..47da372
--- /dev/null
+++ b/Elight.Entity/Elight.Entity.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Elight.Entity/SystemModel/App_Sys_DepartModel.cs b/Elight.Entity/SystemModel/App_Sys_DepartModel.cs
new file mode 100644
index 0000000..94986fa
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_DepartModel.cs
@@ -0,0 +1,68 @@
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 部门信息
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_depart")]
+ public class App_Sys_DepartModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+ ///
+ /// 单位Id
+ ///
+ [DataMember]
+ public string unitId { get; set; }
+
+ ///
+ /// 部门编码
+ ///
+ [DataMember]
+ public string departCode { get; set; }
+ ///
+ /// 部门名称
+ ///
+ [DataMember]
+ public string departname { get; set; }
+
+ ///
+ /// 部门简称
+ ///
+ [DataMember]
+ public string departjc { get; set; }
+
+ ///
+ /// 是否删除 0否,1是
+ ///
+ [DataMember]
+ public int IsDelete { get; set; }
+
+ ///
+ /// 创建人Id
+ ///
+ [DataMember]
+ public string createuserId { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ [DataMember]
+ public string createusername { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? createtime { get; set; } = DateTime.Now;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/App_Sys_MenuModel.cs b/Elight.Entity/SystemModel/App_Sys_MenuModel.cs
new file mode 100644
index 0000000..70a78ea
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_MenuModel.cs
@@ -0,0 +1,113 @@
+
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 菜单管理
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_menu")]
+ public class App_Sys_MenuModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+ ///
+ /// 父级
+ ///
+ [DataMember]
+ public string pid { get; set; }
+
+ ///
+ /// 路径
+ ///
+ [DataMember]
+ public string path { get; set; }
+ ///
+ /// 菜单名称
+ ///
+ [DataMember]
+ public string name { get; set; }
+
+ ///
+ /// 页面组件路径
+ ///
+ [DataMember]
+ public string component { get; set; }
+
+ ///
+ /// 直接跳转路径
+ ///
+ [DataMember]
+ public string redirect { get; set; }
+
+ ///
+ /// 页面标题
+ ///
+ [DataMember]
+ public string title { get; set; }
+
+ ///
+ /// 是否隐藏子菜单
+ ///
+ [DataMember]
+ public bool hideChildrenInMenu { get; set; }
+
+ ///
+ /// 图标
+ ///
+ [DataMember]
+ public string icon { get; set; }
+ ///
+ /// 当前菜单在列表中显示时 激活的菜单
+ ///
+ [DataMember]
+ public bool currentActiveMenu { get; set; }
+ ///
+ /// 是否隐藏面包眉
+ ///
+ [DataMember]
+ public bool hideBreadcrumb { get; set; }
+ ///
+ /// 是否隐藏当前菜单
+ ///
+ [DataMember]
+ public bool hideMenu { get; set; }
+ ///
+ /// 排序
+ ///
+ [DataMember]
+ public int sortnum { get; set; }
+
+ ///
+ /// 是否删除 0否,1是
+ ///
+ [DataMember]
+ public int IsDelete { get; set; }
+
+ ///
+ /// 创建人Id
+ ///
+ [DataMember]
+ public string createuserId { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ [DataMember]
+ public string createusername { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? createtime { get; set; } = DateTime.Now;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs
new file mode 100644
index 0000000..8c27abf
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs
@@ -0,0 +1,60 @@
+
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 角色菜单表
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_rolemenu")]
+ public class App_Sys_RoleMenuModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 角色Id
+ ///
+ [DataMember]
+ public string roleId { get; set; }
+
+ ///
+ /// 菜单Id
+ ///
+ [DataMember]
+ public string menuId { get; set; }
+
+ ///
+ /// 用户Id
+ ///
+ [DataMember]
+ public string userId { get; set; }
+
+ ///
+ /// 用户名称
+ ///
+ [DataMember]
+ public string username { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除
+ ///
+ [DataMember]
+ public int IsDeleted { get; set; } = 0;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/App_Sys_RoleModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleModel.cs
new file mode 100644
index 0000000..a18aa59
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_RoleModel.cs
@@ -0,0 +1,60 @@
+
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 角色表
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_role")]
+ public class App_Sys_RoleModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+
+ ///
+ /// 角色名称
+ ///
+ [DataMember]
+ public string name { get; set; }
+
+ ///
+ /// 用户Id
+ ///
+ [DataMember]
+ public string userId { get; set; }
+
+ ///
+ /// 用户名称
+ ///
+ [DataMember]
+ public string username { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除
+ ///
+ [DataMember]
+ public int IsDeleted { get; set; } = 0;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs
new file mode 100644
index 0000000..dab3d77
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs
@@ -0,0 +1,60 @@
+
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 角色用户表
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_roleuser")]
+ public class App_Sys_RoleUserModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string roleId { get; set; }
+
+ ///
+ /// 角色用户Id
+ ///
+ [DataMember]
+ public string roleuserId { get; set; }
+
+ ///
+ /// 用户Id
+ ///
+ [DataMember]
+ public string userId { get; set; }
+
+ ///
+ /// 用户名称
+ ///
+ [DataMember]
+ public string username { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除
+ ///
+ [DataMember]
+ public int IsDeleted { get; set; } = 0;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/App_Sys_UnitModel.cs b/Elight.Entity/SystemModel/App_Sys_UnitModel.cs
new file mode 100644
index 0000000..48932eb
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_UnitModel.cs
@@ -0,0 +1,69 @@
+
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 单位信息
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_unit")]
+ public class App_Sys_UnitModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+ ///
+ /// 父级
+ ///
+ [DataMember]
+ public string pid { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+ ///
+ /// 单位名称
+ ///
+ [DataMember]
+ public string unitname { get; set; }
+
+ ///
+ /// 单位简称
+ ///
+ [DataMember]
+ public string unitjc { get; set; }
+
+ ///
+ /// 是否删除 0否,1是
+ ///
+ [DataMember]
+ public int IsDelete { get; set; }
+
+ ///
+ /// 创建人Id
+ ///
+ [DataMember]
+ public string createuserId { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ [DataMember]
+ public string createusername { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? createtime { get; set; } = DateTime.Now;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/App_Sys_UserModel.cs b/Elight.Entity/SystemModel/App_Sys_UserModel.cs
new file mode 100644
index 0000000..9eff059
--- /dev/null
+++ b/Elight.Entity/SystemModel/App_Sys_UserModel.cs
@@ -0,0 +1,138 @@
+
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Entity
+{
+ ///
+ /// 用户信息表(app_sys_user)
+ ///
+ [Serializable]
+ [DataContract]
+ [SugarTable("app_sys_user")]
+ public class App_Sys_UserModel
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+
+ ///
+ /// 部门
+ ///
+ [DataMember]
+ public string department { get; set; }
+
+ ///
+ /// 密码
+ ///
+ [DataMember]
+ public string Password { get; set; }
+
+ ///
+ /// 名称
+ ///
+ [DataMember]
+ public string name { get; set; }
+
+ ///
+ /// 职务
+ ///
+ [DataMember]
+ public string duties { get; set; }
+
+ ///
+ /// 电话号码
+ ///
+ [DataMember]
+ public string phone { get; set; }
+
+ ///
+ /// 身份证号码
+ ///
+ [DataMember]
+ public string cardId { get; set; }
+ ///
+ /// 身份(检察官,律师,当事人)
+ ///
+ [DataMember]
+ public string identity { get; set; }
+
+ ///
+ /// 微信Id
+ ///
+ [DataMember]
+ public string wechatId { get; set; }
+
+ ///
+ /// 账号类型0:系统,1:APP
+ ///
+ [DataMember]
+ public int usertype { get; set; }
+
+ ///
+ /// 是否停用 0:启用,1禁用
+ ///
+ [DataMember]
+ public int isdeactivate { get; set; }
+
+ ///
+ /// 是否App通用:0:通用,1:不通用
+ ///
+ [DataMember]
+ public int becurrent { get; set; }
+
+ ///
+ /// 头像地址
+ ///
+ [DataMember]
+ public string photo { get; set; }
+
+ ///
+ /// 性别 0:女 1:男
+ ///
+ [DataMember]
+ public int sex { get; set; }
+
+ ///
+ /// 是否删除
+ ///
+ [DataMember]
+ public int IsDeleted { get; set; } = 0;
+ ///
+ /// 审核状态
+ ///
+ [DataMember]
+ public int? audit { get; set; }
+ ///
+ /// 审核描述
+ ///
+ [DataMember]
+ public string describe { get; set; }
+ ///
+ /// 创建人Id
+ ///
+ [DataMember]
+ public string createuserId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [DataMember]
+ public string createusername { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? createtime { get; set; } = DateTime.Now;
+ }
+}
+
diff --git a/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs b/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs
new file mode 100644
index 0000000..b2ae09b
--- /dev/null
+++ b/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs
@@ -0,0 +1,107 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Entity.SystemModel
+{
+ ///
+ /// 日志记录表(Func_Dossier_LogRecord)
+ ///
+ [DataContract]
+ [Serializable]
+ [SugarTable("app_sys_depart")]
+ public class Func_Dossier_LogRecordModel
+ {
+
+ ///
+ /// 序号
+ ///
+ [DataMember]
+ public string SerialNumber { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string UnitCode { get; set; }
+
+ ///
+ /// 单位名称
+ ///
+ [DataMember]
+ public string NameEntity { get; set; }
+
+ ///
+ /// 部门编码
+ ///
+ [DataMember]
+ public string DepartmentCode { get; set; }
+
+ ///
+ /// 部门名称
+ ///
+ [DataMember]
+ public string DepartmentName { get; set; }
+
+ ///
+ /// 操作人工号
+ ///
+ [DataMember]
+ public string OperatingManual { get; set; }
+
+ ///
+ /// 操作人
+ ///
+ [DataMember]
+ public string Operation { get; set; }
+
+ ///
+ /// 操作时间
+ ///
+ [DataMember]
+ public string OperatingTime { get; set; }
+
+ ///
+ /// 操作IP
+ ///
+ [DataMember]
+ public string OperationIp { get; set; }
+
+ ///
+ /// 操作类型
+ ///
+ [DataMember]
+ public string OperationType { get; set; }
+
+ ///
+ /// 日志内容
+ ///
+ [DataMember]
+ public string LogContents { get; set; }
+
+ ///
+ /// 操作案件部门受案号
+ ///
+ [DataMember]
+ public string OpeCasDepAccCas { get; set; }
+
+ ///
+ /// 分区列 创建时间取年份,触发器完成
+ ///
+ [DataMember]
+ public string ParColCreTimTakYeaTri { get; set; }
+
+ ///
+ /// 是否删除
+ ///
+ [DataMember]
+ public int IsDeleted { get; set; }
+
+
+ /*CodeAutoBuilderArea*/
+ }
+}
diff --git a/Elight.Logic/CurrencyDelete.cs b/Elight.Logic/CurrencyDelete.cs
new file mode 100644
index 0000000..f64eaa9
--- /dev/null
+++ b/Elight.Logic/CurrencyDelete.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Logic
+{
+ ///
+ /// 通用id删除
+ ///
+ [Serializable]
+ [DataContract]
+ public class CurrencyDelete
+ {
+ ///
+ /// Id
+ ///
+ [DataMember]
+ public string tyId { get; set; }
+ ///
+ /// 集合Id
+ ///
+ [DataMember]
+ public List id { get; set; }
+ }
+}
diff --git a/Elight.Logic/Elight.Logic.csproj b/Elight.Logic/Elight.Logic.csproj
new file mode 100644
index 0000000..6068d1a
--- /dev/null
+++ b/Elight.Logic/Elight.Logic.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Elight.Logic/Model/App_ReceptionInput.cs b/Elight.Logic/Model/App_ReceptionInput.cs
new file mode 100644
index 0000000..feba82a
--- /dev/null
+++ b/Elight.Logic/Model/App_ReceptionInput.cs
@@ -0,0 +1,68 @@
+using Elight.Utility.Code;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Logic
+{
+ ///
+ /// 预约接待--分页
+ ///
+ [DataContract]
+ public class App_ReceptionInput : Paging
+ {
+ [DataMember]
+ public string Id { get; set; }
+
+ ///
+ /// 预约时间
+ ///
+ [DataMember]
+ public DateTime? receptiontime { get; set; }
+
+ ///
+ /// 部门
+ ///
+ [DataMember]
+ public string depart { get; set; }
+
+ ///
+ /// 接待人
+ ///
+ [DataMember]
+ public string receptionuser { get; set; }
+
+ ///
+ /// 事由
+ ///
+ [DataMember]
+ public string matter { get; set; }
+
+ ///
+ /// 预约接待类型
+ ///
+ [DataMember]
+ public string receptionId { get; set; }
+
+ ///
+ /// 0:代办,1已完成
+ ///
+ [DataMember]
+ public int? state { get; set; }
+
+ ///
+ /// 创建人名称
+ ///
+ [DataMember]
+ public string createusername { get; set; }
+
+ ///
+ /// 创建人Id
+ ///
+ [DataMember]
+ public string createuserId { get; set; }
+ }
+}
diff --git a/Elight.Logic/Model/StagingInput.cs b/Elight.Logic/Model/StagingInput.cs
new file mode 100644
index 0000000..c3cfeec
--- /dev/null
+++ b/Elight.Logic/Model/StagingInput.cs
@@ -0,0 +1,52 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Logic
+{
+ ///
+ /// 工作台
+ ///
+ [Serializable]
+ [DataContract]
+ public class StagingInput:Paging
+ {
+ [DataMember]
+ public string Id { get; set; }
+
+ ///
+ /// 跳转地址
+ ///
+ [DataMember]
+ public string path { get; set; }
+
+ ///
+ /// 图标地址
+ ///
+ [DataMember]
+ public string icon { get; set; }
+
+ ///
+ /// 颜色
+ ///
+ [DataMember]
+ public string color { get; set; }
+
+ ///
+ /// 名称
+ ///
+ [DataMember]
+ public string title { get; set; }
+
+ ///
+ /// 类型
+ ///
+ [DataMember]
+ public string titletype { get; set; }
+ }
+}
diff --git a/Elight.Logic/Model/StagingNumInput.cs b/Elight.Logic/Model/StagingNumInput.cs
new file mode 100644
index 0000000..dfe412e
--- /dev/null
+++ b/Elight.Logic/Model/StagingNumInput.cs
@@ -0,0 +1,53 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Logic
+{
+ ///
+ /// 工作台使用数据
+ ///
+ [Serializable]
+ [DataContract]
+ public class StagingNumInput
+ {
+ [DataMember]
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ /// 工作台Id
+ ///
+ [DataMember]
+ public string stagingId { get; set; }
+
+ ///
+ /// 使用数
+ ///
+ [DataMember]
+ public string num { get; set; }
+ [DataMember]
+ public string username { get; set; }
+ ///
+ /// 用户Id
+ ///
+ [DataMember]
+ public int userId { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ [DataMember]
+ public DateTime? creationtime { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否删除:0:未删除、1:删除
+ ///
+ [DataMember]
+ public int IsDelete { get; set; } = 0;
+ }
+}
diff --git a/Elight.Logic/SystemModel/App_Sys_DepartInput.cs b/Elight.Logic/SystemModel/App_Sys_DepartInput.cs
new file mode 100644
index 0000000..3ffebf8
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_DepartInput.cs
@@ -0,0 +1,43 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 部门信息--分页
+ ///
+ [DataContract]
+ public class App_Sys_DepartInput : Paging
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ public string Id { get; set; }
+ ///
+ /// 单位Id
+ ///
+ [DataMember]
+ public string unitId { get; set; }
+
+ ///
+ /// 部门编码
+ ///
+ [DataMember]
+ public string departCode { get; set; }
+ ///
+ /// 部门名称
+ ///
+ [DataMember]
+ public string departname { get; set; }
+
+ ///
+ /// 部门简称
+ ///
+ [DataMember]
+ public string departjc { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_MenuInput.cs b/Elight.Logic/SystemModel/App_Sys_MenuInput.cs
new file mode 100644
index 0000000..a0f3e68
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_MenuInput.cs
@@ -0,0 +1,87 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 菜单管理
+ ///
+ [DataContract]
+ public class App_Sys_MenuInput:Paging
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ public string Id { get; set; }
+ ///
+ /// 父级
+ ///
+ [DataMember]
+ public string pid { get; set; }
+
+ ///
+ /// 路径
+ ///
+ [DataMember]
+ public string path { get; set; }
+ ///
+ /// 菜单名称
+ ///
+ [DataMember]
+ public string name { get; set; }
+
+ ///
+ /// 页面组件路径
+ ///
+ [DataMember]
+ public string component { get; set; }
+
+ ///
+ /// 直接跳转路径
+ ///
+ [DataMember]
+ public string redirect { get; set; }
+
+ ///
+ /// 页面标题
+ ///
+ [DataMember]
+ public string title { get; set; }
+
+ ///
+ /// 是否隐藏子菜单
+ ///
+ [DataMember]
+ public bool hideChildrenInMenu { get; set; }
+
+ ///
+ /// 图标
+ ///
+ [DataMember]
+ public string icon { get; set; }
+ ///
+ /// 当前菜单在列表中显示时 激活的菜单
+ ///
+ [DataMember]
+ public bool currentActiveMenu { get; set; }
+ ///
+ /// 是否隐藏面包眉
+ ///
+ [DataMember]
+ public bool hideBreadcrum { get; set; }
+ ///
+ /// 是否隐藏当前菜单
+ ///
+ [DataMember]
+ public bool hideMenu { get; set; }
+ ///
+ /// 排序
+ ///
+ [DataMember]
+ public int sortnum { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_RoleInput.cs b/Elight.Logic/SystemModel/App_Sys_RoleInput.cs
new file mode 100644
index 0000000..fdd232d
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_RoleInput.cs
@@ -0,0 +1,34 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 角色表
+ ///
+ [Serializable]
+ [DataContract]
+ public class App_Sys_RoleInput: Paging
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ public string Id { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+
+ ///
+ /// 角色名称
+ ///
+ [DataMember]
+ public string name { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_RoleMenuInput.cs b/Elight.Logic/SystemModel/App_Sys_RoleMenuInput.cs
new file mode 100644
index 0000000..d772d29
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_RoleMenuInput.cs
@@ -0,0 +1,31 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 角色菜单表
+ ///
+ [Serializable]
+ [DataContract]
+ public class App_Sys_RoleMenuInput : Paging
+ {
+ [DataMember]
+ public string Id { get; set; }
+
+ ///
+ /// 角色Id
+ ///
+ [DataMember]
+ public string roleId { get; set; }
+
+ ///
+ /// 菜单Id
+ ///
+ [DataMember]
+ public string menuId { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_RoleUserInput.cs b/Elight.Logic/SystemModel/App_Sys_RoleUserInput.cs
new file mode 100644
index 0000000..f86e17e
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_RoleUserInput.cs
@@ -0,0 +1,34 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 角色用户表
+ ///
+ [DataContract]
+ public class App_Sys_RoleUserInput : Paging
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ public string Id { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string roleId { get; set; }
+
+ ///
+ /// 角色用户Id
+ ///
+ [DataMember]
+ public string roleuserId { get; set; }
+
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_UnitInput.cs b/Elight.Logic/SystemModel/App_Sys_UnitInput.cs
new file mode 100644
index 0000000..c76f415
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_UnitInput.cs
@@ -0,0 +1,43 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 单位信息--分页
+ ///
+ [DataContract]
+ public class App_Sys_UnitInput : Paging
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ public string Id { get; set; }
+ ///
+ /// 父级
+ ///
+ [DataMember]
+ public string pid { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+ ///
+ /// 单位名称
+ ///
+ [DataMember]
+ public string unitname { get; set; }
+
+ ///
+ /// 单位简称
+ ///
+ [DataMember]
+ public string unitjc { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_UnitTree.cs b/Elight.Logic/SystemModel/App_Sys_UnitTree.cs
new file mode 100644
index 0000000..d608967
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_UnitTree.cs
@@ -0,0 +1,73 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 单位信息--树型查询
+ ///
+ [DataContract]
+ [SugarTable("app_sys_unit")]
+ public class App_Sys_UnitTree
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [SqlSugar.SugarColumn(IsPrimaryKey = true)]
+ [DataMember]
+ public string Id { get; set; }
+ ///
+ /// 父级
+ ///
+ [DataMember]
+ public string pid { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+ ///
+ /// 单位名称
+ ///
+ [DataMember]
+ public string unitname { get; set; }
+
+ ///
+ /// 单位简称
+ ///
+ [DataMember]
+ public string unitjc { get; set; }
+
+
+ ///
+ /// 是否删除 0否,1是
+ ///
+ [DataMember]
+ public int IsDelete { get; set; }
+
+ ///
+ /// 创建人Id
+ ///
+ [DataMember]
+ public string createuserId { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ [DataMember]
+ public string createusername { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [DataMember]
+ public DateTime? createtime { get; set; } = DateTime.Now;
+
+ [SqlSugar.SugarColumn(IsIgnore = true)]
+ public List Child { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/SystemModel/App_Sys_UserInput.cs b/Elight.Logic/SystemModel/App_Sys_UserInput.cs
new file mode 100644
index 0000000..6812e5d
--- /dev/null
+++ b/Elight.Logic/SystemModel/App_Sys_UserInput.cs
@@ -0,0 +1,105 @@
+using Elight.Utility.Code;
+using SqlSugar;
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Logic.SystemModel
+{
+ ///
+ /// 用户信息表
+ ///
+ [DataContract]
+ public class App_Sys_UserInput:Paging
+ {
+ ///
+ /// 表里用户唯一标识符,自增长Id
+ ///
+ [DataMember]
+ public string Id { get; set; }
+
+ ///
+ /// 单位编码
+ ///
+ [DataMember]
+ public string unitCode { get; set; }
+
+ ///
+ /// 部门
+ ///
+ [DataMember]
+ public string department { get; set; }
+
+ ///
+ /// 密码
+ ///
+ [DataMember]
+ public string Password { get; set; }
+
+ ///
+ /// 名称
+ ///
+ [DataMember]
+ public string name { get; set; }
+
+ ///
+ /// 职务
+ ///
+ [DataMember]
+ public string duties { get; set; }
+
+ ///
+ /// 电话号码
+ ///
+ [DataMember]
+ public string phone { get; set; }
+
+ ///
+ /// 身份
+ ///
+ [DataMember]
+ public string identity { get; set; }
+
+ ///
+ /// 身份证号码
+ ///
+ [DataMember]
+ public string cardId { get; set; }
+
+ ///
+ /// 微信Id
+ ///
+ [DataMember]
+ public string wechatId { get; set; }
+
+ ///
+ /// 账号类型0:系统,1:APP
+ ///
+ [DataMember]
+ public int? usertype { get; set; }
+
+ ///
+ /// 是否停用 0:启用,1禁用
+ ///
+ [DataMember]
+ public int? isdeactivate { get; set; }
+
+ ///
+ /// 是否App通用:0:通用,1:不通用
+ ///
+ [DataMember]
+ public int? becurrent { get; set; }
+
+ ///
+ /// 头像地址
+ ///
+ [DataMember]
+ public string photo { get; set; }
+
+ ///
+ /// 性别 0:女 1:男
+ ///
+ [DataMember]
+ public int? sex { get; set; }
+ }
+}
+
diff --git a/Elight.Logic/WriteSysLog.cs b/Elight.Logic/WriteSysLog.cs
new file mode 100644
index 0000000..8c1b01e
--- /dev/null
+++ b/Elight.Logic/WriteSysLog.cs
@@ -0,0 +1,59 @@
+using Elight.Entity;
+using Elight.Entity.SystemModel;
+using Elight.Utility;
+using Elight.Utility.Code;
+using Elight.Utility.logs;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+using SqlSugar;
+using sun.nio.ch;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Logic
+{
+ public class WriteSysLog
+ {
+ App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户
+ Result ret = new Result();
+ public WriteSysLog(User user)
+ {
+ _userdata = user.Userdata();
+ }
+
+ ///
+ /// 添加数据库日志信息
+ ///
+ ///
+ public void WriteSysLogadd(string operationType, string content, Result result, SqlSugarClient _db=null, string opeCasDepAccCas = null)
+ {
+ try
+ {
+ Func_Dossier_LogRecordModel model = new Func_Dossier_LogRecordModel
+ {
+ UnitCode = _userdata.unitCode,
+ OperationType = operationType,
+ NameEntity = "",
+ LogContents = result.IsSucceed ? $"{content}成功" : $"{content}失败:{result.Message}",
+ ParColCreTimTakYeaTri = DateTime.Now.Year.ToString(),
+ OperationIp = "",
+ Operation = _userdata.name,
+ OperatingTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ OperatingManual = _userdata.Id,
+ OpeCasDepAccCas = opeCasDepAccCas ?? string.Empty
+ };
+ var sss= _db.Insertable(model).ExecuteCommand();
+ }
+ catch (Exception ex)
+ {
+ LogService.WriteLog(ex, "添加数据库日志信息_WriteSysLog_1 发生异常");
+ }
+ }
+ }
+}
diff --git a/Elight.Utility/BasicAuthenticationHandler.cs b/Elight.Utility/BasicAuthenticationHandler.cs
new file mode 100644
index 0000000..413cb98
--- /dev/null
+++ b/Elight.Utility/BasicAuthenticationHandler.cs
@@ -0,0 +1,101 @@
+using Elight.Utility.Enum;
+using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using System.ComponentModel;
+using System.Net.Http.Headers;
+using System.Security.Claims;
+using System.Text;
+using System.Text.Encodings.Web;
+
+namespace Elight.Utility
+{ ///
+ /// 响应认证处理器
+ ///
+ /// Author:mxg
+ /// CreatedTimed:2022-05-15 10:08 PM
+ public class ResponseAuthenticationHandler : AuthenticationHandler
+ {
+ #region Identity
+
+ public ResponseAuthenticationHandler(IOptionsMonitor options,
+ ILoggerFactory logger,
+ UrlEncoder encoder,
+ ISystemClock clock
+ ) : base(options, logger, encoder, clock)
+ {
+ }
+
+ #endregion Identity
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Task HandleAuthenticateAsync() => throw new NotImplementedException();
+
+ ///
+ /// HandleChallengeAsync
+ ///
+ ///
+ ///
+ protected override async Task HandleChallengeAsync(AuthenticationProperties properties)
+ {
+ Response.ContentType = "application/json";
+ Response.StatusCode = StatusCodes.Status401Unauthorized;
+ await Response.WriteAsync(JsonConvert.SerializeObject(
+ new ResponseStatusData
+ {
+ Code = CustomizedStatusCodeEnum.Status401Unauthorized,
+ Msg = CustomizedStatusCodeEnum.Status401Unauthorized.ToDescription()
+ },
+ new JsonSerializerSettings()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver()
+ }
+ ));
+ }
+ ///
+ /// HandleForbiddenAsync
+ ///
+ ///
+ ///
+ protected override async Task HandleForbiddenAsync(AuthenticationProperties properties)
+ {
+ Response.ContentType = "application/json";
+ Response.StatusCode = StatusCodes.Status403Forbidden;
+ await Response.WriteAsync(JsonConvert.SerializeObject(
+ new ResponseStatusData
+ {
+ Code = CustomizedStatusCodeEnum.Status403Forbidden,
+ Msg = CustomizedStatusCodeEnum.Status403Forbidden.ToDescription()
+ },
+ new JsonSerializerSettings()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver()
+ }
+ ));
+ }
+ }
+
+ ///
+ ///
+ ///
+ public class ResponseStatusData
+ {
+ ///
+ /// 状态码枚举 (0:操作失败 1:操作成功 401:未登录 403:权限不足 404:资源不存在 500:系统内部错误)
+ ///
+ ///
+ public CustomizedStatusCodeEnum Code { get; set; } = CustomizedStatusCodeEnum.Status1Ok;
+
+ ///
+ ///
+ ///
+ public string? Msg { get; set; }
+ }
+}
diff --git a/Elight.Utility/Elight.Utility.csproj b/Elight.Utility/Elight.Utility.csproj
new file mode 100644
index 0000000..b491c85
--- /dev/null
+++ b/Elight.Utility/Elight.Utility.csproj
@@ -0,0 +1,21 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Elight.Utility/Encrypt/AES.cs b/Elight.Utility/Encrypt/AES.cs
new file mode 100644
index 0000000..0e21edb
--- /dev/null
+++ b/Elight.Utility/Encrypt/AES.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Elight.Utility.Encrypt
+{
+ ///
+ /// AES
+ ///
+ public class AES
+ {
+ ///
+ /// 加密
+ ///
+ /// 数据字符
+ /// 密文
+ public static string Encrypt(string toEncrypt)
+ {
+ byte[] keyArray = Encoding.UTF8.GetBytes("12345678901234567890123456789012");
+ byte[] toEncryptArray = Encoding.UTF8.GetBytes(toEncrypt);
+
+ RijndaelManaged rDel = new RijndaelManaged
+ {
+ Key = keyArray,
+ Mode = CipherMode.ECB,
+ Padding = PaddingMode.PKCS7
+ };
+
+ ICryptoTransform cTransform = rDel.CreateEncryptor();
+ byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
+
+ return Convert.ToBase64String(resultArray, 0, resultArray.Length);
+ }
+
+ ///
+ /// 解密
+ ///
+ /// 密文
+ /// 结果
+ public static string Decrypt(string toDecrypt)
+ {
+ byte[] keyArray = Encoding.UTF8.GetBytes("12345678901234567890123456789012");
+ byte[] toEncryptArray = Convert.FromBase64String(toDecrypt);
+
+ RijndaelManaged rDel = new RijndaelManaged
+ {
+ Key = keyArray,
+ Mode = CipherMode.ECB,
+ Padding = PaddingMode.PKCS7
+ };
+
+ ICryptoTransform cTransform = rDel.CreateDecryptor();
+ byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
+
+ return Encoding.UTF8.GetString(resultArray);
+ }
+ }
+}
diff --git a/Elight.Utility/Encrypt/Md5.cs b/Elight.Utility/Encrypt/Md5.cs
new file mode 100644
index 0000000..baf81af
--- /dev/null
+++ b/Elight.Utility/Encrypt/Md5.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Security.Cryptography;
+using System.Text;
+namespace Elight.Utility.Encrypt
+{///
+ /// Md5
+ ///
+ public class Md5
+ {
+ ///
+ /// 加密32
+ ///
+ /// 数据
+ /// 密文
+ public static string Encrypt32(string source)
+ {
+ MD5 md5 = new MD5CryptoServiceProvider();
+ byte[] t = md5.ComputeHash(Encoding.UTF8.GetBytes(source));
+ StringBuilder sb = new StringBuilder(32);
+ foreach (byte item in t)
+ {
+ sb.Append(item.ToString("x").PadLeft(2, '0'));
+ }
+ return sb.ToString();
+ }
+
+ ///
+ /// 加密16
+ ///
+ /// 数据
+ /// 密文
+ public static string Encrypt16(string source)
+ {
+ MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
+ string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(source)), 4, 8);
+ t2 = t2.Replace("-", "");
+ return t2;
+ }
+
+
+ ///
+ /// MD5 加密字符串
+ ///
+ /// 源字符串
+ /// 加密后字符串
+ public static string MD5Encoding(string rawPass)
+ {
+ // 创建MD5类的默认实例:MD5CryptoServiceProvider
+ MD5 md5 = MD5.Create();
+ byte[] bs = Encoding.UTF8.GetBytes(rawPass);
+ byte[] hs = md5.ComputeHash(bs);
+ StringBuilder sb = new StringBuilder();
+ foreach (byte b in hs)
+ {
+ // 以十六进制格式格式化
+ sb.Append(b.ToString("x2"));
+ }
+ return sb.ToString();
+ }
+
+ ///
+ /// MD5盐值加密
+ ///
+ /// 源字符串
+ /// 盐值
+ /// 加密后字符串
+ public static string MD5Encoding(string rawPass, object salt)
+ {
+ if (salt == null) return rawPass;
+ return MD5Encoding(rawPass + "{" + salt.ToString() + "}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Elight.Utility/Enum/CustomizedStatusCodeEnum.cs b/Elight.Utility/Enum/CustomizedStatusCodeEnum.cs
new file mode 100644
index 0000000..b46f445
--- /dev/null
+++ b/Elight.Utility/Enum/CustomizedStatusCodeEnum.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility.Enum
+{
+ ///
+ /// 状态码枚举 (0:操作失败 1:操作成功 401:未登录 403:权限不足 404:资源不存在 500:系统内部错误)
+ ///
+ /// Author:mxg
+ /// CreatedTimed:2022-05-15 10:31 PM
+ public enum CustomizedStatusCodeEnum
+ {
+ ///
+ /// 操作失败
+ ///
+ [Description("操作失败")]
+ Status0NotOk = 0,
+
+ ///
+ /// 操作成功
+ ///
+ [Description("操作成功")]
+ Status1Ok = 1,
+
+ ///
+ /// 未登录(需要重新登录)
+ ///
+ [Description("未登录")]
+ Status401Unauthorized = 401,
+
+ ///
+ /// 权限不足
+ ///
+ [Description("权限不足")]
+ Status403Forbidden = 403,
+
+ ///
+ /// 资源不存在
+ ///
+ [Description("资源不存在")]
+ Status404NotFound = 404,
+
+ ///
+ /// 系统内部错误(非业务代码里显式抛出的异常,例如由于数据不正确导致空指针异常、数据库异常等等)
+ ///
+ [Description("系统内部错误")]
+ Status500InternalServerError = 500
+ }
+}
diff --git a/Elight.Utility/Enum/EnumExtension.cs b/Elight.Utility/Enum/EnumExtension.cs
new file mode 100644
index 0000000..a90ca11
--- /dev/null
+++ b/Elight.Utility/Enum/EnumExtension.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility.Enum
+{
+ ///
+ ///
+ ///
+ /// Author:mxg
+ /// CreatedTimed:2022-05-13 06:00 PM
+ public static class EnumExtension
+ {
+ public static string? ToDescription(this System.Enum item)
+ {
+ string? name = item.ToString();
+ var desc = item.GetType().GetField(name)?.GetCustomAttribute();
+ return desc?.Description ?? name;
+ }
+
+ public static long ToInt64(this System.Enum item)
+ {
+ return Convert.ToInt64(item);
+ }
+
+ public static List> ToList(this System.Enum value, bool ignoreNull = false)
+ {
+ var enumType = value.GetType();
+
+ if (!enumType.IsEnum)
+ return null;
+
+ return System.Enum.GetValues(enumType).Cast()
+ .Where(m => !ignoreNull || !m.ToString().Equals("Null")).Select(x => new Dictionary
+ {
+ ["Label"] = x.ToDescription(),
+ ["Value"] = x
+ }).ToList();
+ }
+
+ public static List> ToList(bool ignoreNull = false)
+ {
+ var enumType = typeof(T);
+
+ if (!enumType.IsEnum)
+ return null;
+
+ return System.Enum.GetValues(enumType).Cast()
+ .Where(m => !ignoreNull || !m.ToString().Equals("Null")).Select(x => new Dictionary
+ {
+ ["Label"] = x.ToDescription(),
+ ["Value"] = x
+ }).ToList();
+ }
+ }
+}
diff --git a/Elight.Utility/Enum/LogLevel.cs b/Elight.Utility/Enum/LogLevel.cs
new file mode 100644
index 0000000..f97d49d
--- /dev/null
+++ b/Elight.Utility/Enum/LogLevel.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility.Enum
+{
+ ///
+ /// 系统日志等级,按照Syslog的标准,将日志等级分为八个等级
+ ///
+ [DataContract]
+ public enum LogLevel
+ {
+ ///
+ /// A系统不可用
+ ///
+ [EnumMember]
+ A系统不可用 = 0,
+
+ ///
+ /// B紧急事件
+ ///
+ [EnumMember]
+ B紧急事件 = 1,
+
+ ///
+ /// C关键事件
+ ///
+ [EnumMember]
+ C关键事件 = 2,
+
+ ///
+ /// D错误事件
+ ///
+ [EnumMember]
+ D错误事件 = 3,
+
+ ///
+ /// E警告事件
+ ///
+ [EnumMember]
+ E警告事件 = 4,
+
+ ///
+ /// F重要事件
+ ///
+ [EnumMember]
+ F重要事件 = 5,
+
+ ///
+ /// G有用信息
+ ///
+ [EnumMember]
+ G有用信息 = 6,
+
+ ///
+ /// H调试信息
+ ///
+ [EnumMember]
+ H调试信息 = 7
+ }
+}
diff --git a/Elight.Utility/Extensions/StringExtension.cs b/Elight.Utility/Extensions/StringExtension.cs
new file mode 100644
index 0000000..c08fab3
--- /dev/null
+++ b/Elight.Utility/Extensions/StringExtension.cs
@@ -0,0 +1,655 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace Elight.Utility.Extensions
+{
+ ///
+ ///
+ ///
+ /// Author:mxg
+ /// CreatedTimed:2022-05-13 06:00 PM
+ public static class StringExtension
+ {
+ ///
+ /// 判断字符串是否为Null、空
+ ///
+ ///
+ ///
+ public static bool IsNull(this string? s) => string.IsNullOrWhiteSpace(s);
+
+ ///
+ /// 判断字符串是否不为Null、空
+ ///
+ ///
+ ///
+ public static bool NotNull(this string? s) => !string.IsNullOrWhiteSpace(s);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool IsNotEmptyOrNull(this object? thisValue)
+ {
+ var val = thisValue as string;
+ return val != "" && val != "undefined" && val != "null";
+ }
+
+ ///
+ /// 与字符串进行比较,忽略大小写
+ ///
+ ///
+ ///
+ ///
+ public static bool EqualsIgnoreCase(this string s, string? value) => s.Equals(value, StringComparison.OrdinalIgnoreCase);
+
+ ///
+ /// 首字母转小写
+ ///
+ ///
+ ///
+ public static string FirstCharToLower(this string s)
+ {
+ if (string.IsNullOrEmpty(s)) return s;
+ string str = string.Concat(s.First().ToString().ToLower(), s.AsSpan(1));
+ return str;
+ }
+
+ ///
+ /// 首字母转大写
+ ///
+ ///
+ ///
+ public static string FirstCharToUpper(this string s)
+ {
+ if (string.IsNullOrEmpty(s)) return s;
+
+ string str = string.Concat(s.First().ToString().ToUpper(), s.AsSpan(1));
+ return str;
+ }
+
+ ///
+ /// 转为Base64,UTF-8格式
+ ///
+ ///
+ ///
+ public static string ToBase64(this string s) => s.ToBase64(Encoding.UTF8);
+
+ ///
+ /// 转为Base64
+ ///
+ ///
+ /// 编码
+ ///
+ public static string ToBase64(this string s, Encoding encoding)
+ {
+ if (s.IsNull()) return string.Empty;
+
+ var bytes = encoding.GetBytes(s);
+ if (bytes == null)
+ return null;
+ else
+ return Convert.ToBase64String(bytes);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string ToPath(this string s) => s.IsNull() ? string.Empty : s.Replace(@"\", "/");
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string Format(this string str, object obj)
+ {
+ if (str.IsNull()) return str;
+
+ string s = str;
+ if (obj.GetType().Name == "JObject")
+ {
+ foreach (var item in (Newtonsoft.Json.Linq.JObject)obj)
+ {
+ var k = item.Key.ToString();
+ string? v = item.Value?.ToString();
+ s = Regex.Replace(s, "\\{" + k + "\\}", v, RegexOptions.IgnoreCase);
+ }
+ }
+ else
+ {
+ foreach (System.Reflection.PropertyInfo p in obj.GetType().GetProperties())
+ {
+ var xx = p.Name;
+ var yy = p.GetValue(obj)?.ToString();
+ s = Regex.Replace(s, "\\{" + xx + "\\}", yy, RegexOptions.IgnoreCase);
+ }
+ }
+ return s;
+ }
+
+ #region IsXXXX
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool GetGuid(this string guid, out Guid outId) => Guid.TryParse(guid, out outId);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool IsGuid(this string guid) => GetGuid(guid, out _);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool IsInt(this object? obj)
+ {
+ if (obj == null) return false;
+ bool result = Int32.TryParse(obj.ToString(), out int number);
+ return result;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool IsDate(this object? str) => IsDate(str, out _);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool IsDate(this object? str, out DateTime dateTime)
+ {
+ dateTime = DateTime.Now;
+ if (str == null || str.ToString() == "") return false;
+ return DateTime.TryParse(str.ToString(), out dateTime);
+ }
+
+ ///
+ /// 根据传入格式判断是否为小数
+ ///
+ ///
+ /// 18,5
+ ///
+ public static bool IsNumber(this string str, string? formatString)
+ {
+ if (string.IsNullOrEmpty(str)) return false;
+ int precision = 32;
+ int scale = 5;
+ try
+ {
+ if (string.IsNullOrEmpty(formatString))
+ {
+ precision = 10;
+ scale = 2;
+ }
+ else
+ {
+ string[] numbers = formatString.Split(',');
+ precision = Convert.ToInt32(numbers[0]);
+ scale = numbers.Length == 0 ? 2 : Convert.ToInt32(numbers[1]);
+ }
+ }
+ catch
+ {
+ // ignored
+ }
+ return IsNumber(str, precision, scale);
+ }
+
+ ///
+ /// 判断一个字符串是否为合法数字(指定整数位数和小数位数)
+ ///
+ /// 字符串
+ /// 整数位数
+ /// 小数位数
+ ///
+ public static bool IsNumber(this string str, int precision, int scale)
+ {
+ if ((precision == 0) && (scale == 0)) return false;
+ string pattern = @"(^\d{1," + precision + "}";
+ if (scale > 0) pattern += @"\.\d{0," + scale + "}$)|" + pattern;
+ pattern += "$)";
+ return Regex.IsMatch(str, pattern);
+ }
+
+ #endregion IsXXXX
+
+ //
+ // Summary:
+ // Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1
+ // collection of type System.String, using the specified separator between each
+ // member. This is a shortcut for string.Join(...)
+ //
+ // Parameters:
+ // source:
+ // A collection that contains the strings to concatenate.
+ //
+ // separator:
+ // The string to use as a separator. separator is included in the returned string
+ // only if values has more than one element.
+ //
+ // Returns:
+ // A string that consists of the members of values delimited by the separator string.
+ // If values has no members, the method returns System.String.Empty.
+ public static string? JoinAsString(this IEnumerable source, string separator) => string.Join(separator, source);
+
+ //
+ // Summary:
+ // Concatenates the members of a collection, using the specified separator between
+ // each member. This is a shortcut for string.Join(...)
+ //
+ // Parameters:
+ // source:
+ // A collection that contains the objects to concatenate.
+ //
+ // separator:
+ // The string to use as a separator. separator is included in the returned string
+ // only if values has more than one element.
+ //
+ // Type parameters:
+ // T:
+ // The type of the members of values.
+ //
+ // Returns:
+ // A string that consists of the members of values delimited by the separator string.
+ // If values has no members, the method returns System.String.Empty.
+ public static string JoinAsString(this IEnumerable source, string separator) => string.Join(separator, source);
+
+ ///
+ /// A string extension method that query if '@this' is null or empty.
+ ///
+ /// The @this to act on.
+ /// true if null or empty, false if not.
+ public static bool IsNullOrEmpty(this string @this) => string.IsNullOrEmpty(@this);
+
+ ///
+ /// A string extension method that query if '@this' is not null and not empty.
+ ///
+ /// The @this to act on.
+ /// false if null or empty, true if not.
+ public static bool IsNotNullOrEmpty(this string? @this) => !string.IsNullOrEmpty(@this);
+
+ ///
+ /// A string extension method that query if '@this' is null or whiteSpace.
+ ///
+ /// The @this to act on.
+ /// true if null or whiteSpace, false if not.
+ public static bool IsNullOrWhiteSpace(this string? @this) => string.IsNullOrWhiteSpace(@this);
+
+ ///
+ /// A string extension method that query if '@this' is not null and not whiteSpace.
+ ///
+ /// The @this to act on.
+ /// false if null or whiteSpace, true if not.
+ public static bool IsNotNullOrWhiteSpace(this string? @this) => !string.IsNullOrWhiteSpace(@this);
+
+ ///
+ /// Concatenates the elements of an object array, using the specified separator between each element.
+ ///
+ ///
+ /// The string to use as a separator. is included in the returned string only if has more
+ /// than one element.
+ ///
+ /// An array that contains the elements to concatenate.
+ ///
+ /// A string that consists of the elements of delimited by the string. If is an empty array, the method
+ /// returns .
+ ///
+ public static string Join([NotNull] this string separator, IEnumerable values) => string.Join(separator, values);
+
+ ///
+ /// Indicates whether the specified regular expression finds a match in the specified input string.
+ ///
+ /// The string to search for a match.
+ /// The regular expression pattern to match.
+ /// true if the regular expression finds a match; otherwise, false.
+ public static bool IsMatch([NotNull] this string input, string pattern) => Regex.IsMatch(input, pattern);
+
+ ///
+ /// Indicates whether the specified regular expression finds a match in the specified input string, using the
+ /// specified matching options.
+ ///
+ /// The string to search for a match.
+ /// The regular expression pattern to match.
+ /// A bitwise combination of the enumeration values that provide options for matching.
+ /// true if the regular expression finds a match; otherwise, false.
+ public static bool IsMatch([NotNull] this string input, string pattern, RegexOptions options) => Regex.IsMatch(input, pattern, options);
+
+ /// An IEnumerable<string> extension method that concatenates the given this.
+ /// The @this to act on.
+ /// A string.
+ public static string Concatenate([NotNull] this IEnumerable @this)
+ {
+ var sb = new StringBuilder();
+
+ foreach (var s in @this)
+ {
+ sb.Append(s);
+ }
+
+ return sb.ToString();
+ }
+
+ /// An IEnumerable<T> extension method that concatenates.
+ /// Generic type parameter.
+ /// The source to act on.
+ /// The function.
+ /// A string.
+ public static string Concatenate([NotNull] this IEnumerable source, Func func)
+ {
+ var sb = new StringBuilder();
+ foreach (var item in source)
+ {
+ sb.Append(func(item));
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// A string extension method that query if this object contains the given value.
+ ///
+ /// The @this to act on.
+ /// The value.
+ /// true if the value is in the string, false if not.
+ public static bool Contains([NotNull] this string @this, string value) => @this.IndexOf(value, StringComparison.Ordinal) != -1;
+
+ ///
+ /// A string extension method that query if this object contains the given value.
+ ///
+ /// The @this to act on.
+ /// The value.
+ /// Type of the comparison.
+ /// true if the value is in the string, false if not.
+ public static bool Contains([NotNull] this string @this, string value, StringComparison comparisonType) => @this.IndexOf(value, comparisonType) != -1;
+
+ ///
+ /// A string extension method that extracts this object.
+ ///
+ /// The @this to act on.
+ /// The predicate.
+ /// A string.
+ public static string Extract([NotNull] this string @this, Func predicate) => new string(@this.ToCharArray().Where(predicate).ToArray());
+
+ ///
+ /// A string extension method that removes the letter.
+ ///
+ /// The @this to act on.
+ /// The predicate.
+ /// A string.
+ public static string RemoveWhere([NotNull] this string @this, Func predicate) => new string(@this.ToCharArray().Where(x => !predicate(x)).ToArray());
+
+ ///
+ /// Replaces the format item in a specified String with the text equivalent of the value of a corresponding
+ /// Object instance in a specified array.
+ ///
+ /// A String containing zero or more format items.
+ /// An Object array containing zero or more objects to format.
+ ///
+ /// A copy of format in which the format items have been replaced by the String equivalent of the corresponding
+ /// instances of Object in args.
+ ///
+ public static string FormatWith([NotNull] this string @this, params object[] values) => string.Format(@this, values);
+
+ ///
+ /// A string extension method that query if '@this' satisfy the specified pattern.
+ ///
+ /// The @this to act on.
+ /// The pattern to use. Use '*' as wildcard string.
+ /// true if '@this' satisfy the specified pattern, false if not.
+ public static bool IsLike([NotNull] this string @this, string pattern)
+ {
+ // Turn the pattern into regex pattern, and match the whole string with ^$
+ var regexPattern = "^" + Regex.Escape(pattern) + "$";
+
+ // Escape special character ?, #, *, [], and [!]
+ regexPattern = regexPattern.Replace(@"\[!", "[^")
+ .Replace(@"\[", "[")
+ .Replace(@"\]", "]")
+ .Replace(@"\?", ".")
+ .Replace(@"\*", ".*")
+ .Replace(@"\#", @"\d");
+
+ return Regex.IsMatch(@this, regexPattern);
+ }
+
+ ///
+ /// SafeSubstring
+ ///
+ ///
+ ///
+ ///
+ public static string SafeSubstring([NotNull] this string @this, int startIndex)
+ {
+ if (startIndex < 0 || startIndex > @this.Length)
+ {
+ return string.Empty;
+ }
+ return @this[startIndex..];
+ }
+
+ ///
+ /// SafeSubstring
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string SafeSubstring([NotNull] this string str, int startIndex, int length)
+ {
+ if (startIndex < 0 || startIndex >= str.Length || length < 0)
+ {
+ return string.Empty;
+ }
+ return str.Substring(startIndex, Math.Min(str.Length - startIndex, length));
+ }
+
+ ///
+ /// Sub, not only substring but support for negative numbers
+ ///
+ /// string to be handled
+ /// startIndex to substract
+ /// substring
+ public static string Sub([NotNull] this string @this, int startIndex)
+ {
+ if (startIndex >= 0)
+ {
+ return @this.SafeSubstring(startIndex);
+ }
+ if (Math.Abs(startIndex) > @this.Length)
+ {
+ return string.Empty;
+ }
+ return @this[(@this.Length + startIndex)..];
+ }
+
+ ///
+ /// A string extension method that repeats the string a specified number of times.
+ ///
+ /// The @this to act on.
+ /// Number of repeats.
+ /// The repeated string.
+ public static string Repeat([NotNull] this string @this, int repeatCount)
+ {
+ if (@this.Length == 1)
+ {
+ return new string(@this[0], repeatCount);
+ }
+
+ var sb = new StringBuilder(repeatCount * @this.Length);
+ while (repeatCount-- > 0)
+ {
+ sb.Append(@this);
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// A string extension method that reverses the given string.
+ ///
+ /// The @this to act on.
+ /// The string reversed.
+ public static string Reverse([NotNull] this string @this)
+ {
+ if (@this.Length <= 1)
+ {
+ return @this;
+ }
+
+ var chars = @this.ToCharArray();
+ Array.Reverse(chars);
+ return new string(chars);
+ }
+
+ ///
+ /// Returns a String array containing the substrings in this string that are delimited by elements of a specified
+ /// String array. A parameter specifies whether to return empty array elements.
+ ///
+ /// The @this to act on.
+ /// A string that delimit the substrings in this string.
+ ///
+ /// (Optional) Specify RemoveEmptyEntries to omit empty array elements from the array returned,
+ /// or None to include empty array elements in the array returned.
+ ///
+ ///
+ /// An array whose elements contain the substrings in this string that are delimited by the separator.
+ ///
+ public static string[] Split([NotNull] this string @this, string separator, StringSplitOptions option = StringSplitOptions.None) => @this.Split(new[] { separator }, option);
+
+ ///
+ /// A string extension method that converts the @this to a byte array.
+ ///
+ /// The @this to act on.
+ /// @this as a byte[].
+ public static byte[] ToByteArray([NotNull] this string @this) => Encoding.UTF8.GetBytes(@this);
+
+ ///
+ /// A string extension method that converts the @this to a byte array.
+ ///
+ /// The @this to act on.
+ /// encoding
+ /// @this as a byte[].
+ public static byte[] ToByteArray([NotNull] this string @this, Encoding encoding) => encoding.GetBytes(@this);
+
+ public static byte[] GetBytes([NotNull] this string str) => str.GetBytes(Encoding.UTF8);
+
+ public static byte[] GetBytes([NotNull] this string? str, Encoding encoding) => encoding.GetBytes(str);
+
+ ///
+ /// A string extension method that converts the @this to an enum.
+ ///
+ /// Generic type parameter.
+ /// The @this to act on.
+ /// @this as a T.
+ public static T ToEnum([NotNull] this string @this) => (T)System.Enum.Parse(typeof(T), @this);
+
+ ///
+ /// A string extension method that converts the @this to a title case.
+ ///
+ /// The @this to act on.
+ /// @this as a string.
+ public static string ToTitleCase([NotNull] this string @this) => new CultureInfo("en-US").TextInfo.ToTitleCase(@this);
+
+ ///
+ /// A string extension method that converts the @this to a title case.
+ ///
+ /// The @this to act on.
+ /// Information describing the culture.
+ /// @this as a string.
+ public static string ToTitleCase([NotNull] this string @this, CultureInfo cultureInfo) => cultureInfo.TextInfo.ToTitleCase(@this);
+
+ ///
+ /// A string extension method that truncates.
+ ///
+ /// The @this to act on.
+ /// The maximum length.
+ /// A string.
+ public static string Truncate(this string @this, int maxLength) => @this.Truncate(maxLength, "...");
+
+ ///
+ /// A string extension method that truncates.
+ ///
+ /// The @this to act on.
+ /// The maximum length.
+ /// The suffix.
+ /// A string.
+ public static string Truncate(this string @this, int maxLength, string suffix)
+ {
+ if (@this == null || @this.Length <= maxLength)
+ {
+ return @this;
+ }
+ return @this.Substring(0, maxLength - suffix.Length) + suffix;
+ }
+
+ ///
+ /// string=>long
+ ///
+ ///
+ ///
+ public static long? ToLong(this string? @this)
+ {
+ bool status = long.TryParse(@this, out long result);
+
+ if (status)
+ return result;
+ else
+ return null;
+ }
+
+ #region 处理Windows和Linux 系统下文件路径 处理方法
+
+ ///
+ /// 处理Windows和Linux 系统下文件路径
+ ///
+ ///
+ ///
+ public static string GetRuntimeDirectory(this string path)
+ {
+ if (IsLinuxRunTime()) return GetLinuxDirectory(path);
+ return IsWindowRunTime() ? GetWindowDirectory(path) : path;
+ }
+
+ public static bool IsWindowRunTime() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+
+ public static bool IsLinuxRunTime() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
+
+ private static string GetLinuxDirectory(string path)
+ {
+ var pathTemp = Path.Combine(path);
+ return pathTemp.Replace("\\", "/");
+ }
+
+ private static string GetWindowDirectory(string path)
+ {
+ var pathTemp = Path.Combine(path);
+ return pathTemp.Replace("/", "\\");
+ }
+
+ #endregion 处理Windows和Linux 系统下文件路径 处理方法
+ }
+}
diff --git a/Elight.Utility/Paging.cs b/Elight.Utility/Paging.cs
new file mode 100644
index 0000000..c979b6c
--- /dev/null
+++ b/Elight.Utility/Paging.cs
@@ -0,0 +1,166 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace Elight.Utility.Code
+{
+ ///
+ /// 分页类
+ ///
+ [Serializable]
+ [DataContract]
+ public class Paging
+ {
+ ///
+ /// 页码
+ ///
+ [DataMember]
+ private int pageIndex = 1;
+
+ ///
+ /// 页码
+ ///
+ [DataMember]
+ public int PageIndex
+ {
+ get
+ {
+ return this.pageIndex;
+ }
+
+ set
+ {
+ this.pageIndex = value;
+ }
+ }
+
+ ///
+ /// 页大小
+ ///
+ [DataMember]
+ private int pageSize = 10;
+
+ ///
+ /// 页大小(默认10页)
+ ///
+ [DataMember]
+ public int PageSize
+ {
+ get
+ {
+ return this.pageSize;
+ }
+
+ set
+ {
+ this.pageSize = value;
+ }
+ }
+
+ ///
+ /// 总条数
+ ///
+ [DataMember]
+ public int RowsCount { get; set; }
+
+ ///
+ /// 总页数
+ ///
+ [DataMember]
+ private int pageCount;
+
+ ///
+ /// 总页数
+ ///
+ [DataMember]
+ public int PageCount
+ {
+ get
+ {
+ if (PageSize == 0)
+ {
+ return 0;
+ }
+ this.pageCount = (this.RowsCount % this.PageSize) == 0
+ ? this.RowsCount / this.PageSize
+ : (this.RowsCount / this.PageSize) + 1;
+ return this.pageCount;
+ }
+
+ set
+ {
+ this.pageCount = value;
+ }
+ }
+
+ ///
+ /// 是否获取总条数
+ ///
+ [DataMember]
+ private bool getRowsCount = true;
+
+ ///
+ /// 排序名
+ ///
+ [DataMember]
+ public string SortName { get; set; }
+
+ ///
+ /// 排序方式
+ ///
+ [DataMember]
+ public string SortType { get; set; }
+
+ ///
+ /// 实名数量
+ ///
+ [DataMember]
+ public int RealNameCount { get; set; }
+
+ ///
+ /// 匿名数量
+ ///
+ [DataMember]
+ public int AnonymousCount { get; set; }
+
+
+ ///
+ /// 开始时间
+ ///
+ [DataMember]
+ public DateTime? StartTime { get; set; }
+
+
+ ///
+ /// 结束时间
+ ///
+ [DataMember]
+ public DateTime? EndTime { get; set; }
+
+ ///
+ /// 是否获取总条数
+ ///
+ [DataMember]
+ public bool GetRowsCount
+ {
+ get
+ {
+ return this.getRowsCount;
+ }
+
+ set
+ {
+ this.getRowsCount = value;
+ }
+ }
+
+ ///
+ /// 开始索引
+ ///
+ public int StratRows => PageSize * ((PageIndex <= 0 ? 1 : PageIndex) - 1) + 1;
+
+ ///
+ /// 开始索引
+ ///
+ public int EndRows => (PageIndex <= 0 ? 1 : PageIndex) * PageSize;
+ }
+}
\ No newline at end of file
diff --git a/Elight.Utility/QueryResult.cs b/Elight.Utility/QueryResult.cs
new file mode 100644
index 0000000..d12a3e5
--- /dev/null
+++ b/Elight.Utility/QueryResult.cs
@@ -0,0 +1,48 @@
+using Elight.Utility.Code;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility
+{
+ ///
+ /// The query result.
+ ///
+ ///
+ /// T
+ ///
+ [Serializable]
+ [DataContract]
+ public class QueryResult
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// The paging.
+ ///
+ ///
+ /// The data.
+ ///
+ public QueryResult(Paging paging, IList data)
+ {
+ this.Paging = paging;
+ this.Data = data;
+ }
+
+ ///
+ /// 分页信息
+ ///
+ [DataMember]
+ public Paging Paging { get; set; }
+
+ ///
+ /// 数据
+ ///
+ [DataMember]
+ public IList Data { get; set; }
+ }
+}
diff --git a/Elight.Utility/Result.cs b/Elight.Utility/Result.cs
new file mode 100644
index 0000000..95de0cc
--- /dev/null
+++ b/Elight.Utility/Result.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace Elight.Utility.Code
+{
+ ///
+ /// 消息
+ ///
+ [Serializable]
+ [DataContract]
+ public class Result
+ {
+ ///
+ /// 成功/失败
+ ///
+ [DataMember]
+ public bool IsSucceed { get; set; }
+
+ ///
+ /// 消息
+ ///
+ [DataMember]
+ public string Message { get; set; }
+ ///
+ /// 消息
+ ///
+ [DataMember]
+ public dynamic result { get; set; }
+ }
+
+ ///
+ /// 消息
+ ///
+ [Serializable]
+ [DataContract]
+ public class ResultData:Result
+ {
+ ///
+ /// 数据
+ ///
+ [DataMember]
+ public string Data { get; set; }
+ }
+
+ ///
+ /// 处理结果
+ ///
+ /// 扩展数据
+ [Serializable]
+ [DataContract]
+ public class Result : Result
+ {
+ ///
+ /// 扩展数据
+ ///
+ [DataMember]
+ public T Data { get; set; }
+ }
+}
diff --git a/Elight.Utility/TextWriter.cs b/Elight.Utility/TextWriter.cs
new file mode 100644
index 0000000..4c14a7a
--- /dev/null
+++ b/Elight.Utility/TextWriter.cs
@@ -0,0 +1,188 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility
+{
+ ///
+ /// 写入文本
+ ///
+ internal class TextWriter
+ {
+ ///
+ /// 写入文件路径
+ ///
+ private readonly string fileName;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public TextWriter()
+ : this(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"))
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// The file name.
+ ///
+ public TextWriter(string fileName)
+ {
+ this.fileName = fileName;
+ }
+
+ ///
+ /// 写入日志
+ ///
+ /// 内容
+ /// 结果
+ internal bool WriteLog(string logInfo)
+ {
+ if (string.IsNullOrWhiteSpace(logInfo))
+ {
+ return false;
+ }
+
+ DateTime timeStamp = DateTime.Now;
+ string path = this.GetFileMainPath(timeStamp);
+ FileInfo lastFile = GetLastAccessFile(path, timeStamp);
+ FileStream fileStream = GetFileStream(lastFile, path, timeStamp);
+ if (fileStream == null)
+ {
+ return false;
+ }
+
+ try
+ {
+ StreamWriter sw = new StreamWriter(fileStream);
+ sw.BaseStream.Seek(0, SeekOrigin.End);
+ sw.Write(logInfo);
+ sw.Flush();
+ sw.Close();
+ return true;
+ }
+ finally
+ {
+ fileStream.Close();
+ fileStream.Dispose();
+ }
+ }
+
+ ///
+ /// 获取文件路径
+ ///
+ /// timeStamp
+ /// path
+ private string GetFileMainPath(DateTime timeStamp)
+ {
+ return Path.Combine(this.fileName, timeStamp.ToString("yyyyMMdd"));
+ }
+
+ ///
+ /// 获取最后写入日志的文件
+ ///
+ /// 路径
+ /// timeStamp
+ /// FileInfo
+ private static FileInfo GetLastAccessFile(string path, DateTime timeStamp)
+ {
+ FileInfo result = null;
+ DirectoryInfo directoryInfo = new DirectoryInfo(path);
+ if (directoryInfo.Exists)
+ {
+ FileInfo[] fileInfos = directoryInfo.GetFiles();
+ foreach (FileInfo fileInfo in fileInfos)
+ {
+ if (timeStamp.Hour == fileInfo.CreationTime.Hour)
+ {
+ result = fileInfo;
+ break;
+ }
+ }
+ }
+ else
+ {
+ directoryInfo.Create();
+ }
+
+ return result;
+ }
+
+ ///
+ /// 获取文件流
+ ///
+ /// lastFile
+ /// path
+ /// timeStamp
+ /// FileStream
+ private static FileStream GetFileStream(FileInfo fileInfo, string path, DateTime timeStamp)
+ {
+ FileStream result;
+ if (fileInfo == null)
+ {
+ try
+ {
+ result = CreateFile(path, GetFileMainName(timeStamp));
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+ else if (IsOutOfTimeMaxLength(fileInfo.CreationTime, timeStamp))
+ {
+ result = CreateFile(path, GetFileMainName(timeStamp));
+ }
+ else
+ {
+ try
+ {
+ result = fileInfo.OpenWrite();
+ }
+ catch
+ {
+ result = CreateFile(path, GetFileMainName(timeStamp));
+ }
+ }
+
+ return result;
+ }
+
+ ///
+ /// 创建文件
+ ///
+ /// 路径
+ /// 名称
+ /// FileStream
+ private static FileStream CreateFile(string path, string fileName1)
+ {
+ //return File.Create(@"" + path + "\"" + fileName1 + ".log");
+ return File.Create(path + @"\" + fileName1 + ".log");
+ }
+
+ ///
+ /// 获取文件名称
+ ///
+ /// timeStamp
+ /// HHmmssfff
+ private static string GetFileMainName(DateTime timeStamp)
+ {
+ return timeStamp.ToString("HH");
+ }
+
+ ///
+ /// IsOutOfTimeMaxLength
+ ///
+ /// creationTime
+ /// timeStamp
+ /// bool
+ private static bool IsOutOfTimeMaxLength(DateTime creationTime, DateTime timeStamp)
+ {
+ return Math.Abs((creationTime - timeStamp).TotalHours) >= 1;
+ }
+ }
+}
diff --git a/Elight.Utility/User.cs b/Elight.Utility/User.cs
new file mode 100644
index 0000000..d0e17b8
--- /dev/null
+++ b/Elight.Utility/User.cs
@@ -0,0 +1,41 @@
+using Elight.Entity;
+using Elight.Utility.Extensions;
+using Microsoft.AspNetCore.Http;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility
+{
+ ///
+ /// 用户信息
+ ///
+ /// Author:mxg
+ /// CreatedTimed:2022-05-15 10:08 PM
+ public class User
+ {
+ #region Identity
+
+ private readonly IHttpContextAccessor _accessor;
+
+ public User(IHttpContextAccessor accessor)
+ {
+ _accessor = accessor;
+ }
+
+ #endregion Identity
+
+
+ public App_Sys_UserModel Userdata()
+ {
+ var data = _accessor?.HttpContext?.User?.FindFirst(ClaimTypes.UserData);
+ var da = JsonConvert.DeserializeObject(data.Value);
+ return da;
+ }
+ }
+}
diff --git a/Elight.Utility/WebSocketMiddleware.cs b/Elight.Utility/WebSocketMiddleware.cs
new file mode 100644
index 0000000..ff7c857
--- /dev/null
+++ b/Elight.Utility/WebSocketMiddleware.cs
@@ -0,0 +1,68 @@
+using Elight.Entity;
+using Elight.Utility.Code;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.WebSockets;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elight.Utility
+{ ///
+ /// webSocket
+ ///
+ public class WebSocketMiddleware
+ {
+ #region Identity
+ private static Dictionary CONNECT_POOL = new Dictionary();//用户连接池
+ private readonly RequestDelegate _next;
+ App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户
+ Result result = new Result();
+ public WebSocketMiddleware(User user)
+ {
+ _userdata = user.Userdata();
+ }
+
+ #endregion
+ ///
+ /// 构造
+ ///
+ ///
+ /// 目标路径
+ public WebSocketMiddleware(RequestDelegate next)
+ {
+ _next = next;
+ }
+ ///
+ /// 中间件调用
+ ///
+ ///
+ ///
+ [HttpGet("/ws")]
+ public async Task Invoke(HttpContext httpContext)
+ {
+ try
+ {
+ var socket = await httpContext.WebSockets.AcceptWebSocketAsync();
+ string user = _userdata.Id;
+ #region 用户添加连接池
+ //第一次open时,添加到连接池中
+ if (!CONNECT_POOL.ContainsKey(user))
+ CONNECT_POOL.Add(user, socket);//不存在,添加
+ else
+ if (socket != CONNECT_POOL[user])//当前对象不一致,更新
+ CONNECT_POOL[user] = socket;
+ #endregion
+ }
+ catch (Exception ex)
+ {
+ var ss = ex.Message;
+ }
+ await _next(httpContext);
+ }
+ }
+}
diff --git a/Elight.Utility/logs/LogService.cs b/Elight.Utility/logs/LogService.cs
new file mode 100644
index 0000000..dd19159
--- /dev/null
+++ b/Elight.Utility/logs/LogService.cs
@@ -0,0 +1,258 @@
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using LogLevel = Elight.Utility.Enum.LogLevel;
+
+namespace Elight.Utility.logs
+{
+ ///
+ /// 写入文本日志
+ ///
+ public static class LogService
+ {
+
+ ///
+ /// 写日志的等级 默认int最小值
+ ///
+ private static readonly int _logWriteLevel =3;
+
+ ///
+ /// The obj.
+ ///
+ private static readonly object obj = new object();
+
+ ///
+ /// 写日志等级设置,默认只写全部日志
+ ///
+ private static LogLevel LogWriteLevel
+ {
+ get
+ {
+ if (_logWriteLevel < 0 || _logWriteLevel > 7)
+ {
+ return LogLevel.H调试信息;
+ }
+ else
+ {
+ return (LogLevel)_logWriteLevel;
+ }
+ }
+ }
+
+ ///
+ /// 记录异常文本日志
+ ///
+ /// 异常
+ /// 备注
+ public static void WriteLog(Exception ex, string remark)
+ {
+ WriteLog(ex, null, remark);
+ }
+
+ ///
+ /// Writes the log.
+ ///
+ /// The ex.
+ /// The remark.
+ /// The log level.
+ public static void WriteLog(Exception ex, string remark, LogLevel logLevel = LogLevel.D错误事件)
+ {
+ if (logLevel > LogWriteLevel)
+ {
+ return;
+ }
+ else
+ {
+ WriteLog(ex, null, remark);
+ }
+ }
+
+ ///
+ /// 记录异常文本日志
+ ///
+ /// 异常
+ /// 日志路径
+ /// 备注
+ public static void WriteLog(Exception ex, string path, string remark)
+ {
+ var errormessage = CreateErrorMessage(ex, remark);
+ WriteLog(errormessage.ToString(), path ?? Path.Combine(GetLogPath(), "Logs/ExceptionLog"));
+ }
+
+ ///
+ /// 记录异常文本日志
+ ///
+ /// 错误描述
+ /// 异常
+ /// 日志路径
+ /// 备注
+ public static void WriteLog(string describe, Exception ex, string path, string remark)
+ {
+ var errormessage = CreateErrorMessage(ex, remark);
+ WriteLog("Describe:" + describe + " Error:" + errormessage, path ?? Path.Combine(GetLogPath(), "Logs/ExceptionLog"));
+ }
+
+ ///
+ /// 创建异常消息
+ ///
+ /// 异常信息
+ /// 备注
+ /// 结果
+ private static StringBuilder CreateErrorMessage(Exception ex, string remark)
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.Append("************************Exception Start********************************");
+ string newLine = Environment.NewLine;
+ stringBuilder.Append(newLine);
+ stringBuilder.AppendLine("Exception Remark:" + remark);
+ Exception innerException = ex.InnerException;
+ stringBuilder.AppendFormat("Exception Date:{0}{1}", DateTime.Now, Environment.NewLine);
+ if (innerException != null)
+ {
+ stringBuilder.AppendFormat("Inner Exception Type:{0}{1}", innerException.GetType(), newLine);
+ stringBuilder.AppendFormat("Inner Exception Message:{0}{1}", innerException.Message, newLine);
+ stringBuilder.AppendFormat("Inner Exception Source:{0}{1}", innerException.Source, newLine);
+ stringBuilder.AppendFormat("Inner Exception StackTrace:{0}{1}", innerException.StackTrace, newLine);
+ }
+ stringBuilder.AppendFormat("Exception Type:{0}{1}", ex.GetType(), newLine);
+ stringBuilder.AppendFormat("Exception Message:{0}{1}", ex.Message, newLine);
+ stringBuilder.AppendFormat("Exception Source:{0}{1}", ex.Source, newLine);
+ stringBuilder.AppendFormat("Exception StackTrace:{0}{1}", ex.StackTrace, newLine);
+ stringBuilder.Append("************************Exception End************************************");
+ stringBuilder.Append(newLine);
+ return stringBuilder;
+ }
+
+ ///
+ /// 记录文本日志
+ ///
+ /// 日志内容
+ /// The log level.
+ public static void WriteLog(string content, LogLevel logLevel = LogLevel.G有用信息)
+ {
+ if (logLevel > LogWriteLevel)
+ {
+ return;
+ }
+ else
+ {
+ WriteLog(logLevel.ToString() + "\t" + content, Path.Combine(GetLogPath(), "Logs"));
+ }
+ }
+
+ ///
+ /// 记录文本日志
+ ///
+ /// 日志内容
+ /// 日志路径
+ public static void WriteLog(string content, string path)
+ {
+ //Action action = () => Log(content, path);
+ //action.BeginInvoke(null, null);
+ //BeginInvoke只能在framework里使用
+
+ Task task = Task.Run(() => Log(content, path));
+ task.Wait();
+ }
+
+ ///
+ /// 记录文本日志 大于等于配置的等级 才写日志
+ ///
+ /// 日志内容
+ /// 日志路径
+ /// 写日志的等级
+ public static void WriteLog(string content, string path, LogLevel logLevel = LogLevel.G有用信息)
+ {
+ if (logLevel > LogWriteLevel)
+ {
+ return;
+ }
+ WriteLog(logLevel + "\t" + content, path);
+ }
+
+ ///
+ /// 记录日志
+ ///
+ /// 调用方法(必填)
+ /// 请求参数
+ /// 输出参数
+ /// 保存文件夹,默认为CallLog
+ public static void SaveLog(string method, object request, object response, string saveFolder = "CallLog")
+ {
+ //try
+ //{
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.Append("************************Start********************************");
+ stringBuilder.Append(Environment.NewLine);
+ stringBuilder.AppendFormat("Method:{0}{1}", method, Environment.NewLine);
+ stringBuilder.AppendFormat("Request:{0}{1}", request == null ? string.Empty : JsonConvert.SerializeObject(request), Environment.NewLine);
+ stringBuilder.AppendFormat("Response:{0}{1}", response == null ? "void" : JsonConvert.SerializeObject(response), Environment.NewLine);
+ stringBuilder.Append("************************End************************************");
+ stringBuilder.Append(Environment.NewLine);
+ var logContent = stringBuilder.ToString();
+ var path = Path.Combine(GetLogPath(), "Logs/" + saveFolder);
+ WriteLog(logContent, path);
+ //}
+ //catch (Exception ex)
+ //{
+ // WriteLog(ex, "记录调用日志异常");
+ //}
+ }
+
+ ///
+ /// The log.
+ ///
+ ///
+ /// The content.
+ ///
+ ///
+ /// The path.
+ ///
+ ///
+ /// The
+ ///
+ internal static bool Log(string content, string path)
+ {
+ lock (obj)
+ {
+ try
+ {
+ TextWriter textWriter = new TextWriter(path);
+ return
+ textWriter.WriteLog(
+ DateTime.Now.ToString("日志时间:yyyy-MM-dd HH:mm:ss") + Environment.NewLine + content
+ + Environment.NewLine);
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+ }
+
+ ///
+ /// 获取日志路径
+ ///
+ /// 路径
+ internal static string GetLogPath()
+ {
+ var _path = "/CaseFile/logs";
+ var dic = Path.Combine(Environment.CurrentDirectory, "wwwroot");
+ if (!string.IsNullOrEmpty(_path))
+ dic += _path;
+ if (string.IsNullOrWhiteSpace(dic))
+ {
+ return AppDomain.CurrentDomain.BaseDirectory;
+ }
+ else
+ {
+ return dic;
+ }
+ }
+ }
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b1c900c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# MultiDeviceSystem
+
+多设备互联平台
\ No newline at end of file
diff --git a/desktop.ini b/desktop.ini
new file mode 100644
index 0000000..d957fd1
--- /dev/null
+++ b/desktop.ini
@@ -0,0 +1,4 @@
+[ViewState]
+Mode=
+Vid=
+FolderType=Generic