diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java index 0feeb882de..42e454d24c 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java @@ -274,6 +274,9 @@ public class ApiUtils { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeFormat.split(" ")[1]); httpClientConfig.addHeader(header.get("name").toString(), simpleDateFormat.format(date)); } + if (StringUtils.isNotEmpty(timeFormat) && timeFormat.split(" ")[0].equalsIgnoreCase("timestamp")) { + httpClientConfig.addHeader(header.get("name").toString(), String.valueOf(System.currentTimeMillis())); + } } else { httpClientConfig.addHeader(header.get("name").toString(), header.get("value").toString()); } @@ -338,6 +341,9 @@ public class ApiUtils { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeFormat.split(" ")[1]); params.add(argument.get("name") + "=" + simpleDateFormat.format(date)); } + if (StringUtils.isNotEmpty(timeFormat) && timeFormat.split(" ")[0].equalsIgnoreCase("timestamp")) { + params.add(argument.get("name") + "=" + System.currentTimeMillis()); + } } else { params.add(argument.get("name") + "=" + URLEncoder.encode(argument.get("value"))); } @@ -369,6 +375,10 @@ public class ApiUtils { bodYparams.add(matcher.group(1)); } for (String param : bodYparams) { + if (param.equalsIgnoreCase("currentTimestamp")) { + raw = raw.replace("${" + param + "}", String.valueOf(System.currentTimeMillis())); + continue; + } for (ApiDefinition definition : paramsList) { for (int i = 0; i < definition.getFields().size(); i++) { TableField field = definition.getFields().get(i); @@ -470,6 +480,9 @@ public class ApiUtils { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeFormat.split(" ")[1]); body.put(jsonNode.get("name").toString(), simpleDateFormat.format(date)); } + if (StringUtils.isNotEmpty(timeFormat) && timeFormat.split(" ")[0].equalsIgnoreCase("timestamp")) { + body.put(jsonNode.get("name").toString(), String.valueOf(System.currentTimeMillis())); + } } else { body.put(jsonNode.get("name").asText(), jsonNode.get("value").asText()); } diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts index 3b4fbee50c..1545da4251 100644 --- a/core/core-frontend/src/locales/en.ts +++ b/core/core-frontend/src/locales/en.ts @@ -316,6 +316,7 @@ export default { time_function: 'Time function', customize: 'Customize', that_day: 'That day', + timestamp: 'current time (timestamp)', value: 'Value', name_use_parameters: "You can use ${'{'}parameter name{'}'}, use parameters", add_parameters: 'Add parameters', diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts index 120b89fda3..d91aed496e 100644 --- a/core/core-frontend/src/locales/tw.ts +++ b/core/core-frontend/src/locales/tw.ts @@ -305,6 +305,7 @@ export default { time_function: '時間函數', customize: '自訂', that_day: '當天', + timestamp: '當前時間(時間戳)', value: '值', name_use_parameters: "可用${'{'}參數名稱{'}'},使用參數", add_parameters: '新增參數', diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index cdaab31773..5eae2f7e38 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -306,6 +306,7 @@ export default { time_function: '时间函数', customize: '自定义', that_day: '当天', + timestamp: '当前时间(时间戳)', value: '值', name_use_parameters: "可用${'{'}参数名{'}'},使用参数", add_parameters: '添加参数', diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/ApiKeyValue.vue b/core/core-frontend/src/views/visualized/data/datasource/form/ApiKeyValue.vue index 7decd85004..9cabcdc2e4 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/ApiKeyValue.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/ApiKeyValue.vue @@ -111,6 +111,10 @@ const timeFunLists = [ { label: t('data_source.that_day') + '(yyyy/MM/dd)', value: 'currentDay yyyy/MM/dd' + }, + { + label: t('data_source.timestamp'), + value: 'timestamp' } ] diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/ApiVariable.vue b/core/core-frontend/src/views/visualized/data/datasource/form/ApiVariable.vue index 04d71b903e..6530eb56bc 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/ApiVariable.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/ApiVariable.vue @@ -148,6 +148,10 @@ const timeFunLists = [ { label: t('data_source.that_day') + '(yyyy/MM/dd)', value: 'currentDay yyyy/MM/dd' + }, + { + label: t('data_source.timestamp'), + value: 'timestamp' } ]