소스 검색

添加json对象为null返回空字符串方法

DuGuYang 1 년 전
부모
커밋
ac8242cdea
3개의 변경된 파일39개의 추가작업 그리고 0개의 파일을 삭제
  1. 0 0
      Areas/Api/Controllers/Main/MerchantAddInfoController.cs
  2. 22 0
      Util/Extension/JsonDataExtension.cs
  3. 17 0
      Util/Extension/StringExtension.cs

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
Areas/Api/Controllers/Main/MerchantAddInfoController.cs


+ 22 - 0
Util/Extension/JsonDataExtension.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using LitJson;
+
+namespace MySystem
+{
+    public static class JsonDataExtension
+    {
+        
+        #region 获取是否存在Key, isFlag判断是抛出异常还是返回""
+        public static object getItem(this JsonData input, string key) 
+        {
+            string jsonString = input.ToJson();
+            if(jsonString.Contains("\"" + key + "\""))
+            {
+                return input[key];
+            }
+            return "";
+        }
+        #endregion
+    }
+}

+ 17 - 0
Util/Extension/StringExtension.cs

@@ -0,0 +1,17 @@
+
+namespace MySystem
+{
+    public static class StringExtension
+    {
+        #region sql条件拼装
+        public static string Like(this string input, string Field, string Value) 
+        {
+            if (!string.IsNullOrEmpty(Value))
+            {
+                input += " and " + Field + " like '%" + Value + "%'";
+            }
+            return input;
+        }
+        #endregion
+    }
+}

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.