修改可空类型

This commit is contained in:
陈淳
2023-01-06 10:15:37 +08:00
parent b7c9b84449
commit 576397a042
29 changed files with 82 additions and 68 deletions

View File

@@ -69,7 +69,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
//路径为: 文件路径/文件id+文件扩展名 //路径为: 文件路径/文件id+文件扩展名
var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString() + Path.GetExtension(file.FileName)); var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString() + Path.GetExtension(file.FileName));
var stream = System.IO.File.OpenRead(path); var stream = System.IO.File.OpenRead(path);
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName); var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName!);
return File(stream, MimeType, file.FileName); return File(stream, MimeType, file.FileName);
} }
catch catch

View File

@@ -102,7 +102,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[Log("用户模块", OperEnum.Update)] [Log("用户模块", OperEnum.Update)]
public async Task<Result> Update(UserInfoDto userDto) public async Task<Result> Update(UserInfoDto userDto)
{ {
if (await _repository.IsAnyAsync(u => userDto.User.UserName!.Equals(u.UserName) && !userDto.User.Id.Equals(u.Id))) if (await _repository.IsAnyAsync(u => userDto.User!.UserName!.Equals(u.UserName) && !userDto.User.Id.Equals(u.Id)))
{ {
return Result.Error("用户名已存在,修改失败!"); return Result.Error("用户名已存在,修改失败!");
} }
@@ -121,7 +121,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public async Task<Result> UpdateProfile(UserInfoDto userDto) public async Task<Result> UpdateProfile(UserInfoDto userDto)
{ {
//修改需要赋值上主键哦 //修改需要赋值上主键哦
userDto.User.Id = HttpContext.GetUserIdInfo(); userDto.User!.Id = HttpContext.GetUserIdInfo();
return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto)); return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto));
} }
@@ -135,7 +135,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[Log("用户模块", OperEnum.Insert)] [Log("用户模块", OperEnum.Insert)]
public async Task<Result> Add(UserInfoDto userDto) public async Task<Result> Add(UserInfoDto userDto)
{ {
if (string.IsNullOrEmpty(userDto.User.Password)) if (string.IsNullOrEmpty(userDto?.User?.Password))
{ {
return Result.Error("密码为空,添加失败!"); return Result.Error("密码为空,添加失败!");
} }

View File

@@ -23,9 +23,9 @@ namespace Yi.Framework.Common.Abstract
public bool PhoneNumberVerified { get; set; } public bool PhoneNumberVerified { get; set; }
public string[] Roles { get; set; } public string[]? Roles { get; set; }
public string[] Permission { get; set; } public string[]? Permission { get; set; }
} }
} }

View File

@@ -19,7 +19,7 @@ namespace Yi.Framework.Common.Attribute
/// <summary> /// <summary>
/// 指定服务类型 /// 指定服务类型
/// </summary> /// </summary>
public Type ServiceType { get; set; } public Type? ServiceType { get; set; }
} }

View File

@@ -13,15 +13,15 @@ public class BusinessException : Exception,
{ {
public ResultCodeEnum Code { get; set; } public ResultCodeEnum Code { get; set; }
public string Details { get; set; } public string? Details { get; set; }
public LogLevel LogLevel { get; set; } public LogLevel LogLevel { get; set; }
public BusinessException( public BusinessException(
ResultCodeEnum code = ResultCodeEnum.NotSuccess, ResultCodeEnum code = ResultCodeEnum.NotSuccess,
string message = null, string? message = null,
string details = null, string? details = null,
Exception innerException = null, Exception? innerException = null,
LogLevel logLevel = LogLevel.Warning) LogLevel logLevel = LogLevel.Warning)
: base(message, innerException) : base(message, innerException)
{ {

View File

@@ -2,5 +2,5 @@ namespace Yi.Framework.Common.Exceptions;
public interface IHasErrorDetails public interface IHasErrorDetails
{ {
string Details { get; } string? Details { get; }
} }

View File

@@ -14,8 +14,8 @@ public class UserFriendlyException : BusinessException
public UserFriendlyException( public UserFriendlyException(
string message, string message,
ResultCodeEnum code = ResultCodeEnum.NotSuccess, ResultCodeEnum code = ResultCodeEnum.NotSuccess,
string details = null, string? details = null,
Exception innerException = null, Exception? innerException = null,
LogLevel logLevel = LogLevel.Warning) LogLevel logLevel = LogLevel.Warning)
: base( : base(
code, code,

View File

@@ -11,7 +11,7 @@ namespace Yi.Framework.Common.Helper
{ {
public class AssemblyHelper public class AssemblyHelper
{ {
public static List<Type> GetClass(string assemblyFile, string className = null, string spaceName = null) public static List<Type> GetClass(string assemblyFile, string? className = null, string? spaceName = null)
{ {
Assembly assembly = Assembly.Load(assemblyFile); Assembly assembly = Assembly.Load(assemblyFile);
return assembly.GetTypes().Where(m => m.IsClass return assembly.GetTypes().Where(m => m.IsClass

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -13,13 +14,14 @@ namespace Yi.Framework.Common.Helper
{ {
this._getField = getfield; this._getField = getfield;
} }
public bool Equals(T x, T y) public bool Equals(T? x, T? y)
{ {
return EqualityComparer<C>.Default.Equals(_getField(x), _getField(y)); return EqualityComparer<C>.Default.Equals(_getField(x!), _getField(y!));
} }
public int GetHashCode(T obj) public int GetHashCode(T obj)
{ {
return EqualityComparer<C>.Default.GetHashCode(this._getField(obj)); return EqualityComparer<C>.Default.GetHashCode(this._getField(obj)!);
} }
} }
public static class DistinctHelper public static class DistinctHelper

View File

@@ -28,7 +28,7 @@ namespace Yi.Framework.Common.Helper
} }
public static async Task<string> Post(string url, object item = null, Dictionary<string, string> head = null) public static async Task<string> Post(string url, object? item = null, Dictionary<string, string>? head = null)
{ {
using StringContent json = new(JsonSerializer.Serialize(item), Encoding.UTF8, MediaTypeNames.Application.Json); using StringContent json = new(JsonSerializer.Serialize(item), Encoding.UTF8, MediaTypeNames.Application.Json);

View File

@@ -24,6 +24,11 @@ namespace Yi.Framework.Common.Helper
// 获取所有可用网卡IP信息 // 获取所有可用网卡IP信息
var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses); var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses);
if (ipCollection is null)
{
return instanceIp;
}
foreach (var ipadd in ipCollection) foreach (var ipadd in ipCollection)
{ {
if (!IPAddress.IsLoopback(ipadd.Address) && ipadd.Address.AddressFamily == AddressFamily.InterNetwork) if (!IPAddress.IsLoopback(ipadd.Address) && ipadd.Address.AddressFamily == AddressFamily.InterNetwork)

View File

@@ -15,7 +15,7 @@ namespace Yi.Framework.Common.Helper
public static T StrToObj<T>(string str) public static T StrToObj<T>(string str)
{ {
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(str); return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(str)!;
} }
/// <summary> /// <summary>
/// 转换对象为JSON格式数据 /// 转换对象为JSON格式数据
@@ -85,7 +85,7 @@ namespace Yi.Framework.Common.Helper
{ {
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = System.Runtime.Serialization.Json.DataContractJsonSerializer serializer =
new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T)); new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T));
return (T)serializer.ReadObject(ms); return (T)serializer.ReadObject(ms)!;
} }
} }

View File

@@ -35,7 +35,7 @@ namespace Yi.Framework.Common.Helper
byte[] bIn = Encoding.Unicode.GetBytes(pass); byte[] bIn = Encoding.Unicode.GetBytes(pass);
byte[] bSalt = Convert.FromBase64String(salt); byte[] bSalt = Convert.FromBase64String(salt);
byte[] bAll = new byte[bSalt.Length + bIn.Length]; byte[] bAll = new byte[bSalt.Length + bIn.Length];
byte[] bRet = null; byte[]? bRet = null;
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length); Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length); Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);

View File

@@ -22,15 +22,15 @@ namespace Yi.Framework.Common.Helper
public static string GetMimeMapping(string FileName) public static string GetMimeMapping(string FileName)
{ {
string text = null; string text = null!;
int num = FileName.LastIndexOf('.'); int num = FileName.LastIndexOf('.');
if (0 < num && num > FileName.LastIndexOf('\\')) if (0 < num && num > FileName.LastIndexOf('\\'))
{ {
text = (string)MimeHelper._mimeMappingTable[FileName.Substring(num)]; text = (string)MimeHelper._mimeMappingTable[FileName.Substring(num)]!;
} }
if (text == null) if (text == null)
{ {
text = (string)MimeHelper._mimeMappingTable[".*"]; text = (string)MimeHelper._mimeMappingTable[".*"]!;
} }
return text; return text;
} }

View File

@@ -11,8 +11,8 @@ namespace Yi.Framework.Common.Helper
/// </summary> /// </summary>
public class RSAHelper public class RSAHelper
{ {
public readonly RSA _privateKeyRsaProvider; public readonly RSA? _privateKeyRsaProvider;
public readonly RSA _publicKeyRsaProvider; public readonly RSA? _publicKeyRsaProvider;
private readonly HashAlgorithmName _hashAlgorithmName; private readonly HashAlgorithmName _hashAlgorithmName;
private readonly Encoding _encoding; private readonly Encoding _encoding;
@@ -23,7 +23,7 @@ namespace Yi.Framework.Common.Helper
/// <param name="encoding">编码类型</param> /// <param name="encoding">编码类型</param>
/// <param name="privateKey">私钥</param> /// <param name="privateKey">私钥</param>
/// <param name="publicKey">公钥</param> /// <param name="publicKey">公钥</param>
public RSAHelper(RSAType rsaType, Encoding encoding, string privateKey, string publicKey = null) public RSAHelper(RSAType rsaType, Encoding encoding, string privateKey, string? publicKey = null)
{ {
_encoding = encoding; _encoding = encoding;
if (!string.IsNullOrEmpty(privateKey)) if (!string.IsNullOrEmpty(privateKey))
@@ -50,7 +50,7 @@ namespace Yi.Framework.Common.Helper
{ {
byte[] dataBytes = _encoding.GetBytes(data); byte[] dataBytes = _encoding.GetBytes(data);
var signatureBytes = _privateKeyRsaProvider.SignData(dataBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1); var signatureBytes = _privateKeyRsaProvider!.SignData(dataBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1);
return Convert.ToBase64String(signatureBytes); return Convert.ToBase64String(signatureBytes);
} }
@@ -70,7 +70,7 @@ namespace Yi.Framework.Common.Helper
byte[] dataBytes = _encoding.GetBytes(data); byte[] dataBytes = _encoding.GetBytes(data);
byte[] signBytes = Convert.FromBase64String(sign); byte[] signBytes = Convert.FromBase64String(sign);
var verify = _publicKeyRsaProvider.VerifyData(dataBytes, signBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1); var verify = _publicKeyRsaProvider!.VerifyData(dataBytes, signBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1);
return verify; return verify;
} }
@@ -225,7 +225,7 @@ namespace Yi.Framework.Common.Helper
/// </summary> /// </summary>
/// <param name="publicKeyString"></param> /// <param name="publicKeyString"></param>
/// <returns></returns> /// <returns></returns>
public RSA CreateRsaProviderFromPublicKey(string publicKeyString) public RSA? CreateRsaProviderFromPublicKey(string publicKeyString)
{ {
// encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1" // encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1"
byte[] seqOid = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 }; byte[] seqOid = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 };

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.Common.Helper
/// <typeparam name="TEntity"></typeparam> /// <typeparam name="TEntity"></typeparam>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
public static TEntity Deserialize<TEntity>(byte[] value) public static TEntity? Deserialize<TEntity>(byte[] value)
{ {
if (value == null) if (value == null)
{ {

View File

@@ -50,7 +50,7 @@ namespace Yi.Framework.Common.Helper
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
string urlPars = null; string? urlPars = null;
bool isEnter = false; bool isEnter = false;
foreach (var item in dic) foreach (var item in dic)
{ {
@@ -69,7 +69,7 @@ namespace Yi.Framework.Common.Helper
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
string urlPars = null; string? urlPars = null;
bool isEnter = false; bool isEnter = false;
foreach (var item in dic) foreach (var item in dic)
{ {

View File

@@ -9,13 +9,13 @@ namespace Yi.Framework.Common.Helper
{ {
public static class TreeHelper public static class TreeHelper
{ {
public static List<T> SetTree<T>(List<T> list, Action<T> action = null) public static List<T> SetTree<T>(List<T> list, Action<T> action = null!)
{ {
if (list is not null && list.Count > 0) if (list is not null && list.Count > 0)
{ {
IList<T> result = new List<T>(); IList<T> result = new List<T>();
long pid = list.Min(m => (m as ITreeModel<T>).ParentId); long pid = list.Min(m => (m as ITreeModel<T>)!.ParentId);
IList<T> t = list.Where(m => (m as ITreeModel<T>).ParentId == pid).ToList(); IList<T> t = list.Where(m => (m as ITreeModel<T>)!.ParentId == pid).ToList();
foreach (T model in t) foreach (T model in t)
{ {
if (action is not null) if (action is not null)
@@ -24,20 +24,20 @@ namespace Yi.Framework.Common.Helper
} }
result.Add(model); result.Add(model);
var item = (model as ITreeModel<T>); var item = (model as ITreeModel<T>);
IList<T> children = list.Where(m => (m as ITreeModel<T>).ParentId == item.Id).ToList(); IList<T> children = list.Where(m => (m as ITreeModel<T>)!.ParentId == item!.Id).ToList();
if (children.Count > 0) if (children.Count > 0)
{ {
SetTreeChildren(list, children, model, action); SetTreeChildren(list, children, model, action!);
} }
} }
return result.OrderByDescending(m => (m as ITreeModel<T>).OrderNum).ToList(); return result.OrderByDescending(m => (m as ITreeModel<T>)!.OrderNum).ToList();
} }
return null; return null!;
} }
private static void SetTreeChildren<T>(IList<T> list, IList<T> children, T model, Action<T> action = null) private static void SetTreeChildren<T>(IList<T> list, IList<T> children, T model, Action<T> action = null!)
{ {
var mm = (model as ITreeModel<T>); var mm = (model as ITreeModel<T>);
mm.Children = new List<T>(); mm!.Children = new List<T>();
foreach (T item in children) foreach (T item in children)
{ {
if (action is not null) if (action is not null)
@@ -46,13 +46,13 @@ namespace Yi.Framework.Common.Helper
} }
mm.Children.Add(item); mm.Children.Add(item);
var _item = (item as ITreeModel<T>); var _item = (item as ITreeModel<T>);
IList<T> _children = list.Where(m => (m as ITreeModel<T>).ParentId == _item.Id).ToList(); IList<T> _children = list.Where(m => (m as ITreeModel<T>)!.ParentId == _item!.Id).ToList();
if (_children.Count > 0) if (_children.Count > 0)
{ {
SetTreeChildren(list, _children, item, action); SetTreeChildren(list, _children, item, action!);
} }
} }
mm.Children = mm.Children.OrderByDescending(m => (m as ITreeModel<T>).OrderNum).ToList(); mm.Children = mm.Children.OrderByDescending(m => (m as ITreeModel<T>)!.OrderNum).ToList();
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace Yi.Framework.Common.Helper
/// <typeparam name="T">类</typeparam> /// <typeparam name="T">类</typeparam>
/// <param name="obj">对象</param> /// <param name="obj">对象</param>
/// <returns>字符格式的JSON数据</returns> /// <returns>字符格式的JSON数据</returns>
public static string GetXML<T>(object obj) public static string? GetXML<T>(object obj)
{ {
try try
{ {
@@ -42,7 +42,7 @@ namespace Yi.Framework.Common.Helper
XmlSerializer serializer = new XmlSerializer(typeof(T), new XmlRootAttribute(rootName)); XmlSerializer serializer = new XmlSerializer(typeof(T), new XmlRootAttribute(rootName));
StringReader reader = new StringReader(xml); StringReader reader = new StringReader(xml);
T res = (T)serializer.Deserialize(reader); T res = (T)serializer.Deserialize(reader)!;
reader.Close(); reader.Close();
reader.Dispose(); reader.Dispose();
return res; return res;

View File

@@ -6,12 +6,12 @@ namespace Yi.Framework.Common.Models
{ {
public class Result public class Result
{ {
public static IStringLocalizer<LocalLanguage> _local; public static IStringLocalizer<LocalLanguage>? _local;
public ResultCodeEnum Code { get; set; } public ResultCodeEnum Code { get; set; }
public bool Status { get; set; } public bool Status { get; set; }
public string Message { get; set; } public string? Message { get; set; }
public object Data { get; set; } public object? Data { get; set; }
public static Result Expire(ResultCodeEnum Code, string msg="") public static Result Expire(ResultCodeEnum Code, string msg="")
{ {
return new Result() { Code = Code, Status=false, Message = Get(msg, "token_expiration") }; return new Result() { Code = Code, Status=false, Message = Get(msg, "token_expiration") };
@@ -49,7 +49,7 @@ namespace Yi.Framework.Common.Models
this.Status = _Status; this.Status = _Status;
return this; return this;
} }
public Result SetData(object obj) public Result SetData(object? obj)
{ {
this.Data = obj; this.Data = obj;
return this; return this;
@@ -74,7 +74,10 @@ namespace Yi.Framework.Common.Models
{ {
if (msg=="") if (msg=="")
{ {
msg = _local[msg2]; if (_local is not null)
{
msg = _local[msg2];
}
} }
return msg; return msg;
} }
@@ -82,8 +85,8 @@ namespace Yi.Framework.Common.Models
public class Result<T> public class Result<T>
{ {
public ResultCodeEnum Code { get; set; } public ResultCodeEnum Code { get; set; }
public string Message { get; set; } public string? Message { get; set; }
public T Data { get; set; } public T? Data { get; set; }
public static Result<T> Error(string msg = "fail") public static Result<T> Error(string msg = "fail")
{ {
return new Result<T>() { Code = ResultCodeEnum.NotSuccess, Message = msg }; return new Result<T>() { Code = ResultCodeEnum.NotSuccess, Message = msg };

View File

@@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -138,7 +138,7 @@ namespace Yi.Framework.Model.RABC.Entitys
//开头大写 //开头大写
r.Name = routerName?.First().ToString().ToUpper() + routerName?.Substring(1); r.Name = routerName?.First().ToString().ToUpper() + routerName?.Substring(1);
r.Path = m.Router; r.Path = m.Router!;
r.Hidden = !m.IsShow ?? false; r.Hidden = !m.IsShow ?? false;
@@ -162,18 +162,18 @@ namespace Yi.Framework.Model.RABC.Entitys
r.Redirect = "noRedirect"; r.Redirect = "noRedirect";
r.AlwaysShow = true; r.AlwaysShow = true;
r.Component = m.Component; r.Component = m.Component!;
r.AlwaysShow = false; r.AlwaysShow = false;
} }
r.Meta = new Meta r.Meta = new Meta
{ {
Title = m.MenuName, Title = m.MenuName!,
Icon = m.MenuIcon, Icon = m.MenuIcon!,
NoCache = !m.IsCache ?? true NoCache = !m.IsCache ?? true
}; };
if (m.IsLink ?? false) if (m.IsLink ?? false)
{ {
r.Meta.link = m.Router; r.Meta.link = m.Router!;
r.AlwaysShow = false; r.AlwaysShow = false;
} }

View File

@@ -169,6 +169,10 @@ namespace Yi.Framework.Model.RABC.Entitys
/// <returns></returns> /// <returns></returns>
public bool JudgePassword(string password) public bool JudgePassword(string password)
{ {
if (this.Salt is null)
{
throw new ArgumentNullException(this.Salt);
}
var p = MD5Helper.SHA2Encode(password, Salt); var p = MD5Helper.SHA2Encode(password, Salt);
if (Password == MD5Helper.SHA2Encode(password, Salt)) if (Password == MD5Helper.SHA2Encode(password, Salt))
{ {

View File

@@ -10,11 +10,10 @@ namespace Yi.Framework.Template
{ {
public class TemplateFactory public class TemplateFactory
{ {
private List<ITemplateProvider> _templateProviders; private List<ITemplateProvider> _templateProviders=new List<ITemplateProvider>();
public void CreateTemplateProviders(Action<List<ITemplateProvider>> action) public void CreateTemplateProviders(Action<List<ITemplateProvider>> action)
{ {
_templateProviders=new List<ITemplateProvider>();
action(_templateProviders); action(_templateProviders);
} }

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.WebCore.AspNetCoreExtensions
public static void UseLocalizerService(this IApplicationBuilder app) public static void UseLocalizerService(this IApplicationBuilder app)
{ {
Result._local = app.ApplicationServices.GetService<IStringLocalizer<LocalLanguage>>(); Result._local = app.ApplicationServices.GetRequiredService<IStringLocalizer<LocalLanguage>>();
var support = new[] { "zh", "en" }; var support = new[] { "zh", "en" };
var local = new RequestLocalizationOptions().SetDefaultCulture(support[0]) var local = new RequestLocalizationOptions().SetDefaultCulture(support[0])

View File

@@ -42,7 +42,7 @@ namespace Yi.Framework.WebCore.DbExtend
var roles = userRoleMenu?.Roles; var roles = userRoleMenu?.Roles;
if (roles.IsNull()) if (roles!.IsNull())
{ {
roles = new(); roles = new();
} }

View File

@@ -33,7 +33,7 @@ namespace Yi.Framework.WebCore.FilterExtend
var logModel = new LogModel() var logModel = new LogModel()
{ {
OriginalClassName = "", OriginalClassName = "",
OriginalMethodName = actionName, OriginalMethodName = actionName??"",
Remark = $"来源于{nameof(CustomExceptionFilterAttribute)}.{nameof(OnException)}" Remark = $"来源于{nameof(CustomExceptionFilterAttribute)}.{nameof(OnException)}"
}; };
this._logger.LogError(context.Exception, $"{url}----->actionName={actionName} Message={context.Exception.Message}", JsonConvert.SerializeObject(logModel)); this._logger.LogError(context.Exception, $"{url}----->actionName={actionName} Message={context.Exception.Message}", JsonConvert.SerializeObject(logModel));

View File

@@ -30,8 +30,8 @@ namespace Yi.Framework.WebCore.FilterExtend
LogModel logModel = new LogModel() LogModel logModel = new LogModel()
{ {
OriginalClassName = controllerName, OriginalClassName = controllerName??"",
OriginalMethodName = actionName, OriginalMethodName = actionName ?? "",
Remark = $"来源于{nameof(LogActionFilterAttribute)}.{nameof(OnActionExecuting)}" Remark = $"来源于{nameof(LogActionFilterAttribute)}.{nameof(OnActionExecuting)}"
}; };

View File

@@ -53,7 +53,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
//通过鉴权之后,开始赋值 //通过鉴权之后,开始赋值
_currentUser.IsAuthenticated = true; _currentUser.IsAuthenticated = true;
_currentUser.Id = claims.GetClaim(JwtRegisteredClaimNames.Sid) is null ? 0 : Convert.ToInt64(claims.GetClaim(JwtRegisteredClaimNames.Sid)); _currentUser.Id = claims.GetClaim(JwtRegisteredClaimNames.Sid) is null ? 0 : Convert.ToInt64(claims.GetClaim(JwtRegisteredClaimNames.Sid));
_currentUser.UserName = claims.GetClaim(SystemConst.UserName); _currentUser.UserName = claims.GetClaim(SystemConst.UserName)??"";
_currentUser.Permission = claims.GetClaims(SystemConst.PermissionClaim); _currentUser.Permission = claims.GetClaims(SystemConst.PermissionClaim);
_currentUser.TenantId = claims.GetClaim(SystemConst.TenantId) is null ? null : Guid.Parse(claims.GetClaim(SystemConst.TenantId)!); _currentUser.TenantId = claims.GetClaim(SystemConst.TenantId) is null ? null : Guid.Parse(claims.GetClaim(SystemConst.TenantId)!);
await _next(context); await _next(context);