소스 검색

😁代码调整与优化

zuohuaijun 2 년 전
부모
커밋
86c93904ba

+ 3 - 3
Admin.NET/Admin.NET.Application/Configuration/App.json

@@ -39,9 +39,9 @@
     "WorkerPrefix": "adminnet_" // 缓存前缀
   },
   "Cryptogram": {
-    "StrongPassword": false, //是否开启密码强度验证
-    "PasswordStrengthValidation": "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~@#$%\\*-\\+=:,\\\\?\\[\\]\\{}]).{6,16}$", //密码强度验证正则表达式,必须须包含大小写字母、数字和特殊字符的组合,长度在6-16之间
-    "PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合,长度在6-16之间", //密码强度验证消息提示
+    "StrongPassword": false, // 是否开启密码强度验证
+    "PasswordStrengthValidation": "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~@#$%\\*-\\+=:,\\\\?\\[\\]\\{}]).{6,16}$", // 密码强度验证正则表达式,必须须包含大小写字母、数字和特殊字符的组合,长度在6-16之间
+    "PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合,长度在6-16之间", // 密码强度验证消息提示
     "CryptoType": "SM2", // 密码加密算法:MD5、SM2、SM4
     "PublicKey": "04F6E0C3345AE42B51E06BF50B98834988D54EBC7460FE135A48171BC0629EAE205EEDE253A530608178A98F1E19BB737302813BA39ED3FA3C51639D7A20C7391A", // 公钥
     "PrivateKey": "3690655E33D5EA3D9A4AE1A1ADD766FDEA045CDEAA43A9206FB8C430CEFE0D94" // 私钥

+ 3 - 3
Admin.NET/Admin.NET.Application/Configuration/Email.json

@@ -7,9 +7,9 @@
     "DefaultFromEmail": "zuohuaijun@163.com", // 默认发件者邮箱
     "DefaultToEmail": "515096995@qq.com", // 默认接收人邮箱
     "EnableSsl": true, // 启用SSL
-    "UseDefaultCredentials": false, //是否使用默认凭据
-    "UserName": "", // 邮箱账号
+    "UseDefaultCredentials": false, // 是否使用默认凭据
+    "UserName": "zuohuaijun@163.com", // 邮箱账号
     "Password": "", // 邮箱授权码
-    "DefaultFromName": "系统邮件" // 默认邮件标题
+    "DefaultFromName": "Admin.NET 通用权限开发平台" // 默认邮件标题
   }
 }

+ 2 - 2
Admin.NET/Admin.NET.Application/Configuration/Swagger.json

@@ -2,11 +2,11 @@
   "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json",
 
   "SpecificationDocumentSettings": {
-    "DocumentTitle": "Admin.NET 框架",
+    "DocumentTitle": "Admin.NET 通用权限开发平台",
     "GroupOpenApiInfos": [
       {
         "Group": "Default",
-        "Title": "Admin.NET",
+        "Title": "Admin.NET 通用权限开发平台",
         "Description": "让 .NET 开发更简单、更通用、更流行。前后端分离架构(.NET6/Vue3),开箱即用紧随前沿技术。<br/><a href='https://gitee.com/zuohuaijun/Admin.NET/'>https://gitee.com/zuohuaijun/Admin.NET</a>",
         "Version": "1.0.0",
         "TermsOfService": "https://dotnetchina.gitee.io/furion/",

+ 0 - 14
Admin.NET/Admin.NET.Core/Entity/SysLogAudit.cs

@@ -54,18 +54,4 @@ public class SysLogAudit : EntityBase
     /// </summary>
     [SugarColumn(ColumnDescription = "审计时间")]
     public DateTime? AuditTime { get; set; }
-
-    /// <summary>
-    /// 账号
-    /// </summary>
-    [SugarColumn(ColumnDescription = "账号", Length = 32)]
-    [MaxLength(32)]
-    public string? Account { get; set; }
-
-    /// <summary>
-    /// 真实姓名
-    /// </summary>
-    [SugarColumn(ColumnDescription = "真实姓名", Length = 32)]
-    [MaxLength(32)]
-    public string? RealName { get; set; }
 }

+ 7 - 7
Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs

@@ -277,8 +277,8 @@ public class SysAuthService : IDynamicApiController, ITransient
     [DisplayName("Swagger登录提交")]
     public async Task<int> SwaggerSubmitUrl([FromForm] SpecificationAuth auth)
     {
-        try
-        {
+        //try
+        //{
             _sysCacheService.Set(CommonConst.SysCaptcha, false);
 
             await Login(new LoginInput
@@ -290,10 +290,10 @@ public class SysAuthService : IDynamicApiController, ITransient
             _sysCacheService.Remove(CommonConst.SysCaptcha);
 
             return 200;
-        }
-        catch (Exception)
-        {
-            return 401;
-        }
+        //}
+        //catch (Exception)
+        //{
+        //    return 401;
+        //}
     }
 }

+ 3 - 2
Admin.NET/Admin.NET.Core/Service/Org/SysOrgService.cs

@@ -71,10 +71,11 @@ public class SysOrgService : IDynamicApiController, ITransient
             // 递归禁用没权限的机构(防止用户修改或创建无权的机构和用户)
             HandlerOrgTree(orgTree, userOrgIdList);
         }
-        if (!(sysOrg is null)) 
+
+        if (sysOrg != null)
         {
             sysOrg.Children = orgTree;
-            orgTree = new List<SysOrg>{ sysOrg };
+            orgTree = new List<SysOrg> { sysOrg };
         }
         return orgTree;
     }

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/Sms/SysSmsService.cs

@@ -71,9 +71,9 @@ public class SysSmsService : IDynamicApiController, ITransient
                 throw Oops.Oh($"短信发送失败:{sendSmsResponse.Body.Code}-{sendSmsResponse.Body.Message}");
             }
         }
-        catch (Exception e)
+        catch (Exception ex)
         {
-            throw Oops.Oh($"短信发送失败:{e.Message}");
+            throw Oops.Oh($"短信发送失败:{ex.Message}");
         }
 
         await Task.CompletedTask;

+ 4 - 9
Admin.NET/Admin.NET.Core/Service/User/SysUserService.cs

@@ -227,17 +227,12 @@ public class SysUserService : IDynamicApiController, ITransient
                 throw Oops.Oh(ErrorCodeEnum.D1004);
         }
 
-        //强密码验证
+        // 验证密码强度
         if (CryptogramUtil.StrongPassword)
         {
-            if (input.PasswordNew.TryValidate(CryptogramUtil.PasswordStrengthValidation))
-            {
-                user.Password = CryptogramUtil.Encrypt(input.PasswordNew);
-            }
-            else
-            {
-                throw Oops.Oh(CryptogramUtil.PasswordStrengthValidationMsg);
-            }
+            user.Password = input.PasswordNew.TryValidate(CryptogramUtil.PasswordStrengthValidation)
+                ? CryptogramUtil.Encrypt(input.PasswordNew)
+                : throw Oops.Oh(CryptogramUtil.PasswordStrengthValidationMsg);
         }
         else
         {

+ 9 - 9
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -176,35 +176,35 @@ public static class SqlSugarSetup
                     if (id == null || (long)id == 0)
                         entityInfo.SetValue(YitIdHelper.NextId());
                 }
-                if (entityInfo.PropertyName == "CreateTime")
+                if (entityInfo.PropertyName == nameof(EntityBase.CreateTime))
                     entityInfo.SetValue(DateTime.Now);
                 if (App.User != null)
                 {
-                    if (entityInfo.PropertyName == "TenantId")
+                    if (entityInfo.PropertyName == nameof(EntityTenantId.TenantId))
                     {
                         var tenantId = ((dynamic)entityInfo.EntityValue).TenantId;
                         if (tenantId == null || tenantId == 0)
                             entityInfo.SetValue(App.User.FindFirst(ClaimConst.TenantId)?.Value);
                     }
-                    else if (entityInfo.PropertyName == "CreateUserId")
+                    else if (entityInfo.PropertyName == nameof(EntityBase.CreateUserId))
                     {
                         var createUserId = ((dynamic)entityInfo.EntityValue).CreateUserId;
                         if (createUserId == 0 || createUserId == null)
                             entityInfo.SetValue(App.User.FindFirst(ClaimConst.UserId)?.Value);
                     }
-                    else if (entityInfo.PropertyName == "CreateUserName")
+                    else if (entityInfo.PropertyName == nameof(EntityBase.CreateUserName))
                     {
                         var createUserName = ((dynamic)entityInfo.EntityValue).CreateUserName;
                         if (string.IsNullOrEmpty(createUserName))
                             entityInfo.SetValue(App.User.FindFirst(ClaimConst.RealName)?.Value);
                     }
-                    else if (entityInfo.PropertyName == "CreateOrgId")
+                    else if (entityInfo.PropertyName == nameof(EntityBaseData.CreateOrgId))
                     {
                         var createOrgId = ((dynamic)entityInfo.EntityValue).CreateOrgId;
                         if (createOrgId == 0 || createOrgId == null)
                             entityInfo.SetValue(App.User.FindFirst(ClaimConst.OrgId)?.Value);
                     }
-                    else if (entityInfo.PropertyName == "CreateOrgName")
+                    else if (entityInfo.PropertyName == nameof(EntityBaseData.CreateOrgName))
                     {
                         var createOrgName = ((dynamic)entityInfo.EntityValue).CreateOrgName;
                         if (string.IsNullOrEmpty(createOrgName))
@@ -214,11 +214,11 @@ public static class SqlSugarSetup
             }
             if (entityInfo.OperationType == DataFilterType.UpdateByObject)
             {
-                if (entityInfo.PropertyName == "UpdateTime")
+                if (entityInfo.PropertyName == nameof(EntityBase.UpdateTime))
                     entityInfo.SetValue(DateTime.Now);
-                else if (entityInfo.PropertyName == "UpdateUserId")
+                else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserId))
                     entityInfo.SetValue(App.User?.FindFirst(ClaimConst.UserId)?.Value);
-                else if (entityInfo.PropertyName == "UpdateUserName")
+                else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserName))
                     entityInfo.SetValue(App.User?.FindFirst(ClaimConst.RealName)?.Value);
             }
         };

+ 7 - 1
Admin.NET/Admin.NET.Core/Util/CodeGenUtil.cs

@@ -285,7 +285,13 @@ public static class CodeGenUtil
     {
         var columnList = new List<string>()
         {
-            "CreateOrgId", "TenantId", "CreateTime", "UpdateTime", "CreateUserId", "UpdateUserId", "IsDelete"
+            nameof(EntityBaseData.CreateOrgId),
+            nameof(EntityTenant.TenantId),
+            nameof(EntityBase.CreateTime),
+            nameof(EntityBase.UpdateTime),
+            nameof(EntityBase.CreateUserId),
+            nameof(EntityBase.UpdateUserId),
+            nameof(EntityBase.IsDelete)
         };
         return columnList.Contains(columnName);
     }