From 906eac78e278d76f3cff62bf2a60413828f5822e Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Mon, 2 Sep 2019 16:10:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B9=E5=86=99mongodb=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=97=B6=E7=9A=84=E7=AC=AC=E4=B8=80=E6=AC=A1finekit?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/ParameterKit.java | 11 ++++++++ .../fanruan/api/design/macro/UIConstants.java | 1 + .../com/fanruan/api/err/JSONException.java | 11 ++++++++ .../java/com/fanruan/api/json/JSONArray.java | 26 +++++++++++++++++++ .../java/com/fanruan/api/json/JSONObject.java | 16 ++++++++++++ .../java/com/fanruan/api/util/CodeKit.java | 15 +++++++++++ .../java/com/fanruan/api/util/DateKit.java | 18 +++++++++++++ .../java/com/fanruan/api/util/GeneralKit.java | 12 +++++++++ .../com/fanruan/api/util/CodeKitTest.java | 12 +++++++++ .../com/fanruan/api/util/DateKitTest.java | 18 +++++++++++++ .../com/fanruan/api/util/GeneralKitTest.java | 7 +++++ 11 files changed, 147 insertions(+) create mode 100644 src/main/java/com/fanruan/api/err/JSONException.java create mode 100644 src/main/java/com/fanruan/api/json/JSONArray.java create mode 100644 src/main/java/com/fanruan/api/json/JSONObject.java create mode 100644 src/main/java/com/fanruan/api/util/CodeKit.java create mode 100644 src/main/java/com/fanruan/api/util/DateKit.java create mode 100644 src/test/java/com/fanruan/api/util/CodeKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/DateKitTest.java diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 963e152..86bff51 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -89,4 +89,15 @@ public class ParameterKit { public static @NotNull ParameterMapNameSpace createParameterMapNameSpace(ParameterProvider[] ps) { return ParameterMapNameSpace.create(ps); } + /** + * 获得新的参数集合 + * + * @param paramTexts sql语句 + * @param ps 旧的参数集合 + * @return 新参数集合 + */ + public static Parameter[] analyzeAndUnionSameParameters(String[] paramTexts, + Parameter[] ps){ + return ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps); + } } diff --git a/src/main/java/com/fanruan/api/design/macro/UIConstants.java b/src/main/java/com/fanruan/api/design/macro/UIConstants.java index 613600f..96206c1 100644 --- a/src/main/java/com/fanruan/api/design/macro/UIConstants.java +++ b/src/main/java/com/fanruan/api/design/macro/UIConstants.java @@ -4,5 +4,6 @@ import java.awt.*; public class UIConstants { Color UIPOPUPMENU_LINE_COLOR = new Color(13158861); + Color LINE_COLOR = new Color(153, 153, 153); int ARC = 0; } diff --git a/src/main/java/com/fanruan/api/err/JSONException.java b/src/main/java/com/fanruan/api/err/JSONException.java new file mode 100644 index 0000000..9de7f2e --- /dev/null +++ b/src/main/java/com/fanruan/api/err/JSONException.java @@ -0,0 +1,11 @@ +package com.fanruan.api.err; + +public class JSONException extends com.fr.json.JSONException{ + public JSONException(String var1) { + super(var1); + } + + public JSONException(Throwable var1) { + super(var1); + } +} diff --git a/src/main/java/com/fanruan/api/json/JSONArray.java b/src/main/java/com/fanruan/api/json/JSONArray.java new file mode 100644 index 0000000..3199f27 --- /dev/null +++ b/src/main/java/com/fanruan/api/json/JSONArray.java @@ -0,0 +1,26 @@ +package com.fanruan.api.json; + +import java.util.*; +import java.lang.*; + +public class JSONArray extends com.fr.json.JSONArray{ + public JSONArray(){ + + } + + public JSONArray(Collection collection){ + super(collection); + } + + public JSONArray(List list) { + super(list); + } + + public JSONArray(Object array) { + super(array); + } + + public JSONArray(String json) { + super(json); + } +} diff --git a/src/main/java/com/fanruan/api/json/JSONObject.java b/src/main/java/com/fanruan/api/json/JSONObject.java new file mode 100644 index 0000000..31a53ba --- /dev/null +++ b/src/main/java/com/fanruan/api/json/JSONObject.java @@ -0,0 +1,16 @@ +package com.fanruan.api.json; +import java.util.*; + +public class JSONObject extends com.fr.json.JSONObject{ + public JSONObject(){ + + } + + public JSONObject(Map map){ + super(map); + } + + public JSONObject(String json){ + super(json); + } +} diff --git a/src/main/java/com/fanruan/api/util/CodeKit.java b/src/main/java/com/fanruan/api/util/CodeKit.java new file mode 100644 index 0000000..b819eb4 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/CodeKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.util; + +import com.fr.stable.CodeUtils; +import com.fr.stable.CommonCodeUtils; + +public class CodeKit { + /** + * 给字符串解密 + * @param passwordText 待解密的字符串 + * @return 解密后的字符串 + */ + public static String passwordDecode(String passwordText) { + return CodeUtils.passwordDecode(passwordText); + } +} diff --git a/src/main/java/com/fanruan/api/util/DateKit.java b/src/main/java/com/fanruan/api/util/DateKit.java new file mode 100644 index 0000000..072e6e0 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/DateKit.java @@ -0,0 +1,18 @@ +package com.fanruan.api.util; + +import com.fr.general.DateUtils; + +import java.util.Date; + +public class DateKit { + /** + * 将字符串转化为日期 + * + * @param str 字符串 + * @param returnNull 转化失败的时候是否返回null + * @return 将字符串转化为相应的日期值 + */ + public static Date string2Date(String str, boolean returnNull) { + return DateUtils.string2Date(str, returnNull); + } +} diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 30a74bb..f86fa54 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -2,7 +2,9 @@ package com.fanruan.api.util; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; +import com.fr.stable.CommonUtils; import com.fr.third.guava.base.Objects; +import com.fr.stable.StableUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -69,4 +71,14 @@ public class GeneralKit { public static int compare(Object obj1, Object obj2) { return ComparatorUtils.compare(obj1, obj2); } + + /** + * 将一个数组中的元素按照给定的连接符连接成一个字符串 + * @param array 数组 + * @param se 连接符 + * @return 连接后的字符串 + */ + public static String join(Object[] array, String se) { + return StableUtils.join(array, se); + } } diff --git a/src/test/java/com/fanruan/api/util/CodeKitTest.java b/src/test/java/com/fanruan/api/util/CodeKitTest.java new file mode 100644 index 0000000..10853e6 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/CodeKitTest.java @@ -0,0 +1,12 @@ +package com.fanruan.api.util; + +import com.fr.stable.CommonCodeUtils; +import org.junit.Assert; +import org.junit.Test; + +public class CodeKitTest { + @Test + public void passwordDecode(String passwordText) { + Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123); + } +} diff --git a/src/test/java/com/fanruan/api/util/DateKitTest.java b/src/test/java/com/fanruan/api/util/DateKitTest.java new file mode 100644 index 0000000..31ae43c --- /dev/null +++ b/src/test/java/com/fanruan/api/util/DateKitTest.java @@ -0,0 +1,18 @@ +package com.fanruan.api.util; + +import java.util.Date; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import org.junit.Assert; +import org.junit.Test; + +public class DateKitTest { + @Test + public void string2Date() throws Exception{ + DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd"); + Date myDate = dateFormat2.parse("2019-02-20"); + Assert.assertEquals(DateKit.string2Date("2019-02-20", false), myDate); + Assert.assertEquals(DateKit.string2Date("abcd", false), new Date()); + Assert.assertEquals(DateKit.string2Date("abcd", true), null); + } +} diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 7bbefa6..b4457c1 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -39,4 +39,11 @@ public class GeneralKitTest extends Prepare { Assert.assertEquals(GeneralKit.compare(s,s3),0); Assert.assertEquals(GeneralKit.compare(s,s2),1); } + + @Test + public void join() { + Object obj [] = {1,2,3,4}; + String result = "1-2-3-4"; + Assert.assertEquals(GeneralKit.join(obj, "-"),result); + } } \ No newline at end of file