From 2efb01a7db0233aa5f391f37784aa563832d1434 Mon Sep 17 00:00:00 2001 From: liujiaqiang <1448951783@qq.com> Date: Wed, 14 Jun 2023 11:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=A0=E5=8F=AF=E7=A9=BA?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8A=A5=E9=94=99=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=AA=8C=E8=AF=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/ReservationController.cs | 3 ++ .../Controllers/Common/StagingController.cs | 3 ++ .../Controllers/Common/WebSocketController.cs | 41 ++++++++++++-- 24Hour/Controllers/LoginController.cs | 8 +-- .../system/SystemControllerController.cs | 2 +- 24Hour/Program.cs | 54 ++++++++++++------- 24Hour/Properties/launchSettings.json | 6 +-- 24Hour/appsettings.json | 18 +++++-- Elight.Entity/AppMode/App_ReceptionModel.cs | 4 +- Elight.Entity/AppMode/StagingModel.cs | 16 +++--- Elight.Entity/AppMode/StagingNumModel.cs | 8 +-- .../SystemModel/App_Sys_DepartModel.cs | 14 ++--- .../SystemModel/App_Sys_MenuModel.cs | 20 +++---- .../SystemModel/App_Sys_RoleMenuModel.cs | 10 ++-- .../SystemModel/App_Sys_RoleModel.cs | 10 ++-- .../SystemModel/App_Sys_RoleUserModel.cs | 10 ++-- .../SystemModel/App_Sys_UnitModel.cs | 14 ++--- .../SystemModel/App_Sys_UserModel.cs | 28 +++++----- .../Func_Dossier_LogRecordModel.cs | 26 ++++----- Elight.Logic/Model/App_ReceptionInput.cs | 14 ++--- Elight.Logic/Model/StagingInput.cs | 12 ++--- Elight.Logic/Model/StagingNumInput.cs | 8 +-- Elight.Logic/SystemModel/App_Sys_UnitTree.cs | 2 +- Elight.Utility/NullableConverter.cs | 36 +++++++++++++ 24 files changed, 234 insertions(+), 133 deletions(-) create mode 100644 Elight.Utility/NullableConverter.cs diff --git a/24Hour/Controllers/Common/ReservationController.cs b/24Hour/Controllers/Common/ReservationController.cs index 6e256dd..76823ca 100644 --- a/24Hour/Controllers/Common/ReservationController.cs +++ b/24Hour/Controllers/Common/ReservationController.cs @@ -9,6 +9,9 @@ using SqlSugar; namespace _24Hour.Controllers.Common { + /// + /// 预约接待 + /// [Authorize] [ApiController] [Route("api/reception")] diff --git a/24Hour/Controllers/Common/StagingController.cs b/24Hour/Controllers/Common/StagingController.cs index df5f763..ff1abac 100644 --- a/24Hour/Controllers/Common/StagingController.cs +++ b/24Hour/Controllers/Common/StagingController.cs @@ -8,6 +8,9 @@ using SqlSugar; namespace _24Hour.Controllers.Common { + /// + /// 工作台 + /// [Authorize] [ApiController] [Route("api/Staging")] diff --git a/24Hour/Controllers/Common/WebSocketController.cs b/24Hour/Controllers/Common/WebSocketController.cs index d6865c4..2cfd9a7 100644 --- a/24Hour/Controllers/Common/WebSocketController.cs +++ b/24Hour/Controllers/Common/WebSocketController.cs @@ -1,11 +1,25 @@ -using Microsoft.AspNetCore.Authorization; +using Elight.Entity; +using Elight.Logic; +using Elight.Utility; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using System.Net.WebSockets; namespace _24Hour.Controllers.Common { - [Authorize] + //[Authorize] public class WebSocketController : Controller { + //private readonly SqlSugarClient _db;//数据库 + //App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 + //private readonly ILogger _logger;//日志 + //public WebSocketController(ILogger logger, SqlSugarClient db, User user) + //{ + // _logger = logger; + // _db = db; + // _userdata = user.Userdata(); + //} [HttpGet("/ws")] public async Task WebSocketServer() { @@ -14,11 +28,32 @@ namespace _24Hour.Controllers.Common try { var socket = await HttpContext.WebSockets.AcceptWebSocketAsync(); + //ProcessChat(socket); } catch (Exception ex) { } } } + //private async Task ProcessChat(WebSockets context) + //{ + // WebSocket socket = context.WebSocket; + // while (true) + // { + // if (socket.State == WebSocketState.Open) + // { + // ArraySegment buffer = new ArraySegment(new byte[2048]); + // WebSocketReceiveResult result = await socket.ReceiveAsync(buffer, CancellationToken.None); + // string userMsg = Encoding.UTF8.GetString(buffer.Array, 0, result.Count); + // userMsg = "你发送了:" + userMsg + "于" + DateTime.Now.ToLongTimeString(); + // buffer = new ArraySegment(Encoding.UTF8.GetBytes(userMsg)); + // await socket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None); + // } + // else + // { + // break; + // } + // } + //} + } } -} diff --git a/24Hour/Controllers/LoginController.cs b/24Hour/Controllers/LoginController.cs index 8f3de09..0bb7ba8 100644 --- a/24Hour/Controllers/LoginController.cs +++ b/24Hour/Controllers/LoginController.cs @@ -75,8 +75,8 @@ namespace _24Hour.Controllers 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", + issuer: _configuration.GetSection("JwtConfiguration:Issuer").Value, + audience: _configuration.GetSection("JwtConfiguration:Audience").Value, claims: claims, notBefore: DateTime.Now, expires: DateTime.Now.AddDays(1), @@ -147,8 +147,8 @@ namespace _24Hour.Controllers 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", + issuer: _configuration.GetSection("JwtConfiguration:Issuer").Value, + audience: _configuration.GetSection("JwtConfiguration:Audience").Value, claims: claims, notBefore: DateTime.Now, expires: DateTime.Now.AddDays(1), diff --git a/24Hour/Controllers/system/SystemControllerController.cs b/24Hour/Controllers/system/SystemControllerController.cs index 4658b85..e210bed 100644 --- a/24Hour/Controllers/system/SystemControllerController.cs +++ b/24Hour/Controllers/system/SystemControllerController.cs @@ -566,7 +566,7 @@ namespace _24Hour.Controllers.system .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); + .Where(q => q.IsDelete == 0).ToTreeAsync(it => it.children, it => it.pid, null); result.IsSucceed = true; result.result = treelist; return result; diff --git a/24Hour/Program.cs b/24Hour/Program.cs index 45217eb..e72ae17 100644 --- a/24Hour/Program.cs +++ b/24Hour/Program.cs @@ -2,6 +2,8 @@ using Elight.Logic; using Elight.Utility; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -10,20 +12,33 @@ using Microsoft.OpenApi.Models; using SqlSugar; using System.Data; using System.Text; +using System.Text.Json.Serialization; +using System.Text.Json; +using Microsoft.AspNetCore.Http.Json; #region builder var builder = WebApplication.CreateBuilder(args); var Configuration = builder.Configuration; - +builder.WebHost.UseUrls(Configuration.GetSection("UrlsConfiguration:Urls").Value.Split(",")); // Add services to the container. - -builder.Services.AddControllers(); +builder.Services.AddControllers().AddJsonOptions(options => +{ + options.JsonSerializerOptions.PropertyNamingPolicy = null; + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); + options.JsonSerializerOptions.Converters.Add(new Elight.Utility.NullableConverter()); +}); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -#region -#endregion +#region Swaggerļ builder.Services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); @@ -58,9 +73,11 @@ builder.Services.AddSwaggerGen(c => Type = SecuritySchemeType.ApiKey }); }); -builder.Services.AddControllers().AddJsonOptions(options => +#endregion + +builder.Services.AddMvc(config => { - options.JsonSerializerOptions.PropertyNamingPolicy = null; + config.Filters.Add(new AllowAnonymousFilter()); }); // ֤ builder.Services.AddAuthentication(options => @@ -84,13 +101,13 @@ builder.Services.AddAuthentication(options => ClockSkew = TimeSpan.Zero }; - ////صжSignalR·(https://www.cnblogs.com/fger/p/11811190.html) + //صжWebSocket·(https://www.cnblogs.com/fger/p/11811190.html) options.Events = new JwtBearerEvents { OnMessageReceived = (context) => { if (!context.HttpContext.Request.Path.HasValue) return Task.CompletedTask; - //صжSignalR· + //صжWebSocket· var accessToken = context.HttpContext.Request.Query["access_token"]; var path = context.HttpContext.Request.Path; if (string.IsNullOrWhiteSpace(accessToken) || !path.StartsWithSegments("/ws")) return Task.CompletedTask; @@ -149,7 +166,14 @@ if (app.Environment.IsDevelopment()) app.UseSwagger(); app.UseSwaggerUI(); } - +#region websockets +app.UseWebSockets(new WebSocketOptions +{ + KeepAliveInterval = TimeSpan.FromMinutes(2) +}); +//app.UseMiddleware(); +#endregion +app.UseStaticFiles(); app.UseHttpsRedirection(); //· app.UseRouting(); @@ -168,15 +192,5 @@ app.UseSwaggerUI(c => 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 index a5e4ad0..8112789 100644 --- a/24Hour/Properties/launchSettings.json +++ b/24Hour/Properties/launchSettings.json @@ -11,13 +11,11 @@ "profiles": { "_24Hour": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:7246", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "applicationUrl": "http://localhost:8099" }, "IIS Express": { "commandName": "IISExpress", diff --git a/24Hour/appsettings.json b/24Hour/appsettings.json index 95caff8..b970f09 100644 --- a/24Hour/appsettings.json +++ b/24Hour/appsettings.json @@ -8,16 +8,16 @@ "AllowedHosts": "*", "ConnectionStrings": { "DBType": "MySQL", - "MySQLConnString": "server=192.168.0.251;Database=equipmentrearend;Uid=root;Pwd=sa@admin;Allow User Variables=True;", + "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", + "Issuer": "http://127.0.0.1:8098", /* JwtConfig Audience=http://127.0.0.1:api本地端口*/ //订阅者 - "Audience": "https://127.0.0.1:7246", + "Audience": "http://127.0.0.1:8098", //RefreshToken受众 "RefreshTokenAudience": null, //加密Key @@ -28,5 +28,17 @@ "RefreshTokenExpires": 1440, //时间歪斜,单位秒 "ClockSkew": 1 + }, + //Urls + "UrlsConfiguration": { + /* Urls:["http://*:api端口号"] */ + "Urls": "http://*:8098", + //所谓同源是指"协议+域名+端口" + /* 允许跨域的域名及IP */ + "CorUrls": [ "http://localhost:8002", "http://114.115.168.247:9111", "http://47.109.20.59:8937", "http://47.109.20.59:8942", "http://localhost:8080", "http://localhost:4223" ], + + /* DomainUrl:["http://localhost:api端口号"] */ + "DomainUrl": "http://localhost:8006", + "HubCorUrls": [] } } diff --git a/Elight.Entity/AppMode/App_ReceptionModel.cs b/Elight.Entity/AppMode/App_ReceptionModel.cs index 4b07a51..181c252 100644 --- a/Elight.Entity/AppMode/App_ReceptionModel.cs +++ b/Elight.Entity/AppMode/App_ReceptionModel.cs @@ -58,10 +58,10 @@ namespace Elight.Entity [DataMember] - public string createusername { get; set; } + public string? createusername { get; set; } [DataMember] - public string createuserId { get; set; } + public string? createuserId { get; set; } /// /// 创建日期 diff --git a/Elight.Entity/AppMode/StagingModel.cs b/Elight.Entity/AppMode/StagingModel.cs index 0fa2adb..5a30e4c 100644 --- a/Elight.Entity/AppMode/StagingModel.cs +++ b/Elight.Entity/AppMode/StagingModel.cs @@ -18,44 +18,44 @@ namespace Elight.Entity { [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 跳转地址 /// [DataMember] - public string path { get; set; } + public string? path { get; set; } /// /// 图标地址 /// [DataMember] - public string icon { get; set; } + public string? icon { get; set; } /// /// 颜色 /// [DataMember] - public string color { get; set; } + public string? color { get; set; } /// /// 名称 /// [DataMember] - public string title { get; set; } + public string? title { get; set; } /// /// 类型 /// [DataMember] - public string titletype { get; set; } + public string? titletype { get; set; } [DataMember] - public string username { get; set; } + public string? username { get; set; } [DataMember] - public string userId { get; set; } + public string? userId { get; set; } /// /// 创建日期 diff --git a/Elight.Entity/AppMode/StagingNumModel.cs b/Elight.Entity/AppMode/StagingNumModel.cs index 74b58e1..b68d5f5 100644 --- a/Elight.Entity/AppMode/StagingNumModel.cs +++ b/Elight.Entity/AppMode/StagingNumModel.cs @@ -18,13 +18,13 @@ namespace Elight.Entity { [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 工作台Id /// [DataMember] - public string stagingId { get; set; } + public string? stagingId { get; set; } /// /// 使用数 @@ -32,12 +32,12 @@ namespace Elight.Entity [DataMember] public int num { get; set; } [DataMember] - public string username { get; set; } + public string? username { get; set; } /// /// 用户Id /// [DataMember] - public string userId { get; set; } + public string? userId { get; set; } /// /// 创建日期 diff --git a/Elight.Entity/SystemModel/App_Sys_DepartModel.cs b/Elight.Entity/SystemModel/App_Sys_DepartModel.cs index 94986fa..892bda0 100644 --- a/Elight.Entity/SystemModel/App_Sys_DepartModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_DepartModel.cs @@ -17,29 +17,29 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 单位Id /// [DataMember] - public string unitId { get; set; } + public string? unitId { get; set; } /// /// 部门编码 /// [DataMember] - public string departCode { get; set; } + public string? departCode { get; set; } /// /// 部门名称 /// [DataMember] - public string departname { get; set; } + public string? departname { get; set; } /// /// 部门简称 /// [DataMember] - public string departjc { get; set; } + public string? departjc { get; set; } /// /// 是否删除 0否,1是 @@ -51,13 +51,13 @@ namespace Elight.Entity /// 创建人Id /// [DataMember] - public string createuserId { get; set; } + public string? createuserId { get; set; } /// /// 创建人 /// [DataMember] - public string createusername { get; set; } + public string? createusername { get; set; } /// /// 创建时间 /// diff --git a/Elight.Entity/SystemModel/App_Sys_MenuModel.cs b/Elight.Entity/SystemModel/App_Sys_MenuModel.cs index 70a78ea..80fb7bc 100644 --- a/Elight.Entity/SystemModel/App_Sys_MenuModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_MenuModel.cs @@ -18,41 +18,41 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 父级 /// [DataMember] - public string pid { get; set; } + public string? pid { get; set; } /// /// 路径 /// [DataMember] - public string path { get; set; } + public string? path { get; set; } /// /// 菜单名称 /// [DataMember] - public string name { get; set; } + public string? name { get; set; } /// /// 页面组件路径 /// [DataMember] - public string component { get; set; } + public string? component { get; set; } /// /// 直接跳转路径 /// [DataMember] - public string redirect { get; set; } + public string? redirect { get; set; } /// /// 页面标题 /// [DataMember] - public string title { get; set; } + public string? title { get; set; } /// /// 是否隐藏子菜单 @@ -64,7 +64,7 @@ namespace Elight.Entity /// 图标 /// [DataMember] - public string icon { get; set; } + public string? icon { get; set; } /// /// 当前菜单在列表中显示时 激活的菜单 /// @@ -96,13 +96,13 @@ namespace Elight.Entity /// 创建人Id /// [DataMember] - public string createuserId { get; set; } + public string? createuserId { get; set; } /// /// 创建人 /// [DataMember] - public string createusername { get; set; } + public string? createusername { get; set; } /// /// 创建时间 /// diff --git a/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs index 8c27abf..e5e0337 100644 --- a/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs @@ -18,31 +18,31 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 角色Id /// [DataMember] - public string roleId { get; set; } + public string? roleId { get; set; } /// /// 菜单Id /// [DataMember] - public string menuId { get; set; } + public string? menuId { get; set; } /// /// 用户Id /// [DataMember] - public string userId { get; set; } + public string? userId { get; set; } /// /// 用户名称 /// [DataMember] - public string username { get; set; } + public string? username { get; set; } /// /// 创建时间 diff --git a/Elight.Entity/SystemModel/App_Sys_RoleModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleModel.cs index a18aa59..34efbfa 100644 --- a/Elight.Entity/SystemModel/App_Sys_RoleModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_RoleModel.cs @@ -18,31 +18,31 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 单位编码 /// [DataMember] - public string unitCode { get; set; } + public string? unitCode { get; set; } /// /// 角色名称 /// [DataMember] - public string name { get; set; } + public string? name { get; set; } /// /// 用户Id /// [DataMember] - public string userId { get; set; } + public string? userId { get; set; } /// /// 用户名称 /// [DataMember] - public string username { get; set; } + public string? username { get; set; } /// /// 创建时间 diff --git a/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs index dab3d77..b62d3b6 100644 --- a/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs @@ -18,31 +18,31 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 单位编码 /// [DataMember] - public string roleId { get; set; } + public string? roleId { get; set; } /// /// 角色用户Id /// [DataMember] - public string roleuserId { get; set; } + public string? roleuserId { get; set; } /// /// 用户Id /// [DataMember] - public string userId { get; set; } + public string? userId { get; set; } /// /// 用户名称 /// [DataMember] - public string username { get; set; } + public string? username { get; set; } /// /// 创建时间 diff --git a/Elight.Entity/SystemModel/App_Sys_UnitModel.cs b/Elight.Entity/SystemModel/App_Sys_UnitModel.cs index 48932eb..e30aca2 100644 --- a/Elight.Entity/SystemModel/App_Sys_UnitModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_UnitModel.cs @@ -18,29 +18,29 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 父级 /// [DataMember] - public string pid { get; set; } + public string? pid { get; set; } /// /// 单位编码 /// [DataMember] - public string unitCode { get; set; } + public string? unitCode { get; set; } /// /// 单位名称 /// [DataMember] - public string unitname { get; set; } + public string? unitname { get; set; } /// /// 单位简称 /// [DataMember] - public string unitjc { get; set; } + public string? unitjc { get; set; } /// /// 是否删除 0否,1是 @@ -52,13 +52,13 @@ namespace Elight.Entity /// 创建人Id /// [DataMember] - public string createuserId { get; set; } + public string? createuserId { get; set; } /// /// 创建人 /// [DataMember] - public string createusername { get; set; } + public string? createusername { get; set; } /// /// 创建时间 /// diff --git a/Elight.Entity/SystemModel/App_Sys_UserModel.cs b/Elight.Entity/SystemModel/App_Sys_UserModel.cs index 9eff059..9200ea5 100644 --- a/Elight.Entity/SystemModel/App_Sys_UserModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_UserModel.cs @@ -18,60 +18,60 @@ namespace Elight.Entity /// [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 单位编码 /// [DataMember] - public string unitCode { get; set; } + public string? unitCode { get; set; } /// /// 部门 /// [DataMember] - public string department { get; set; } + public string? department { get; set; } /// /// 密码 /// [DataMember] - public string Password { get; set; } + public string? Password { get; set; } /// /// 名称 /// [DataMember] - public string name { get; set; } + public string? name { get; set; } /// /// 职务 /// [DataMember] - public string duties { get; set; } + public string? duties { get; set; } /// /// 电话号码 /// [DataMember] - public string phone { get; set; } + public string? phone { get; set; } /// /// 身份证号码 /// [DataMember] - public string cardId { get; set; } + public string? cardId { get; set; } /// /// 身份(检察官,律师,当事人) /// [DataMember] - public string identity { get; set; } + public string? identity { get; set; } /// /// 微信Id /// [DataMember] - public string wechatId { get; set; } + public string? wechatId { get; set; } /// /// 账号类型0:系统,1:APP @@ -95,7 +95,7 @@ namespace Elight.Entity /// 头像地址 /// [DataMember] - public string photo { get; set; } + public string? photo { get; set; } /// /// 性别 0:女 1:男 @@ -117,17 +117,17 @@ namespace Elight.Entity /// 审核描述 /// [DataMember] - public string describe { get; set; } + public string? describe { get; set; } /// /// 创建人Id /// [DataMember] - public string createuserId { get; set; } + public string? createuserId { get; set; } /// /// 创建人 /// [DataMember] - public string createusername { get; set; } + public string? createusername { get; set; } /// /// 创建时间 /// diff --git a/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs b/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs index b2ae09b..2019ccc 100644 --- a/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs +++ b/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs @@ -21,79 +21,79 @@ namespace Elight.Entity.SystemModel /// 序号 /// [DataMember] - public string SerialNumber { get; set; } + public string? SerialNumber { get; set; } /// /// 单位编码 /// [DataMember] - public string UnitCode { get; set; } + public string? UnitCode { get; set; } /// /// 单位名称 /// [DataMember] - public string NameEntity { get; set; } + public string? NameEntity { get; set; } /// /// 部门编码 /// [DataMember] - public string DepartmentCode { get; set; } + public string? DepartmentCode { get; set; } /// /// 部门名称 /// [DataMember] - public string DepartmentName { get; set; } + public string? DepartmentName { get; set; } /// /// 操作人工号 /// [DataMember] - public string OperatingManual { get; set; } + public string? OperatingManual { get; set; } /// /// 操作人 /// [DataMember] - public string Operation { get; set; } + public string? Operation { get; set; } /// /// 操作时间 /// [DataMember] - public string OperatingTime { get; set; } + public string? OperatingTime { get; set; } /// /// 操作IP /// [DataMember] - public string OperationIp { get; set; } + public string? OperationIp { get; set; } /// /// 操作类型 /// [DataMember] - public string OperationType { get; set; } + public string? OperationType { get; set; } /// /// 日志内容 /// [DataMember] - public string LogContents { get; set; } + public string? LogContents { get; set; } /// /// 操作案件部门受案号 /// [DataMember] - public string OpeCasDepAccCas { get; set; } + public string? OpeCasDepAccCas { get; set; } /// /// 分区列 创建时间取年份,触发器完成 /// [DataMember] - public string ParColCreTimTakYeaTri { get; set; } + public string? ParColCreTimTakYeaTri { get; set; } /// /// 是否删除 diff --git a/Elight.Logic/Model/App_ReceptionInput.cs b/Elight.Logic/Model/App_ReceptionInput.cs index feba82a..3b1767f 100644 --- a/Elight.Logic/Model/App_ReceptionInput.cs +++ b/Elight.Logic/Model/App_ReceptionInput.cs @@ -15,7 +15,7 @@ namespace Elight.Logic public class App_ReceptionInput : Paging { [DataMember] - public string Id { get; set; } + public string? Id { get; set; } /// /// 预约时间 @@ -27,25 +27,25 @@ namespace Elight.Logic /// 部门 /// [DataMember] - public string depart { get; set; } + public string? depart { get; set; } /// /// 接待人 /// [DataMember] - public string receptionuser { get; set; } + public string? receptionuser { get; set; } /// /// 事由 /// [DataMember] - public string matter { get; set; } + public string? matter { get; set; } /// /// 预约接待类型 /// [DataMember] - public string receptionId { get; set; } + public string? receptionId { get; set; } /// /// 0:代办,1已完成 @@ -57,12 +57,12 @@ namespace Elight.Logic /// 创建人名称 /// [DataMember] - public string createusername { get; set; } + public string? createusername { get; set; } /// /// 创建人Id /// [DataMember] - public string createuserId { get; set; } + public string? createuserId { get; set; } } } diff --git a/Elight.Logic/Model/StagingInput.cs b/Elight.Logic/Model/StagingInput.cs index c3cfeec..23ec1b9 100644 --- a/Elight.Logic/Model/StagingInput.cs +++ b/Elight.Logic/Model/StagingInput.cs @@ -17,36 +17,36 @@ namespace Elight.Logic public class StagingInput:Paging { [DataMember] - public string Id { get; set; } + public string? Id { get; set; } /// /// 跳转地址 /// [DataMember] - public string path { get; set; } + public string? path { get; set; } /// /// 图标地址 /// [DataMember] - public string icon { get; set; } + public string? icon { get; set; } /// /// 颜色 /// [DataMember] - public string color { get; set; } + public string? color { get; set; } /// /// 名称 /// [DataMember] - public string title { get; set; } + public string? title { get; set; } /// /// 类型 /// [DataMember] - public string titletype { get; set; } + public string? titletype { get; set; } } } diff --git a/Elight.Logic/Model/StagingNumInput.cs b/Elight.Logic/Model/StagingNumInput.cs index dfe412e..4abb56a 100644 --- a/Elight.Logic/Model/StagingNumInput.cs +++ b/Elight.Logic/Model/StagingNumInput.cs @@ -17,21 +17,21 @@ namespace Elight.Logic { [DataMember] [SugarColumn(IsPrimaryKey = true)] - public string Id { get; set; } + public string? Id { get; set; } /// /// 工作台Id /// [DataMember] - public string stagingId { get; set; } + public string? stagingId { get; set; } /// /// 使用数 /// [DataMember] - public string num { get; set; } + public string? num { get; set; } [DataMember] - public string username { get; set; } + public string? username { get; set; } /// /// 用户Id /// diff --git a/Elight.Logic/SystemModel/App_Sys_UnitTree.cs b/Elight.Logic/SystemModel/App_Sys_UnitTree.cs index 7c4b199..7bb7e03 100644 --- a/Elight.Logic/SystemModel/App_Sys_UnitTree.cs +++ b/Elight.Logic/SystemModel/App_Sys_UnitTree.cs @@ -67,7 +67,7 @@ namespace Elight.Logic.SystemModel public DateTime? createtime { get; set; } = DateTime.Now; [SqlSugar.SugarColumn(IsIgnore = true)] - public List? Child { get; set; } + public List? children { get; set; } } } diff --git a/Elight.Utility/NullableConverter.cs b/Elight.Utility/NullableConverter.cs new file mode 100644 index 0000000..10fffd5 --- /dev/null +++ b/Elight.Utility/NullableConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Elight.Utility +{ + /// + /// 自定义 NullableConverter 解决可为空类型字段入参“”空字符触发转换异常问题 + /// + /// + public class NullableConverter : JsonConverter where T:struct + { + public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.String) + { + if (string.IsNullOrEmpty(reader.GetString()) || string.IsNullOrWhiteSpace(reader.GetString())) + { + return null; + } + } + return JsonSerializer.Deserialize(ref reader, options); + } + + + public override void Write(Utf8JsonWriter writer, T? value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value!.Value, options); + } + + } +}