From f8ee9013a45c31c14b8f6caf94c47aa11d670838 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Fri, 7 Feb 2020 00:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++- .../aop/util/InterfaceProxyFactoryUtil.java | 5 +- .../org/panda/code/uitl/DateUtilTest.java | 68 +++++++++++++++++++ .../panda/beans/exception/BeansException.java | 1 + .../java/org/panda/beans/util/ClassUtil.java | 6 +- panda-code/README.md | 1 + .../java/org/panda/code/uitl/CodecUtil.java | 4 +- .../panda/code/uitl/DataValidatorUtil.java | 5 +- .../java/org/panda/code/uitl/DateUtil.java | 16 +++-- .../java/org/panda/code/uitl/JsonUtil.java | 2 + .../java/org/panda/code/uitl/JvmUtil.java | 22 ++++-- .../java/org/panda/code/uitl/StreamUtil.java | 1 + .../java/org/panda/code/uitl/TestUtil.java | 6 +- .../panda/code/uitl/{ => http}/HttpKit.java | 3 +- .../panda/code/uitl/{ => http}/HttpUtil.java | 2 +- .../org/panda/code/uitl/http/HttpsClient.java | 11 ++- .../java/org/panda/code/uitl/os/NetUtil.java | 2 +- .../org/panda/code/uitl/DateUtilTest.java | 67 ++++++++++++++++++ panda-jdbc/panda-jdbc.iml | 7 -- .../main/java/org/panda/jdbc/JdbcLoad.java | 3 + .../main/java/org/panda/jdbc/JdbcUtils.java | 2 +- .../panda/jdbc/config/DbConfigConstant.java | 7 +- .../java/org/panda/jdbc/pool/JdbcPool.java | 1 + .../java/org/panda/jdbc/sql/BeanSqlUtil.java | 9 +-- .../java/org/panda/jdbc/sql/SqlConstant.java | 5 ++ .../jdbc/sql/builder/AbstractDbBuiler.java | 2 +- panda-web/src/main/java/org/panda/App.java | 13 ---- .../java/org/panda/web/helper/AopHelper.java | 3 +- .../java/org/panda/web/helper/BeanHelper.java | 1 + .../org/panda/web/helper/ConfigHelper.java | 1 + .../panda/web/helper/ControllerHelper.java | 1 + .../org/panda/web/helper/HelperLoader.java | 3 + .../java/org/panda/web/helper/IocHelper.java | 1 + .../org/panda/web/helper/RequestHelper.java | 3 +- .../org/panda/web/helper/ServletHelper.java | 1 + .../org/panda/web/helper/UploadHelper.java | 1 + .../main/java/org/panda/web/mode/Data.java | 1 + .../java/org/panda/web/mode/FileParam.java | 21 ++++-- .../java/org/panda/web/mode/FormParam.java | 3 + .../main/java/org/panda/web/mode/Handler.java | 1 + .../main/java/org/panda/web/mode/Param.java | 5 +- .../main/java/org/panda/web/mode/Request.java | 1 + .../main/java/org/panda/web/mode/View.java | 1 + .../panda/web/servlet/DispatcherServlet.java | 17 +++-- 44 files changed, 271 insertions(+), 74 deletions(-) create mode 100644 panda-aop/src/test/java/org/panda/code/uitl/DateUtilTest.java create mode 100644 panda-code/README.md rename panda-code/src/main/java/org/panda/code/uitl/{ => http}/HttpKit.java (98%) rename panda-code/src/main/java/org/panda/code/uitl/{ => http}/HttpUtil.java (98%) create mode 100644 panda-code/src/tests/java/org/panda/code/uitl/DateUtilTest.java delete mode 100644 panda-web/src/main/java/org/panda/App.java diff --git a/README.md b/README.md index 596f839..ec98f41 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -#熊猫框架 +熊猫框架 +==================== -##开发环境 +###开发环境 1. mavne3 +2. jdk1.8 + + + diff --git a/panda-aop/src/main/java/org/panda/aop/util/InterfaceProxyFactoryUtil.java b/panda-aop/src/main/java/org/panda/aop/util/InterfaceProxyFactoryUtil.java index 8db2868..47d51b2 100644 --- a/panda-aop/src/main/java/org/panda/aop/util/InterfaceProxyFactoryUtil.java +++ b/panda-aop/src/main/java/org/panda/aop/util/InterfaceProxyFactoryUtil.java @@ -11,6 +11,7 @@ import java.lang.reflect.Proxy; /** * 为接口提供动态代理方式,可以尝试模拟 JPA * Created by qi_liang on 2018/4/23. + * @author qi */ public class InterfaceProxyFactoryUtil implements InvocationHandler { @@ -51,7 +52,9 @@ public class InterfaceProxyFactoryUtil implements InvocationHandler { return result; } - //后置增强 + /** + * 后置增强 + */ private void after(){ System.out.println("后置增强"); } diff --git a/panda-aop/src/test/java/org/panda/code/uitl/DateUtilTest.java b/panda-aop/src/test/java/org/panda/code/uitl/DateUtilTest.java new file mode 100644 index 0000000..009afe8 --- /dev/null +++ b/panda-aop/src/test/java/org/panda/code/uitl/DateUtilTest.java @@ -0,0 +1,68 @@ +package org.panda.code.uitl; + +import org.junit.Test; + +import java.text.ParseException; +import java.util.Date; + +/** + * 核心包-日期工具类测试 + * @author qi + * + */ +public class DateUtilTest { + + /** + * 日期格式化,采用默认格式yyyy-MM-dd HH:mm:ss + */ + @Test + public void getDateToStr() { + String dateToStr = DateUtil.getDateToStr(new Date()); + System.out.println(dateToStr); + String dateToStr2 = DateUtil.getDateToStr(null); + System.out.println(dateToStr2); + + } + + /** + *日期格式化 + */ + @Test + public void getDateToStr1() { + String dateToStr = DateUtil.getDateToStr(new Date(),"yyyy-MM-dd HH:mm"); + System.out.println(dateToStr); + } + + /** + * 字符串转日期 + */ + @Test + public void strToDate() { + try { + Date date = DateUtil.strToDate("2020-01-20 22:51","yyyy-MM-dd HH:mm"); + System.out.println(date); + } catch (ParseException e) { + e.printStackTrace(); + } + + } + + @Test + public void disparityDay() { + try { + Date starDate = DateUtil.strToDate("2019-01-22","yyyy-MM-dd"); + Date endDate = DateUtil.strToDate("2019-02-24","yyyy-MM-dd"); + System.out.println(endDate); + int day = DateUtil.disparityDay(starDate,endDate); + System.out.println(day); + } catch (ParseException e) { + e.printStackTrace(); + } + + + } + + @Test + public void dataFormat() { + } +} diff --git a/panda-beans/src/main/java/org/panda/beans/exception/BeansException.java b/panda-beans/src/main/java/org/panda/beans/exception/BeansException.java index 3726e24..f66b231 100644 --- a/panda-beans/src/main/java/org/panda/beans/exception/BeansException.java +++ b/panda-beans/src/main/java/org/panda/beans/exception/BeansException.java @@ -2,6 +2,7 @@ package org.panda.beans.exception; /** * bean 自定义异常 + * @author qi */ public class BeansException extends Exception{ diff --git a/panda-beans/src/main/java/org/panda/beans/util/ClassUtil.java b/panda-beans/src/main/java/org/panda/beans/util/ClassUtil.java index e2e13fc..2794b6f 100644 --- a/panda-beans/src/main/java/org/panda/beans/util/ClassUtil.java +++ b/panda-beans/src/main/java/org/panda/beans/util/ClassUtil.java @@ -76,9 +76,9 @@ public class ClassUtil { String packagePath = url.getPath().replace("%20",""); addClass(classSet,packagePath,packageName); }else if ("".equals(protocol)){ - JarURLConnection jarURLConnection =(JarURLConnection) url.openConnection(); - if (jarURLConnection!=null){ - JarFile jarFile = jarURLConnection.getJarFile(); + JarURLConnection jarUrlConnection =(JarURLConnection) url.openConnection(); + if (jarUrlConnection!=null){ + JarFile jarFile = jarUrlConnection.getJarFile(); if (jarFile!=null){ Enumeration jarEntries = jarFile.entries(); while (jarEntries.hasMoreElements()){ diff --git a/panda-code/README.md b/panda-code/README.md new file mode 100644 index 0000000..726e534 --- /dev/null +++ b/panda-code/README.md @@ -0,0 +1 @@ +##熊猫框架-核心包 diff --git a/panda-code/src/main/java/org/panda/code/uitl/CodecUtil.java b/panda-code/src/main/java/org/panda/code/uitl/CodecUtil.java index c36c060..dd0ad43 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/CodecUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/CodecUtil.java @@ -21,7 +21,7 @@ public final class CodecUtil { * @param source * @return */ - public static String encodeURL(String source){ + public static String encodeUrl(String source){ String target; try { @@ -38,7 +38,7 @@ public final class CodecUtil { * @param source * @return */ - public static String decodeURL(String source){ + public static String decodeUrl(String source){ String target; try { diff --git a/panda-code/src/main/java/org/panda/code/uitl/DataValidatorUtil.java b/panda-code/src/main/java/org/panda/code/uitl/DataValidatorUtil.java index 5e74fe7..b36f180 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/DataValidatorUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/DataValidatorUtil.java @@ -4,6 +4,7 @@ import java.util.regex.Pattern; /** * Created by qi_liang on 2018/1/25. + * @author qi */ public class DataValidatorUtil { @@ -103,7 +104,7 @@ public class DataValidatorUtil { * @param idCard * @return 校验通过返回true,否则返回false */ - public static boolean isIDCard(String idCard) { + public static boolean isIdCard(String idCard) { return Pattern.matches(REGEX_ID_CARD, idCard); } @@ -123,7 +124,7 @@ public class DataValidatorUtil { * @param ipAddr * @return */ - public static boolean isIPAddr(String ipAddr) { + public static boolean isIpAddr(String ipAddr) { return Pattern.matches(REGEX_IP_ADDR, ipAddr); } diff --git a/panda-code/src/main/java/org/panda/code/uitl/DateUtil.java b/panda-code/src/main/java/org/panda/code/uitl/DateUtil.java index f877304..ed33161 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/DateUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/DateUtil.java @@ -7,10 +7,12 @@ import org.slf4j.LoggerFactory; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.Date; /** * Created by qi_liang on 2018/1/26. + * @author qi */ public class DateUtil { @@ -67,14 +69,19 @@ public class DateUtil { } /** - * + * 两个日期相差多少日 * @param startDate * @param endDate * @return */ - public static int disparityDay(Date startDate,Date endDate){ - int day = (int)(endDate.getTime()-startDate.getTime())/(24*60*60*1000); - return day; + public static int disparityDay(Date startDate,Date endDate){ + long endTime = endDate.getTime(); + long starTime = startDate.getTime(); + if (endTime>starTime) { + int day = new Long((endDate.getTime() - startDate.getTime()) / (24 * 60 * 60 * 1000)).intValue(); + return day; + } + return 0; } /** @@ -92,6 +99,7 @@ public class DateUtil { DecimalFormat df = new DecimalFormat("00"); return df.format(hour)+":"+df.format(minute)+":"+df.format(second); + } diff --git a/panda-code/src/main/java/org/panda/code/uitl/JsonUtil.java b/panda-code/src/main/java/org/panda/code/uitl/JsonUtil.java index 444bdc9..b3a5987 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/JsonUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/JsonUtil.java @@ -12,6 +12,8 @@ import java.io.IOException; */ public class JsonUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(JsonUtil.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); diff --git a/panda-code/src/main/java/org/panda/code/uitl/JvmUtil.java b/panda-code/src/main/java/org/panda/code/uitl/JvmUtil.java index 319dcda..670082a 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/JvmUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/JvmUtil.java @@ -11,6 +11,16 @@ import java.util.Locale; * Created by qi_liang on 2018/5/25. */ public class JvmUtil { + + /** + * 秒-分钟单位 + */ + private static final int SECONDS_MINUTE_UNIT = 60; + /** + * 分-时单位 + */ + private static final int MINUTES_HOURS_UNIT = 24; + private final int Kb = 1024; private NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH)); private NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH)); @@ -51,28 +61,28 @@ public class JvmUtil { protected String toDuration(double uptime) { uptime /= 1000; - if (uptime < 60) { + if (uptime < SECONDS_MINUTE_UNIT) { return fmtD.format(uptime) + " seconds"; } uptime /= 60; - if (uptime < 60) { + if (uptime < SECONDS_MINUTE_UNIT) { long minutes = (long) uptime; String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute"); return s; } uptime /= 60; - if (uptime < 24) { + if (uptime < MINUTES_HOURS_UNIT) { long hours = (long) uptime; - long minutes = (long) ((uptime - hours) * 60); + long minutes = (long) ((uptime - hours) * SECONDS_MINUTE_UNIT); String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour"); if (minutes != 0) { s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute"); } return s; } - uptime /= 24; + uptime /= MINUTES_HOURS_UNIT; long days = (long) uptime; - long hours = (long) ((uptime - days) * 24); + long hours = (long) ((uptime - days) * MINUTES_HOURS_UNIT); String s = fmtI.format(days) + (days > 1 ? " days" : " day"); if (hours != 0) { s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : " hour"); diff --git a/panda-code/src/main/java/org/panda/code/uitl/StreamUtil.java b/panda-code/src/main/java/org/panda/code/uitl/StreamUtil.java index f2bf8e4..5ff2fd4 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/StreamUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/StreamUtil.java @@ -8,6 +8,7 @@ import java.io.*; /** * 流操作工具类 + * @author qi */ public class StreamUtil { diff --git a/panda-code/src/main/java/org/panda/code/uitl/TestUtil.java b/panda-code/src/main/java/org/panda/code/uitl/TestUtil.java index f07896b..034c79a 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/TestUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/TestUtil.java @@ -10,6 +10,7 @@ import java.util.*; /** * Created by qi_liang on 2018/5/27. + * @author qi */ public class TestUtil { @@ -25,7 +26,7 @@ public class TestUtil { } - public void showURL() throws IOException, IOException { + public void showUrl() throws IOException, IOException { // 第一种:获取类加载的根路径 D:\git\daotie\daotie\target\classes File f = new File(this.getClass().getResource("/").getPath()); @@ -36,7 +37,8 @@ public class TestUtil { System.out.println(f2); // 第二种:获取项目路径 D:\git\daotie\daotie - File directory = new File("");// 参数为空 + // 参数为空 + File directory = new File(""); String courseFile = directory.getCanonicalPath(); System.out.println(courseFile); diff --git a/panda-code/src/main/java/org/panda/code/uitl/HttpKit.java b/panda-code/src/main/java/org/panda/code/uitl/http/HttpKit.java similarity index 98% rename from panda-code/src/main/java/org/panda/code/uitl/HttpKit.java rename to panda-code/src/main/java/org/panda/code/uitl/http/HttpKit.java index ec1af98..bfc1005 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/HttpKit.java +++ b/panda-code/src/main/java/org/panda/code/uitl/http/HttpKit.java @@ -2,10 +2,11 @@ * 微信公众平台开发模式 * */ -package org.panda.code.uitl; +package org.panda.code.uitl.http; import org.apache.log4j.Logger; +import org.panda.code.uitl.StringUtil; import java.io.BufferedReader; import java.io.InputStream; diff --git a/panda-code/src/main/java/org/panda/code/uitl/HttpUtil.java b/panda-code/src/main/java/org/panda/code/uitl/http/HttpUtil.java similarity index 98% rename from panda-code/src/main/java/org/panda/code/uitl/HttpUtil.java rename to panda-code/src/main/java/org/panda/code/uitl/http/HttpUtil.java index d992d7b..6347bed 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/HttpUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/http/HttpUtil.java @@ -1,4 +1,4 @@ -package org.panda.code.uitl; +package org.panda.code.uitl.http; import java.io.BufferedReader; import java.io.InputStreamReader; diff --git a/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java b/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java index 30f6813..4b308ca 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java +++ b/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java @@ -1,7 +1,6 @@ package org.panda.code.uitl.http; import com.alibaba.fastjson.JSONObject; -import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -19,10 +18,12 @@ import org.slf4j.LoggerFactory; import javax.net.ssl.SSLContext; import java.io.*; import java.nio.charset.Charset; -import java.util.HashMap; import java.util.Map; import java.util.UUID; +/** + * @author qi + */ public class HttpsClient { private static final Logger LOGGER = LoggerFactory.getLogger(HttpsClient.class); @@ -64,7 +65,7 @@ public class HttpsClient { // 建造我们的http多媒体对象 HttpEntity he = mBuilder.build(); // 建立一个sslcontext,这里我们信任任何的证书。 - SSLContext context = getTrustAllSSLContext(); + SSLContext context = getTrustAllSslContext(); // 建立socket工厂 SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory( context); @@ -91,10 +92,8 @@ public class HttpsClient { } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } finally{ // 关闭返回的reponse @@ -142,7 +141,7 @@ public class HttpsClient { return get; } - private static SSLContext getTrustAllSSLContext() throws Exception { + private static SSLContext getTrustAllSslContext() throws Exception { // SSLContext context = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { // // @Override diff --git a/panda-code/src/main/java/org/panda/code/uitl/os/NetUtil.java b/panda-code/src/main/java/org/panda/code/uitl/os/NetUtil.java index aa4c2c2..47fba46 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/os/NetUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/os/NetUtil.java @@ -10,7 +10,7 @@ import java.net.UnknownHostException; */ public class NetUtil { - public static String getIP(){ + public static String getIp(){ String ip = null; try { InetAddress address = InetAddress.getLocalHost(); diff --git a/panda-code/src/tests/java/org/panda/code/uitl/DateUtilTest.java b/panda-code/src/tests/java/org/panda/code/uitl/DateUtilTest.java new file mode 100644 index 0000000..231ac80 --- /dev/null +++ b/panda-code/src/tests/java/org/panda/code/uitl/DateUtilTest.java @@ -0,0 +1,67 @@ +package org.panda.code.uitl; + +import org.apache.commons.lang3.time.DateUtils; +import org.junit.Test; + +import java.text.ParseException; +import java.util.Date; + +public class DateUtilTest { + + /** + * 日期格式化,采用默认格式yyyy-MM-dd HH:mm:ss + */ + @Test + public void getDateToStr() { + String dateToStr = DateUtil.getDateToStr(new Date()); + System.out.println(dateToStr); + String dateToStr2 = DateUtil.getDateToStr(null); + System.out.println(dateToStr2); + + } + + /** + *日期格式化 + */ + @Test + public void getDateToStr1() { + String dateToStr = DateUtil.getDateToStr(new Date(),"yyyy-MM-dd HH:mm"); + System.out.println(dateToStr); + } + + /** + * 字符串转日期 + */ + @Test + public void strToDate() { + try { + Date date = DateUtil.strToDate("2020-01-20 22:51","yyyy-MM-dd HH:mm"); + System.out.println(date); + } catch (ParseException e) { + e.printStackTrace(); + } + + } + + @Test + public void disparityDay() { + try { + Date starDate = DateUtil.strToDate("2019-01-22","yyyy-MM-dd"); + Date endDate = DateUtil.strToDate("2020-02-24","yyyy-MM-dd"); + System.out.println((endDate.getTime()-starDate.getTime())/(24*60*60*1000)) ; + + System.out.println((24*60*60*1000)); + int day = DateUtil.disparityDay(starDate,endDate); + System.out.println(day); + } catch (ParseException e) { + e.printStackTrace(); + } + + + } + + @Test + public void dataFormat() { + + } +} diff --git a/panda-jdbc/panda-jdbc.iml b/panda-jdbc/panda-jdbc.iml index 839e2b5..49f74a8 100644 --- a/panda-jdbc/panda-jdbc.iml +++ b/panda-jdbc/panda-jdbc.iml @@ -6,17 +6,10 @@ - - - - - - - diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/JdbcLoad.java b/panda-jdbc/src/main/java/org/panda/jdbc/JdbcLoad.java index 1d1348b..9b1b76d 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/JdbcLoad.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/JdbcLoad.java @@ -2,6 +2,9 @@ package org.panda.jdbc; import org.panda.jdbc.helper.DbConfigInterface; +/** + * @author qi + */ public class JdbcLoad { private String driver = null; diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/JdbcUtils.java b/panda-jdbc/src/main/java/org/panda/jdbc/JdbcUtils.java index 90d61b2..792ed27 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/JdbcUtils.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/JdbcUtils.java @@ -51,7 +51,7 @@ public class JdbcUtils { * * @return */ - public DbInfo getDBInfo() { + public DbInfo getDbInfo() { Connection conn = null; DatabaseMetaData metaData; DbInfo dbInfo = new DbInfo(); diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/config/DbConfigConstant.java b/panda-jdbc/src/main/java/org/panda/jdbc/config/DbConfigConstant.java index 12bd9d0..a5b616f 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/config/DbConfigConstant.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/config/DbConfigConstant.java @@ -1,8 +1,13 @@ package org.panda.jdbc.config; +/** + * @author qi + */ public class DbConfigConstant { - //读取配置文件位置 + /** + * 读取配置文件位置 + */ public static final String CONFIG_FILE="smart.properties"; public static final String JDBC_DRIVER = "jdbc.driver"; diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/pool/JdbcPool.java b/panda-jdbc/src/main/java/org/panda/jdbc/pool/JdbcPool.java index dc5b324..419c1f2 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/pool/JdbcPool.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/pool/JdbcPool.java @@ -14,6 +14,7 @@ import java.util.logging.Logger; */ public class JdbcPool implements DataSource { + /** * 获取连接 * @return diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java b/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java index b1044e7..1b11937 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java @@ -15,11 +15,6 @@ import java.util.Map; */ public class BeanSqlUtil { - /** - * 驼峰下滑线 - */ - public static final String SQL_CHARACTER = "_"; - /** * 大小写转化驼峰 * @param str @@ -34,7 +29,7 @@ public class BeanSqlUtil { continue; } if (Character.isUpperCase(charArray[i])){ - strBuffer.append(SQL_CHARACTER+charArray[i]); + strBuffer.append(SqlConstant.SQL_SYMBOL+charArray[i]); }else { strBuffer.append(charArray[i]); } @@ -51,7 +46,7 @@ public class BeanSqlUtil { StringBuffer strBuffer=new StringBuffer(); char[] charArray=str.toCharArray(); for (int i=0;isql.lastIndexOf(")")){ + if (sql.lastIndexOf(SqlConstant.ORDER_SQL)>sql.lastIndexOf(SqlConstant.SQL_BRACKETS)){ sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length(),upperCaseSql.lastIndexOf(SqlConstant.ORDER_SQL))); }else{ sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length())); diff --git a/panda-web/src/main/java/org/panda/App.java b/panda-web/src/main/java/org/panda/App.java deleted file mode 100644 index 5e4b9bf..0000000 --- a/panda-web/src/main/java/org/panda/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.panda; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/panda-web/src/main/java/org/panda/web/helper/AopHelper.java b/panda-web/src/main/java/org/panda/web/helper/AopHelper.java index 8471ad6..fd6d796 100644 --- a/panda-web/src/main/java/org/panda/web/helper/AopHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/AopHelper.java @@ -14,6 +14,7 @@ import java.util.*; /** * 方法拦截助手类 + * @author qi */ public final class AopHelper { @@ -40,7 +41,7 @@ public final class AopHelper { */ private static Map> createProxyMap() { //初始化结果集合 - Map> proxyMap = new HashMap<>(); + Map> proxyMap = new HashMap<>(16); // //代理class 集合 // Set proxyClassSet = ClassHelper.getClasswetBySuper(AspectProxy.class); // //代理集合遍历 diff --git a/panda-web/src/main/java/org/panda/web/helper/BeanHelper.java b/panda-web/src/main/java/org/panda/web/helper/BeanHelper.java index f59a666..0c21cb4 100644 --- a/panda-web/src/main/java/org/panda/web/helper/BeanHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/BeanHelper.java @@ -7,6 +7,7 @@ import java.util.Set; /** * Bean助手类 + * @author qi */ public class BeanHelper { diff --git a/panda-web/src/main/java/org/panda/web/helper/ConfigHelper.java b/panda-web/src/main/java/org/panda/web/helper/ConfigHelper.java index 888aa53..0919c54 100644 --- a/panda-web/src/main/java/org/panda/web/helper/ConfigHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/ConfigHelper.java @@ -7,6 +7,7 @@ import java.util.Properties; /** * 属性文件助手类 + * @author qi */ public class ConfigHelper { diff --git a/panda-web/src/main/java/org/panda/web/helper/ControllerHelper.java b/panda-web/src/main/java/org/panda/web/helper/ControllerHelper.java index 1b54dfc..b602ba7 100644 --- a/panda-web/src/main/java/org/panda/web/helper/ControllerHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/ControllerHelper.java @@ -14,6 +14,7 @@ import java.util.Set; /** * 控制器助手 + * @author qi */ public final class ControllerHelper { diff --git a/panda-web/src/main/java/org/panda/web/helper/HelperLoader.java b/panda-web/src/main/java/org/panda/web/helper/HelperLoader.java index 2a9e50b..edeb37c 100644 --- a/panda-web/src/main/java/org/panda/web/helper/HelperLoader.java +++ b/panda-web/src/main/java/org/panda/web/helper/HelperLoader.java @@ -3,6 +3,9 @@ package org.panda.web.helper; import org.apache.commons.dbutils.handlers.BeanHandler; import org.panda.beans.util.ClassUtil; +/** + * @author qi + */ public class HelperLoader { public static void init() { diff --git a/panda-web/src/main/java/org/panda/web/helper/IocHelper.java b/panda-web/src/main/java/org/panda/web/helper/IocHelper.java index 308dc62..2aaca79 100644 --- a/panda-web/src/main/java/org/panda/web/helper/IocHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/IocHelper.java @@ -11,6 +11,7 @@ import java.util.Map; /** * 依赖注入助手类 + * @author qi */ public class IocHelper { diff --git a/panda-web/src/main/java/org/panda/web/helper/RequestHelper.java b/panda-web/src/main/java/org/panda/web/helper/RequestHelper.java index ebec36a..6643356 100644 --- a/panda-web/src/main/java/org/panda/web/helper/RequestHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/RequestHelper.java @@ -15,6 +15,7 @@ import java.util.List; /** * 请求助手类 + * @author qi */ public class RequestHelper { @@ -61,7 +62,7 @@ public class RequestHelper { private static List parseInputStream(HttpServletRequest request) throws IOException { List formParamList = new ArrayList<>(); - String body = CodecUtil.decodeURL(StreamUtil.getString(request.getInputStream())); + String body = CodecUtil.decodeUrl(StreamUtil.getString(request.getInputStream())); if (StringUtil.isNotNull(body)) { String[] kvs = StringUtil.splistString(body, "&"); if (ArrayUtil.isNotEmpty(kvs)) { diff --git a/panda-web/src/main/java/org/panda/web/helper/ServletHelper.java b/panda-web/src/main/java/org/panda/web/helper/ServletHelper.java index 25b2b41..39c3832 100644 --- a/panda-web/src/main/java/org/panda/web/helper/ServletHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/ServletHelper.java @@ -12,6 +12,7 @@ import java.io.IOException; /** * Servlet 助手类 + * @author qi */ public class ServletHelper { diff --git a/panda-web/src/main/java/org/panda/web/helper/UploadHelper.java b/panda-web/src/main/java/org/panda/web/helper/UploadHelper.java index d4989ef..dc8a130 100644 --- a/panda-web/src/main/java/org/panda/web/helper/UploadHelper.java +++ b/panda-web/src/main/java/org/panda/web/helper/UploadHelper.java @@ -22,6 +22,7 @@ import java.util.Map; /** * 文件上传助手类 + * @author qi */ public class UploadHelper { diff --git a/panda-web/src/main/java/org/panda/web/mode/Data.java b/panda-web/src/main/java/org/panda/web/mode/Data.java index 6e70cbc..51662bd 100644 --- a/panda-web/src/main/java/org/panda/web/mode/Data.java +++ b/panda-web/src/main/java/org/panda/web/mode/Data.java @@ -2,6 +2,7 @@ package org.panda.web.mode; /** * 放回数据对象 + * @author qi */ public class Data { diff --git a/panda-web/src/main/java/org/panda/web/mode/FileParam.java b/panda-web/src/main/java/org/panda/web/mode/FileParam.java index 2be6b08..5b9ca5d 100644 --- a/panda-web/src/main/java/org/panda/web/mode/FileParam.java +++ b/panda-web/src/main/java/org/panda/web/mode/FileParam.java @@ -4,18 +4,29 @@ import java.io.InputStream; /** * 封装上传文件参数 + * @author qi */ public class FileParam { - //文件表单字段 + /** + * 文件表单字段 + */ private String fieldName; - //文件名称 + /** + * 文件名称 + */ private String fileName; - //文件大小 + /** + * 文件大小 + */ private Long fileSize; - //上传文件的contentType,可判断文件类型 + /** + * 上传文件的contentType,可判断文件类型 + */ private String contentType; - //文件字节流 + /** + * 文件字节流 + */ private InputStream inputStream; public FileParam(String fieldName, String fileName, Long fileSize, String contentType, InputStream inputStream) { diff --git a/panda-web/src/main/java/org/panda/web/mode/FormParam.java b/panda-web/src/main/java/org/panda/web/mode/FormParam.java index fdb29e9..5c8a0a5 100644 --- a/panda-web/src/main/java/org/panda/web/mode/FormParam.java +++ b/panda-web/src/main/java/org/panda/web/mode/FormParam.java @@ -1,5 +1,8 @@ package org.panda.web.mode; +/** + * @author qi + */ public class FormParam { private String fieldName; diff --git a/panda-web/src/main/java/org/panda/web/mode/Handler.java b/panda-web/src/main/java/org/panda/web/mode/Handler.java index 8bec8ca..618ccd6 100644 --- a/panda-web/src/main/java/org/panda/web/mode/Handler.java +++ b/panda-web/src/main/java/org/panda/web/mode/Handler.java @@ -4,6 +4,7 @@ import java.lang.reflect.Method; /** * 封装Action 信息 + * @author qi */ public class Handler { diff --git a/panda-web/src/main/java/org/panda/web/mode/Param.java b/panda-web/src/main/java/org/panda/web/mode/Param.java index bdac7d2..fb0d77c 100644 --- a/panda-web/src/main/java/org/panda/web/mode/Param.java +++ b/panda-web/src/main/java/org/panda/web/mode/Param.java @@ -11,6 +11,7 @@ import java.util.Map; /** * 请求参数对象 + * @author qi */ public class Param { @@ -28,7 +29,7 @@ public class Param { } public Map getFieldMap(){ - Map fieldMap = new HashMap<>(); + Map fieldMap = new HashMap<>(formParamsList.size()); if (CollectionUtil.isNotEmpty(formParamsList)){ formParamsList.forEach((formParam)->{ String fieldName = formParam.getFieldName(); @@ -47,7 +48,7 @@ public class Param { * @return */ public Map> getFileMap(){ - Map> fileMap = new HashMap<>(); + Map> fileMap = new HashMap<>(fileParamList.size()); if (CollectionUtil.isNotEmpty(fileParamList)){ fileParamList.forEach((fileParam)->{ String fieldName = fileParam.getFieldName(); diff --git a/panda-web/src/main/java/org/panda/web/mode/Request.java b/panda-web/src/main/java/org/panda/web/mode/Request.java index 9a48e4f..52f013e 100644 --- a/panda-web/src/main/java/org/panda/web/mode/Request.java +++ b/panda-web/src/main/java/org/panda/web/mode/Request.java @@ -5,6 +5,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; /** * 封装请求信息 + * @author qi */ public class Request { diff --git a/panda-web/src/main/java/org/panda/web/mode/View.java b/panda-web/src/main/java/org/panda/web/mode/View.java index 593b170..68fa2de 100644 --- a/panda-web/src/main/java/org/panda/web/mode/View.java +++ b/panda-web/src/main/java/org/panda/web/mode/View.java @@ -5,6 +5,7 @@ import java.util.Map; /** * 放回视图对象 + * @author qi */ public class View { diff --git a/panda-web/src/main/java/org/panda/web/servlet/DispatcherServlet.java b/panda-web/src/main/java/org/panda/web/servlet/DispatcherServlet.java index f1539fb..584fc04 100644 --- a/panda-web/src/main/java/org/panda/web/servlet/DispatcherServlet.java +++ b/panda-web/src/main/java/org/panda/web/servlet/DispatcherServlet.java @@ -29,7 +29,7 @@ import java.util.Map; /** * @author qi */ -//@WebServlet(urlPatterns = "/*",loadOnStartup = 0) +@WebServlet(urlPatterns = "/*",loadOnStartup = 0) public class DispatcherServlet extends HttpServlet{ private final static Logger LOGGER = LoggerFactory.getLogger(DispatcherServlet.class); @@ -42,6 +42,11 @@ public class DispatcherServlet extends HttpServlet{ private final static String FAVICON_ICO = "/favicon.ico"; + /** + * 路径切割符号 + */ + public final static String PATH_CUT_SYMBOL = "/"; + @Override public void init(ServletConfig config) throws ServletException { @@ -110,11 +115,13 @@ public class DispatcherServlet extends HttpServlet{ } - //处理视图类视图返回值 + /** + * 处理视图类视图返回值 + */ private void handleViewResult(View view,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String path = view.getPaht(); if (StringUtil.isNotNull(path)){ - if (path.startsWith("/")) { + if (path.startsWith(PATH_CUT_SYMBOL)) { response.sendRedirect(request.getContextPath() + path); } else { Map model = view.getModel(); @@ -127,7 +134,9 @@ public class DispatcherServlet extends HttpServlet{ } } - //处理实体视图返回值 + /** + * 处理实体视图返回值 + */ private void handleDateResult(Data data,HttpServletRequest request,HttpServletResponse response) throws IOException { //返回json数据