feat(tools): 数据库查询按权限拆分为 user/admin,强制 userId 隔离
- query/ 为内部实现,user/ 仅供 bot-escort(绑定登录用户、schema 不暴露 userId),admin/ 仅供 escort-admin(显式跨用户) - 新增 employee、employee_review 查询;health_profile 用户端补齐 userId 隔离,按 _id 精确查询也带归属条件 - organization 是公共数据且无 userId,不进用户端;机构与写入工具统一移入 admin/ - utils 增加严格 ObjectId 解析,避免 CastError 与畸形 ID 进入查询 - 用户端员工视图剔除手机号、证件号、证书编号、紧急联系人与内部备注 - 新增 test/db_tools.test.js,用模型桩断言查询条件确实带 userId
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { buildEmployeeQueryTool } from "../query/employee_query.js";
|
||||
|
||||
/**
|
||||
* 用户端员工查询工具
|
||||
*
|
||||
* 只传入当前登录用户的 userId,schema 不暴露 userId 参数;
|
||||
* 查询强制按 userId 隔离,并只输出本人员工档案的非敏感字段。
|
||||
*/
|
||||
const createEmployeeQueryTool = (userInfo) =>
|
||||
buildEmployeeQueryTool({ userId: userInfo?._id });
|
||||
|
||||
export { createEmployeeQueryTool };
|
||||
@@ -0,0 +1,12 @@
|
||||
import { buildEmployeeReviewQueryTool } from "../query/employee_review_query.js";
|
||||
|
||||
/**
|
||||
* 用户端员工评价查询工具
|
||||
*
|
||||
* 只传入当前登录用户的 userId,schema 不暴露 userId 参数;
|
||||
* 查询强制按评价人 userId 隔离,只返回本人提交的评价。
|
||||
*/
|
||||
const createEmployeeReviewQueryTool = (userInfo) =>
|
||||
buildEmployeeReviewQueryTool({ userId: userInfo?._id });
|
||||
|
||||
export { createEmployeeReviewQueryTool };
|
||||
@@ -0,0 +1,12 @@
|
||||
import { buildEscortRecordQueryTool } from "../query/escort_record_query.js";
|
||||
|
||||
/**
|
||||
* 用户端陪诊记录查询工具
|
||||
*
|
||||
* 只传入当前登录用户的 userId,不开放管理端的手机号/陪诊员/日期筛选。
|
||||
* 未登录或身份非法时,工具执行会直接拒绝,不会回落到跨用户查询。
|
||||
*/
|
||||
const createEscortRecordQueryTool = (userInfo) =>
|
||||
buildEscortRecordQueryTool({ userId: userInfo?._id });
|
||||
|
||||
export { createEscortRecordQueryTool };
|
||||
@@ -0,0 +1,12 @@
|
||||
import { buildHealthProfileQueryTool } from "../query/health_profile_query.js";
|
||||
|
||||
/**
|
||||
* 用户端健康档案查询工具
|
||||
*
|
||||
* 只传入当前登录用户的 userId,schema 不暴露 userId 参数;
|
||||
* 未登录或身份非法时直接拒绝,不会回落到跨用户查询。
|
||||
*/
|
||||
const createHealthProfileQueryTool = (userInfo) =>
|
||||
buildHealthProfileQueryTool({ userId: userInfo?._id });
|
||||
|
||||
export { createHealthProfileQueryTool };
|
||||
Reference in New Issue
Block a user