APIJSON icon indicating copy to clipboard operation
APIJSON copied to clipboard

[权限] ACCESS的时候,只查询前100条,现在表里面超过100条无法查询

Open tanfen100 opened this issue 2 years ago • 4 comments

Description

权限查询ACCESS的时候,只查询前100条,现在表里面超过100条无法查到,导致权限无法生效

tanfen100 avatar Jun 20 '23 09:06 tanfen100

DemoParser 重写 getMaxQueryCount,具体看常见问题

TommyLemon avatar Jun 22 '23 07:06 TommyLemon

apijson 支持增量加载.自己可以扩展, 参见示例如下代码:

int eveNum = 1;
while (true) {
	JSONObject table = new JSONObject();
	table.put("id{}", ">=" + (30 * eveNum));
	table.setOrder("id+");
	APIJSONVerifier.initAccess(IS_INIT_SHUTDOWNWHENSERVERERROR, 
        APIJSONApplication.DEFAULT_APIJSON_CREATOR, table);
	int tmp_accessMapCount = AbstractVerifier.getAccessSize();
	if (accessMapCount == tmp_accessMapCount) {
		break;
	} else {
		accessMapCount = tmp_accessMapCount;
	}
	eveNum++;
}

cloudAndMonkey avatar Jun 25 '23 02:06 cloudAndMonkey

apijson 支持增量加载.自己可以扩展, 参见示例如下代码:

int eveNum = 1;
while (true) {
	JSONObject table = new JSONObject();
	table.put("id{}", ">=" + (30 * eveNum));
	table.setOrder("id+");
	APIJSONVerifier.initAccess(IS_INIT_SHUTDOWNWHENSERVERERROR, 
        APIJSONApplication.DEFAULT_APIJSON_CREATOR, table);
	int tmp_accessMapCount = AbstractVerifier.getAccessSize();
	if (accessMapCount == tmp_accessMapCount) {
		break;
	} else {
		accessMapCount = tmp_accessMapCount;
	}
	eveNum++;
}

这样更好,不会把业务表查询限制放得很开

TommyLemon avatar Jul 02 '23 05:07 TommyLemon

其实之前已经针对 APIJSON 配置表,用 SQLConfig.limitCount 做了不设置查询上限数量的处理 https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java#L847-L850 image

https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L174-L196 image

但因为 APIJSONVerifier.initAccess 中 accessItem.toArray(0, 0, ACCESS_) 传参 0 导致只能按 Parser.getMaxQueryCount 返回的最大数量查询
https://github.com/APIJSON/apijson-framework/blob/master/src/main/java/apijson/framework/APIJSONVerifier.java#L168-L171 image

所以需要改为 accessItem.toArray(null, 0, ACCESS_),但因为这个方法参数类型为 int 不能传 null,所以也需要把 int 改为 Integer,最好 int count, int page 都改为 Integer https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/JSONRequest.java#L164-L180 Screenshot 2023-07-30 at 23 45 32

改了后麻烦提交 PR 贡献代码,开源要大家一起参与贡献才会更美好~ image https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md

TommyLemon avatar Jul 30 '23 15:07 TommyLemon