feat(medications): 实现V2版本药品AI分析功能及结构化数据支持

- 新增 V2 版药品分析服务,通过 AI 生成包含适用人群、副作用等字段的结构化 JSON 数据
- 添加 `POST :id/ai-analysis/v2` 接口,集成用户免费次数校验与自动扣费逻辑
- 在药品创建流程中增加异步触发自动 AI 分析的机制
- fix(users): 修复 Apple 登录未获取到邮箱时的报错问题,改为自动生成随机唯一邮箱
- perf(medications): 将服药提醒定时任务的检查频率调整为每 5 分钟一次
- refactor(push-notifications): 移除不再使用的 PushTestService
This commit is contained in:
richarjiang
2025-11-20 17:55:05 +08:00
parent 07fae9bdc0
commit afe6ae1c6a
6 changed files with 308 additions and 9 deletions

View File

@@ -29,10 +29,10 @@ export class MedicationReminderService {
) {}
/**
* 每1分钟检查一次需要发送的提前提醒
* 每5分钟检查一次需要发送的提前提醒
* 只有主进程NODE_APP_INSTANCE=0执行避免多进程重复发送
*/
@Cron('*/1 * * * *')
@Cron('*/5 * * * *')
async checkAndSendReminders(): Promise<void> {
this.logger.log('开始检查服药提醒');
@@ -48,9 +48,7 @@ export class MedicationReminderService {
// 计算时间范围:当前时间 + 15分钟
const now = new Date();
const reminderTime = dayjs(now)
.add(this.REMINDER_MINUTES_BEFORE, 'minute')
.toDate();
// 查找在接下来1分钟内需要提醒的记录
const startRange = now;