feat(filter): buildQuery 放行 _id 精确过滤(单项查看/relation 跳转)
filter 原本只认 filterable 字段,_id 会被丢弃。新增: key==='_id' 时始终以 eq 放行,
让 ?filter={_id} 能过滤到单条。_id 是主键精确匹配、用户已有列表权限,无安全顾虑。
This commit is contained in:
@@ -300,6 +300,11 @@ export class ShrimpTableModule<T, P extends ITableCrudProto<T> = ITableCrudProto
|
||||
const stringLikeTypes = new Set(['string', 'textarea'])
|
||||
const where: Record<string, IShrimpCondition> = {}
|
||||
for (const [key, value] of Object.entries(filter)) {
|
||||
// _id 始终放行精确过滤(单项查看/relation 跳转用),无需配 filterable
|
||||
if (key === '_id') {
|
||||
if (value != null && value !== '') where['_id'] = { eq: value }
|
||||
continue
|
||||
}
|
||||
const field = filterableFields.get(key)
|
||||
if (!field) continue
|
||||
if (value == null) continue
|
||||
|
||||
Reference in New Issue
Block a user