fix(health+server+mp): 审计 P0 批次修复 — 积分冲突/文章草稿泄露/商城空白/模板ID配置化
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

P0-1: 微信模板 ID 从硬编码空字符串改为环境变量注入
  - wechat-templates.ts 读取 process.env.TARO_APP_WX_TEMPLATE_*
  - defineConstants 新增 5 个模板 ID 编译时注入

P0-2: 积分商城 Tab 空白降级
  - mall/index.tsx 在 currentPatient 为 null 时先调用 loadPatients()
  - 仍无档案才显示空状态引导,而非直接阻断

P0-3: 消除 erp-points 重复路由冲突
  - 从 erp-server 移除 erp-points 模块注册和路由 merge
  - 积分功能统一由 erp-health /health/points/* 提供
  - erp-points crate 保留但不参与编译

P0-4: 文章列表按角色过滤防止草稿泄露
  - list_articles handler: 非管理权限强制 status=published
  - get_article service: 新增 is_admin 参数控制状态过滤
This commit is contained in:
iven
2026-04-29 15:11:05 +08:00
parent facc8b0d24
commit dffa2dd47d
9 changed files with 46 additions and 39 deletions

View File

@@ -22,7 +22,7 @@ const TYPE_BG: Record<string, string> = {
};
export default function Mall() {
const { currentPatient } = useAuthStore();
const { currentPatient, loadPatients } = useAuthStore();
const { account, checkinStatus, refresh: refreshPoints, doCheckin } = usePointsStore();
const [products, setProducts] = useState<PointsProduct[]>([]);
const [productType, setProductType] = useState('');
@@ -66,13 +66,18 @@ export default function Mall() {
async (type?: string) => {
const t = type !== undefined ? type : productType;
if (!currentPatient) {
setNoProfile(true);
return;
// 先尝试从服务端加载患者列表
await loadPatients();
const updated = useAuthStore.getState().currentPatient;
if (!updated) {
setNoProfile(true);
return;
}
}
setNoProfile(false);
await Promise.all([refreshPoints(), fetchProducts(1, t, true)]);
},
[currentPatient, refreshPoints, fetchProducts, productType],
[currentPatient, loadPatients, refreshPoints, fetchProducts, productType],
);
useDidShow(() => {

View File

@@ -1,18 +1,18 @@
// 微信订阅消息模板 ID — 需在微信公众平台注册后填
// 微信订阅消息模板 ID — 通过环境变量注
// 注册路径:公众平台 → 功能 → 订阅消息 → 添加模板
// TODO: 上线前必须配置
// 环境变量TARO_APP_WX_TEMPLATE_APPOINTMENT / FOLLOWUP / REPORT / CRITICAL_ALERT / HEALTH_ABNORMAL
export const TEMPLATE_IDS = {
APPOINTMENT_REMINDER: '',
FOLLOWUP_REMINDER: '',
REPORT_NOTIFICATION: '',
CRITICAL_HEALTH_ALERT: '',
HEALTH_DATA_ABNORMAL: '',
APPOINTMENT_REMINDER: process.env.TARO_APP_WX_TEMPLATE_APPOINTMENT || '',
FOLLOWUP_REMINDER: process.env.TARO_APP_WX_TEMPLATE_FOLLOWUP || '',
REPORT_NOTIFICATION: process.env.TARO_APP_WX_TEMPLATE_REPORT || '',
CRITICAL_HEALTH_ALERT: process.env.TARO_APP_WX_TEMPLATE_CRITICAL_ALERT || '',
HEALTH_DATA_ABNORMAL: process.env.TARO_APP_WX_TEMPLATE_HEALTH_ABNORMAL || '',
} as const;
/** 检查模板 ID 是否已配置,未配置时返回 false 并打印警告 */
export function isTemplateConfigured(key: keyof typeof TEMPLATE_IDS): boolean {
if (!TEMPLATE_IDS[key]) {
console.warn(`[wechat-templates] 模板 ${key} 未配置,请在微信公众平台注册并填入 ID`);
console.warn(`[wechat-templates] 模板 ${key} 未配置,请在微信公众平台注册并设置对应环境变量`);
return false;
}
return true;