| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a3dffa8 commit b248b42
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 6 | <groupId>com.github.Tencent</groupId> | |
| 7 | 7 | <artifactId>APIJSON</artifactId> | |
| 8 | - <version>5.2.0</version> | ||
| 8 | + <version>5.3.0</version> | ||
| 9 | 9 | <packaging>jar</packaging> | |
| 10 | 10 | ||
| 11 | 11 | <name>APIJSONORM</name> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,18 +14,30 @@ public class Log { | |||
| 14 | 14 | ||
| 15 | 15 | public static boolean DEBUG = true; | |
| 16 | 16 | ||
| 17 | - public static final String VERSION = "5.2.0"; | ||
| 18 | - public static final String KEY_SYSTEM_INFO_DIVIDER = "---|-----APIJSON SYSTEM INFO-----|---"; | ||
| 17 | + public static final String VERSION = "5.3.0"; | ||
| 18 | + public static final String KEY_SYSTEM_INFO_DIVIDER = "\n---|-----APIJSON SYSTEM INFO-----|---\n"; | ||
| 19 | 19 | ||
| 20 | - //默认的时间格式 | ||
| 21 | - public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); | ||
| 20 | + public static final String OS_NAME; | ||
| 21 | + public static final String OS_VERSION; | ||
| 22 | + public static final String OS_ARCH; | ||
| 23 | + public static final String JAVA_VERSION; | ||
| 24 | + static { | ||
| 25 | + OS_NAME = System.getProperty("os.name"); | ||
| 26 | + OS_VERSION = System.getProperty("os.version"); | ||
| 27 | + OS_ARCH = System.getProperty("os.arch"); | ||
| 28 | + JAVA_VERSION = System.getProperty("java.version"); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + //默认的时间格式 | ||
| 33 | + public static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); | ||
| 22 | 34 | ||
| 23 | 35 | /** | |
| 24 | 36 | * modify date format | |
| 25 | 37 | * @param dateFormatString | |
| 26 | 38 | */ | |
| 27 | 39 | public static void setDateFormat(String dateFormatString) { | |
| 28 | - dateFormat = new SimpleDateFormat(dateFormatString); | ||
| 40 | + DATE_FORMAT = new SimpleDateFormat(dateFormatString); | ||
| 29 | 41 | } | |
| 30 | 42 | ||
| 31 | 43 | /** | |
@@ -36,10 +48,10 @@ public static void setDateFormat(String dateFormatString) { | |||
| 36 | 48 | */ | |
| 37 | 49 | public static void logInfo(String TAG, String msg, String level){ | |
| 38 | 50 | if(level.equals("DEBUG") || level .equals("ERROR") ||level.equals("WARN")){ | |
| 39 | - System.err.println(dateFormat.format(System.currentTimeMillis()) + ": " + TAG + "." + level + ": " + msg); | ||
| 51 | + System.err.println(DATE_FORMAT.format(System.currentTimeMillis()) + ": " + TAG + "." + level + ": " + msg); | ||
| 40 | 52 | } | |
| 41 | 53 | else if(level.equals("VERBOSE") || level .equals("INFO") ){ | |
| 42 | - System.out.println(dateFormat.format(System.currentTimeMillis()) + ": " + TAG + "." + level + ": " + msg); | ||
| 54 | + System.out.println(DATE_FORMAT.format(System.currentTimeMillis()) + ": " + TAG + "." + level + ": " + msg); | ||
| 43 | 55 | } | |
| 44 | 56 | } | |
| 45 | 57 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,13 +12,15 @@ | |||
| 12 | 12 | import apijson.StringUtil; | |
| 13 | 13 | import apijson.orm.AbstractFunctionParser.FunctionBean; | |
| 14 | 14 | import apijson.orm.exception.ConflictException; | |
| 15 | + import apijson.orm.exception.CommonException; | ||
| 15 | 16 | import apijson.orm.exception.NotExistException; | |
| 16 | 17 | import com.alibaba.fastjson.JSON; | |
| 17 | 18 | import com.alibaba.fastjson.JSONArray; | |
| 18 | 19 | import com.alibaba.fastjson.JSONObject; | |
| 19 | 20 | ||
| 20 | 21 | import javax.activation.UnsupportedDataTypeException; | |
| 21 | 22 | import java.rmi.ServerException; | |
| 23 | + import java.sql.SQLException; | ||
| 22 | 24 | import java.util.ArrayList; | |
| 23 | 25 | import java.util.Arrays; | |
| 24 | 26 | import java.util.LinkedHashMap; | |
@@ -282,46 +284,7 @@ else if (method == PUT && value instanceof JSONArray && (whereList == null || wh | |||
| 282 | 284 | } | |
| 283 | 285 | } catch (Exception e) { | |
| 284 | 286 | if (tri == false) { | |
| 285 | - if (Log.DEBUG && sqlConfig != null && e.getMessage().contains(Log.KEY_SYSTEM_INFO_DIVIDER) == false) { | ||
| 286 | - try { | ||
| 287 | - String db = sqlConfig.getDatabase(); | ||
| 288 | - if (db == null) { | ||
| 289 | - if (sqlConfig.isMySQL()) { | ||
| 290 | - db = SQLConfig.DATABASE_MYSQL; | ||
| 291 | - } | ||
| 292 | - else if (sqlConfig.isPostgreSQL()) { | ||
| 293 | - db = SQLConfig.DATABASE_POSTGRESQL; | ||
| 294 | - } | ||
| 295 | - else if (sqlConfig.isSQLServer()) { | ||
| 296 | - db = SQLConfig.DATABASE_SQLSERVER; | ||
| 297 | - } | ||
| 298 | - else if (sqlConfig.isOracle()) { | ||
| 299 | - db = SQLConfig.DATABASE_ORACLE; | ||
| 300 | - } | ||
| 301 | - else if (sqlConfig.isDb2()) { | ||
| 302 | - db = SQLConfig.DATABASE_DB2; | ||
| 303 | - } | ||
| 304 | - else if (sqlConfig.isClickHouse()) { | ||
| 305 | - db = SQLConfig.DATABASE_CLICKHOUSE; | ||
| 306 | - } | ||
| 307 | - else { | ||
| 308 | - db = AbstractSQLConfig.DEFAULT_DATABASE; | ||
| 309 | - } | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - Class<? extends Exception> clazz = e.getClass(); | ||
| 313 | - e = clazz.getConstructor(String.class).newInstance( | ||
| 314 | - e.getMessage() | ||
| 315 | - + " " + Log.KEY_SYSTEM_INFO_DIVIDER + " \n **环境信息** " | ||
| 316 | - + " \n 系统: " + System.getProperty("os.name") + " " + System.getProperty("os.version") | ||
| 317 | - + " \n 数据库: " + db + " " + sqlConfig.getDBVersion() | ||
| 318 | - + " \n JDK: " + System.getProperty("java.version") + " " + System.getProperty("os.arch") | ||
| 319 | - + " \n APIJSON: " + Log.VERSION | ||
| 320 | - ); | ||
| 321 | - } catch (Throwable e2) {} | ||
| 322 | - } | ||
| 323 | - | ||
| 324 | - throw e; // 不忽略错误,抛异常 | ||
| 287 | + throw CommonException.wrap(e, sqlConfig); // 不忽略错误,抛异常 | ||
| 325 | 288 | } | |
| 326 | 289 | invalidate(); // 忽略错误,还原request | |
| 327 | 290 | } | |
@@ -515,9 +478,9 @@ else if (isTable && key.startsWith("@") && JSONRequest.TABLE_KEY_LIST.contains(k | |||
| 515 | 478 | ||
| 516 | 479 | ||
| 517 | 480 | /** | |
| 481 | + * @param index | ||
| 518 | 482 | * @param key | |
| 519 | 483 | * @param value | |
| 520 | - * @param isFirst | ||
| 521 | 484 | * @return | |
| 522 | 485 | * @throws Exception | |
| 523 | 486 | */ | |
@@ -746,9 +709,6 @@ public AbstractObjectParser setSQLConfig(int count, int page, int position) thro | |||
| 746 | 709 | ||
| 747 | 710 | protected SQLConfig sqlConfig = null;//array item复用 | |
| 748 | 711 | /**SQL查询,for array item | |
| 749 | - * @param count | ||
| 750 | - * @param page | ||
| 751 | - * @param position | ||
| 752 | 712 | * @return this | |
| 753 | 713 | * @throws Exception | |
| 754 | 714 | */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments