|
@@ -13,6 +13,7 @@ import {
|
|
|
getRecordsInfoByMonth,
|
|
|
getTypesById,
|
|
|
delFileByRecordId,
|
|
|
+ delByRecordId,
|
|
|
} from "#db";
|
|
|
import { shanghaiTime, shanghaiTimeFormat } from "#utils";
|
|
|
import dayjs from "dayjs";
|
|
@@ -115,9 +116,9 @@ router.get("/:record_id", async function (req, res) {
|
|
|
}
|
|
|
function getFileUrl(elm) {
|
|
|
// 获取请求的来源域名
|
|
|
- const host = req.headers['host']; // 主机名 + 端口
|
|
|
+ const host = req.headers["host"]; // 主机名 + 端口
|
|
|
const origin = req.headers["referer"]; // 请求的来源域(适用于跨域)
|
|
|
- if (`${origin}`.indexOf("3032") > -1 || `${host}`.indexOf('3000') > -1) {
|
|
|
+ if (`${origin}`.indexOf("3032") > -1 || `${host}`.indexOf("3000") > -1) {
|
|
|
return "http://localhost:3000" + `/api_files_${elm.file_id}`;
|
|
|
}
|
|
|
if (`${origin}`.indexOf("zs_interval") > -1) {
|
|
@@ -243,4 +244,30 @@ router.get("/:book_id/m/:time", async function (req, res) {
|
|
|
})),
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+// 根据日期获取数据
|
|
|
+router.delete("/:record_id", async function (req, res) {
|
|
|
+ const record_id = req.params.record_id; // 获取 fileId 参数
|
|
|
+ const { userInfo = {} } = req.body;
|
|
|
+ console.log(251, userInfo, record_id);
|
|
|
+ const recordInfo = await getRecordInfoById(record_id);
|
|
|
+
|
|
|
+ // 删除附件映射关系
|
|
|
+ const getAllfiles = await getFileByRecordId(record_id);
|
|
|
+ if (getAllfiles.length) {
|
|
|
+ await Promise.all(
|
|
|
+ getAllfiles.map((elm) =>
|
|
|
+ delFileByRecordId(record_id, elm.file_id)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除record数据
|
|
|
+ await delByRecordId(record_id, userInfo.user_id);
|
|
|
+
|
|
|
+ res.json({
|
|
|
+ code: 200,
|
|
|
+ data: '',
|
|
|
+ });
|
|
|
+});
|
|
|
export default router;
|