Skip to content

Commit aa31231

Browse files
committed
优化假删除,支持 notDeletedValue,适配 deletedTime = NULL 表示未删除等需求
1 parent 7d92e49 commit aa31231

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/main/java/apijson/framework/APIJSONSQLConfig.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,6 @@ public static SQLConfig newSQLConfig(RequestMethod method, String table, String
232232
return newSQLConfig(method, table, alias, request, joinList, isProcedure, SIMPLE_CALLBACK);
233233
}
234234

235-
@Override
236-
public boolean isFakeDelete() {
237-
return false;
238-
}
239-
240-
@Override
241-
public void onFakeDelete(Map<String, Object> map) {
242-
}
243235

244236
// 支持 !key 反选字段 和 字段名映射,依赖插件 https://github.com/APIJSON/apijson-column
245237
@Override

src/main/java/apijson/framework/APIJSONVerifier.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,23 @@ public static <T> JSONObject initAccess(boolean shutdownWhenServerError, APIJSON
210210
String alias = item.getString("alias");
211211

212212
Map<String, Object> fakemap = new HashMap<>();
213-
if(StringUtil.isNotEmpty(item.getString("deletedKey"), true)) {
214-
if (StringUtil.isEmpty(item.getString("deletedValue"), true)) {
215-
onServerError("Access表 id= "+ item.getString("id") +", deletedKey,deletedValue 的值不能为空!", shutdownWhenServerError);
213+
String deletedKey = item.getString(AbstractSQLConfig.KEY_DELETED_KEY);
214+
if(StringUtil.isNotEmpty(deletedKey, true)) {
215+
boolean containNotDeletedValue = item.containsKey(AbstractSQLConfig.KEY_NOT_DELETED_VALUE);
216+
Object deletedValue = item.getString(AbstractSQLConfig.KEY_DELETED_VALUE);
217+
if (containNotDeletedValue == false && StringUtil.isEmpty(deletedValue, true)) {
218+
onServerError(
219+
"Access表 id = " + item.getString("id") + " 对应的 "
220+
+ AbstractSQLConfig.KEY_DELETED_VALUE + " 的值不能为空!或者必须包含字段 "
221+
+ AbstractSQLConfig.KEY_NOT_DELETED_VALUE + " !"
222+
, shutdownWhenServerError
223+
);
224+
}
225+
fakemap.put(AbstractSQLConfig.KEY_DELETED_KEY, deletedKey);
226+
fakemap.put(AbstractSQLConfig.KEY_DELETED_VALUE, deletedValue);
227+
if (containNotDeletedValue) {
228+
fakemap.put(AbstractSQLConfig.KEY_NOT_DELETED_VALUE, item.get(AbstractSQLConfig.KEY_NOT_DELETED_VALUE));
216229
}
217-
fakemap.put("deletedKey", item.getString("deletedKey"));
218-
fakemap.put("deletedValue", item.getString("deletedValue"));
219230
}
220231

221232
/**TODO

0 commit comments

Comments
 (0)