Skip to content

Commit 2172d4f

Browse files
committed
Java:兼容 APIJSON 5.0.0+ 对接 Oracle DATETIME, TIMESTAMP 等日期时间类型
1 parent 5ab7168 commit 2172d4f

File tree

4 files changed

+65
-52
lines changed

4 files changed

+65
-52
lines changed

APIJSON-Java-Server/APIJSONBoot-BigData/src/main/java/apijson/demo/DemoSQLConfig.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import static apijson.framework.APIJSONConstant.USER_;
2020
import static apijson.framework.APIJSONConstant.USER_ID;
2121

22+
import java.text.SimpleDateFormat;
2223
import java.util.Arrays;
2324
import java.util.HashMap;
2425
import java.util.List;
2526
import java.util.Map;
2627

28+
import apijson.Log;
2729
import com.alibaba.fastjson.annotation.JSONField;
2830

2931
import apijson.RequestMethod;
@@ -273,25 +275,26 @@ public String getDBPassword() {
273275
// return super.getKey(ColumnUtil.compatInputKey(key, getTable(), getMethod()));
274276
// }
275277

276-
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库
277-
// public Object getValue(@NotNull Object value) {
278-
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
279-
// try {
280-
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
281-
// parser.parse((String) value);
282-
// if (isPrepared()) {
283-
// preparedValueList.add(value);
284-
// }
285-
// return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')";
286-
// }
287-
// catch (Throwable e) {
288-
// if (Log.DEBUG) {
289-
// e.printStackTrace();
290-
// }
291-
// }
292-
// }
293-
// return super.getValue(value);
294-
// }
278+
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库。5.0.0+ 重写以下方法,4.9.1 及以下改为重写 getValue(String)
279+
// @Override
280+
// protected Object getValue(String key, String column, Object value) {
281+
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
282+
// try {
283+
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
284+
// parser.parse((String) value);
285+
// if (isPrepared()) {
286+
// preparedValueList.add(value);
287+
// }
288+
// return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')";
289+
// }
290+
// catch (Throwable e) {
291+
// if (Log.DEBUG) {
292+
// e.printStackTrace();
293+
// }
294+
// }
295+
// }
296+
// return super.getValue(key, column, value);
297+
// }
295298

296299

297300
@Override

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoSQLConfig.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
import static apijson.framework.APIJSONConstant.USER_;
2020
import static apijson.framework.APIJSONConstant.USER_ID;
2121

22+
import java.text.SimpleDateFormat;
2223
import java.util.Arrays;
2324
import java.util.HashMap;
2425
import java.util.List;
2526
import java.util.Map;
2627

28+
import apijson.Log;
29+
import apijson.NotNull;
2730
import com.alibaba.fastjson.annotation.JSONField;
2831

2932
import apijson.RequestMethod;
@@ -340,8 +343,9 @@ public String getDBPassword() {
340343
// return super.getKey(ColumnUtil.compatInputKey(key, getTable(), getMethod()));
341344
// }
342345

343-
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库
344-
// public Object getValue(@NotNull Object value) {
346+
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库。5.0.0+ 重写以下方法,4.9.1 及以下改为重写 getValue(String)
347+
// @Override
348+
// protected Object getValue(String key, String column, Object value) {
345349
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
346350
// try {
347351
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -357,7 +361,7 @@ public String getDBPassword() {
357361
// }
358362
// }
359363
// }
360-
// return super.getValue(value);
364+
// return super.getValue(key, column, value);
361365
// }
362366

363367

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/DemoSQLConfig.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import static apijson.framework.APIJSONConstant.USER_;
2020
import static apijson.framework.APIJSONConstant.USER_ID;
2121

22+
import java.text.SimpleDateFormat;
2223
import java.util.Arrays;
2324
import java.util.HashMap;
2425
import java.util.List;
2526
import java.util.Map;
2627

28+
import apijson.Log;
2729
import com.alibaba.fastjson.annotation.JSONField;
2830

2931
import apijson.RequestMethod;
@@ -288,25 +290,26 @@ public String getDBPassword() {
288290
// return super.getKey(ColumnUtil.compatInputKey(key, getTable(), getMethod()));
289291
// }
290292

291-
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库
292-
// public Object getValue(@NotNull Object value) {
293-
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
294-
// try {
295-
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
296-
// parser.parse((String) value);
297-
// if (isPrepared()) {
298-
// preparedValueList.add(value);
293+
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库。5.0.0+ 重写以下方法,4.9.1 及以下改为重写 getValue(String)
294+
// @Override
295+
// protected Object getValue(String key, String column, Object value) {
296+
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
297+
// try {
298+
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
299+
// parser.parse((String) value);
300+
// if (isPrepared()) {
301+
// preparedValueList.add(value);
302+
// }
303+
// return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')";
299304
// }
300-
// return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')";
301-
// }
302-
// catch (Throwable e) {
303-
// if (Log.DEBUG) {
304-
// e.printStackTrace();
305+
// catch (Throwable e) {
306+
// if (Log.DEBUG) {
307+
// e.printStackTrace();
308+
// }
305309
// }
306310
// }
311+
// return super.getValue(key, column, value);
307312
// }
308-
// return super.getValue(value);
309-
// }
310313

311314

312315
@Override

APIJSON-Java-Server/APIJSONFinal/src/main/java/apijson/demo/DemoSQLConfig.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import static apijson.framework.APIJSONConstant.USER_;
2020
import static apijson.framework.APIJSONConstant.USER_ID;
2121

22+
import java.text.SimpleDateFormat;
2223
import java.util.List;
2324

25+
import apijson.Log;
2426
import com.alibaba.fastjson.annotation.JSONField;
2527

2628
import apijson.RequestMethod;
@@ -244,25 +246,26 @@ public String getDBPassword() {
244246
// return super.getKey(ColumnUtil.compatInputKey(key, getTable(), getMethod()));
245247
// }
246248

247-
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库
248-
// public Object getValue(@NotNull Object value) {
249-
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
250-
// try {
251-
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
252-
// parser.parse((String) value);
253-
// if (isPrepared()) {
254-
// preparedValueList.add(value);
249+
// 取消注释来兼容 Oracle DATETIME, TIMESTAMP 等日期时间类型的值来写库。5.0.0+ 重写以下方法,4.9.1 及以下改为重写 getValue(String)
250+
// @Override
251+
// protected Object getValue(String key, String column, Object value) {
252+
// if (isOracle() && RequestMethod.isQueryMethod(getMethod()) == false && value instanceof String) {
253+
// try {
254+
// SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
255+
// parser.parse((String) value);
256+
// if (isPrepared()) {
257+
// preparedValueList.add(value);
258+
// }
259+
// return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')";
255260
// }
256-
// return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')";
257-
// }
258-
// catch (Throwable e) {
259-
// if (Log.DEBUG) {
260-
// e.printStackTrace();
261+
// catch (Throwable e) {
262+
// if (Log.DEBUG) {
263+
// e.printStackTrace();
264+
// }
261265
// }
262266
// }
267+
// return super.getValue(key, column, value);
263268
// }
264-
// return super.getValue(value);
265-
// }
266269

267270

268271
@Override

0 commit comments

Comments
 (0)