Browse Source

修改命名

CrazyIter 5 years ago
parent
commit
530debc4ff

+ 3 - 2
TEAMModelOS.SDK/Helper/Security/TmdCrypt/TmdCrypt.cs

@@ -7,12 +7,13 @@ namespace TEAMModelOS.SDK.Helper.Security.TmdCrypt
 {
     public static class TmdCrypt
     {
-        private static string doSHA256AndBase64(string password)
+        private static string DoSHA256AndBase64(string password)
         {
             SHA256 sha256 = new SHA256CryptoServiceProvider();//建立一個SHA256
             byte[] source = Encoding.Default.GetBytes(password);//將字串轉為Byte[]
             byte[] crypto = sha256.ComputeHash(source);//進行SHA256加密
             string resultSha256 = Convert.ToBase64String(crypto);
+            sha256.Dispose();
             return resultSha256;
         }
 
@@ -22,7 +23,7 @@ namespace TEAMModelOS.SDK.Helper.Security.TmdCrypt
         /// <param name="password"></param>
         /// <returns></returns>
         public static string Encrypt(string password) {
-           return doSHA256AndBase64(doSHA256AndBase64(doSHA256AndBase64(password) + doSHA256AndBase64(password)) + doSHA256AndBase64(password));
+           return DoSHA256AndBase64(DoSHA256AndBase64(DoSHA256AndBase64(password) + DoSHA256AndBase64(password)) + DoSHA256AndBase64(password));
         }
     }
 }

+ 9 - 11
TEAMModelOS.SDK/Module/AzureCosmosDB/Implements/AzureCosmosDBRepository.cs

@@ -567,9 +567,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
         {
             Type t = typeof(T);
             List<T> objs = new List<T>();
-            Boolean open = IsPk;
             await InitializeCollection<T>();
-
             StringBuilder sql = new StringBuilder("select * from c where 1=1 ");
             if (dict != null)
             {
@@ -592,17 +590,17 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
         {
             Type s = obj.GetType();
             TypeCode typeCode = Type.GetTypeCode(s);
-            switch (typeCode)
+            return typeCode switch
             {
-                case TypeCode.String: return "and c." + key + "=" + "'" + obj.ToString() + "'";
-                case TypeCode.Int32: return "and c." + key + "=" + int.Parse(obj.ToString());
-                case TypeCode.Double: return "and c." + key + "=" + double.Parse(obj.ToString());
+                TypeCode.String => "and c." + key + "=" + "'" + obj.ToString() + "'",
+                TypeCode.Int32 => "and c." + key + "=" + int.Parse(obj.ToString()),
+                TypeCode.Double => "and c." + key + "=" + double.Parse(obj.ToString()),
                 //case TypeCode.Byte: return "and c." + key + "=" + (Byte)obj ;   
-                case TypeCode.Boolean: return "and c." + key + "=" + bool.Parse(obj.ToString());
-                case TypeCode.DateTime: return "and c." + key + "=" + (DateTime)obj;
-                case TypeCode.Int64: return "and c." + key + "=" + long.Parse(obj.ToString());
-                default: return null;
-            }
+                TypeCode.Boolean => "and c." + key + "=" + bool.Parse(obj.ToString()),
+                TypeCode.DateTime => "and c." + key + "=" + (DateTime)obj,
+                TypeCode.Int64 => "and c." + key + "=" + long.Parse(obj.ToString()),
+                _ => null,
+            };
         }
     }
 }

+ 4 - 0
TEAMModelOS.Service/.editorconfig

@@ -0,0 +1,4 @@
+[*.cs]
+
+# IDE1006: 命名样式
+dotnet_diagnostic.IDE1006.severity = none

+ 1 - 2
TEAMModelOS/Controllers/Core/StudentController.cs

@@ -46,8 +46,7 @@ namespace TEAMModelOS.Controllers.Syllabus
         public async Task<BaseJosnRPCResponse> FindStudent(JosnRPCRequest<Dictionary<string, object>> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            StringBuilder sql = new StringBuilder();
-            if (request.@params.TryGetValue("schoolCode", out object schoolCode))
+            if (request.@params.TryGetValue("schoolCode", out object _))
             {
                 List<Student> data = await azureCosmosDBRepository.FindByDict<Student>(request.@params,false);
                 return builder.Data(data).build();

+ 11 - 7
TEAMModelOS/Controllers/Syllabus/VolumeController.cs

@@ -55,8 +55,10 @@ namespace TEAMModelOS.Controllers.Syllabus
                     request.@params.volumeCode = key;
                 }
             }
-            List<Volume> volumes = new List<Volume>();
-            volumes.Add(request.@params);
+            List<Volume> volumes = new List<Volume>
+            {
+                request.@params
+            };
             List<Volume> volume = await azureCosmosDBRepository.SaveAll<Volume>(volumes);
             return builder.Data(volume.IsEmpty() ? null : volume[0]).build();
         }
@@ -75,15 +77,17 @@ namespace TEAMModelOS.Controllers.Syllabus
                 if (request.@params.type == 0)
                 {
                     request.@params.status = 0;
-                    List<Volume> volumes = new List<Volume>();
-                    volumes.Add(request.@params);
-                    List<Volume> volume = await azureCosmosDBRepository.SaveAll<Volume>(volumes);
+                    List<Volume> volumes = new List<Volume>
+                    {
+                        request.@params
+                    };
+                    await azureCosmosDBRepository.SaveAll<Volume>(volumes);
                     flag = true;
                 }
                 else
                 {
                     await azureCosmosDBRepository.DeleteAsync<Volume>(request.@params.id, request.@params.schoolCode);
-                    List<SyllabusNode> syllabusNodes = await azureCosmosDBRepository.DeleteAll<SyllabusNode>(new Dictionary<string, object>() { { "volumeCode", request.@params.id } });
+                    await azureCosmosDBRepository.DeleteAll<SyllabusNode>(new Dictionary<string, object>() { { "volumeCode", request.@params.id } });
                     flag = true;
                 }
             }
@@ -98,7 +102,7 @@ namespace TEAMModelOS.Controllers.Syllabus
         public async Task<BaseJosnRPCResponse> Find(JosnRPCRequest<Dictionary<string, object>> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            List<Volume> volumes = null;
+            List<Volume> volumes ;
             if (request.@params.TryGetValue("schoolCode", out _))
             {
                 volumes = await azureCosmosDBRepository.FindByParams<Volume>(request.@params);