fix(health): 数据完整性 + 代码规范修复 — FK约束/版本类型统一/软删除过滤
数据完整性: - 新增 8 个 FK 约束 (follow_up_task→appointment, points_transaction→account/rule/order, points_order→product/patient, offline_event_registration→event/patient) - critical_alert/critical_alert_response version 字段 i64→i32 统一 - vital_signs_daily_service 聚合查询添加 DeletedAt.is_null() 过滤 代码规范: - 新增 api/upload.ts 封装文件上传,ArticleEditor 改用 service 层 - 新增 messages.updateSubscription,NotificationPreferences 改用 service 层 - 修复 erp-message SSE 测试编译错误 (移除 serde_urlencoded 依赖)
This commit is contained in:
@@ -86,3 +86,13 @@ export async function sendMessage(req: SendMessageRequest) {
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
export interface SubscriptionUpdateReq {
|
||||
dnd_enabled: boolean;
|
||||
dnd_start?: string;
|
||||
dnd_end?: string;
|
||||
}
|
||||
|
||||
export async function updateSubscription(req: SubscriptionUpdateReq) {
|
||||
await client.put('/message-subscriptions', req);
|
||||
}
|
||||
|
||||
16
apps/web/src/api/upload.ts
Normal file
16
apps/web/src/api/upload.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import client from './client';
|
||||
|
||||
export interface UploadResult {
|
||||
url: string;
|
||||
filename?: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export async function uploadFile(file: File): Promise<UploadResult> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const { data: result } = await client.post('/upload', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
return result.data;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { useThemeMode } from '../../hooks/useThemeMode';
|
||||
import { AuthButton } from '../../components/AuthButton';
|
||||
import client, { handleApiError } from '../../api/client';
|
||||
import { uploadFile } from '../../api/upload';
|
||||
import '@wangeditor/editor/dist/css/style.css';
|
||||
|
||||
export default function ArticleEditor() {
|
||||
@@ -109,10 +110,8 @@ export default function ArticleEditor() {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const { data: result } = await client.post('/upload', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
const url: string = result.data.url;
|
||||
const result = await uploadFile(file);
|
||||
const url: string = result.url;
|
||||
const token = localStorage.getItem('access_token');
|
||||
const urlWithToken = token ? `${url}?token=${token}` : url;
|
||||
insertFn(urlWithToken, file.name, urlWithToken);
|
||||
@@ -464,12 +463,8 @@ export default function ArticleEditor() {
|
||||
showUploadList={false}
|
||||
beforeUpload={async (file) => {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const { data: result } = await client.post('/upload', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
setCoverImage(result.data.url);
|
||||
const result = await uploadFile(file);
|
||||
setCoverImage(result.url);
|
||||
message.success('封面图上传成功');
|
||||
} catch {
|
||||
message.error('封面图上传失败');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Form, Switch, TimePicker, Button, message } from 'antd';
|
||||
import { BellOutlined } from '@ant-design/icons';
|
||||
import client from '../../api/client';
|
||||
import { useThemeMode } from '../../hooks/useThemeMode';
|
||||
import { updateSubscription } from '../../api/messages';
|
||||
|
||||
interface PreferencesData {
|
||||
dnd_enabled: boolean;
|
||||
@@ -38,7 +38,7 @@ export default function NotificationPreferences() {
|
||||
}
|
||||
}
|
||||
|
||||
await client.put('/message-subscriptions', {
|
||||
await updateSubscription({
|
||||
dnd_enabled: req.dnd_enabled,
|
||||
dnd_start: req.dnd_start,
|
||||
dnd_end: req.dnd_end,
|
||||
|
||||
Reference in New Issue
Block a user