update wizard relation db store procedure parameter(erase _)
This commit is contained in:
+2
-1
@@ -11,7 +11,8 @@ const pool = mysql.createPool({
|
||||
connectionLimit: 15, // 增加併發處理能力
|
||||
queueLimit: 0,
|
||||
multipleStatements: true,
|
||||
timezone: '+08:00' // 強制時區一致
|
||||
charset: 'utf8mb4', // 確保這一行存在
|
||||
timezone: '+08:00' // 強制時區一致
|
||||
});
|
||||
|
||||
// 啟動測試
|
||||
|
||||
@@ -246,10 +246,14 @@ class OrmService {
|
||||
if (spName === 'get_treedata' || spName === 'get_assignData') {
|
||||
finalParams = [...orderedParas, "''"];
|
||||
}
|
||||
// get_treedata 應傳入3個參數
|
||||
//if (spName === 'zen_showsource') {
|
||||
// finalParams = [...orderedParas, "''"];
|
||||
//}
|
||||
// get_treedata 應傳入3個參數(會傳入 [_flow_level, _tag, para01, para02, para03])
|
||||
if (spName === 'zen_showsource' || spName === 'zen_updatesource') {
|
||||
finalParams = [body.para01, body.para02, body.para03];
|
||||
}
|
||||
//
|
||||
if (spName === 'zen_create_json_v2') {
|
||||
finalParams = [body.para01, body.para02];
|
||||
}
|
||||
|
||||
return finalParams;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const multer = require('multer');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto'); // 用於生成隨機字串
|
||||
|
||||
const storage = multer.diskStorage({
|
||||
destination: (req, file, cb) => {
|
||||
@@ -10,8 +11,45 @@ const storage = multer.diskStorage({
|
||||
cb(null, uploadPath);
|
||||
},
|
||||
filename: (req, file, cb) => {
|
||||
const dateStr = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
cb(null, `${dateStr}-${file.originalname}`);
|
||||
//下行程式會自動加入日期 tag 在檔名前, 目前先取消 2026/01/10
|
||||
//const dateStr = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
//cb(null, `${dateStr}-${file.originalname}`);
|
||||
|
||||
// 解決中文亂碼問題:將 latin1 轉回 utf-8
|
||||
//const originalName = Buffer.from(file.originalname, 'latin1').toString('utf8');
|
||||
//cb(null, `${file.originalname}`);
|
||||
|
||||
|
||||
// 1. 取得原始檔名與副檔名
|
||||
const ext = path.extname(file.originalname); // 包含點,例如 .jpg
|
||||
const baseName = path.basename(file.originalname, ext); // 只有主檔名
|
||||
|
||||
// 2. 正則表達式:判斷是否為純英數、底線、橫線
|
||||
// ^[a-zA-Z0-9_-]+$ 表示從頭到尾都是英數或底線橫線
|
||||
const isAlphaNumeric = /^[a-zA-Z0-9_-]+$/.test(baseName);
|
||||
|
||||
let finalFileName = '';
|
||||
//const dateStr = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const dateStr = new Date().toISOString().replace(/\D/g, '');
|
||||
|
||||
if (isAlphaNumeric) {
|
||||
// A. 如果是純英數,保持原樣,~~加上時間戳防止重複~~
|
||||
//finalFileName = `${dateStr}-${file.originalname}`;
|
||||
finalFileName = `${file.originalname}`;
|
||||
} else {
|
||||
// B. 如果包含中文或其他字元
|
||||
// 先修復 Multer 的編碼錯誤 (latin1 -> utf8)
|
||||
const decodedName = Buffer.from(file.originalname, 'latin1').toString('utf8');
|
||||
|
||||
// 為了系統穩定,硬碟端存儲建議改用「隨機英數」防止 URL 編碼問題
|
||||
const uniqueSuffix = crypto.randomBytes(4).toString('hex');
|
||||
finalFileName = `${dateStr}-${uniqueSuffix}${ext}`;
|
||||
|
||||
// 將正確的中文名稱掛載,供 Controller 存入資料庫使用
|
||||
file.decodedOriginalName = decodedName;
|
||||
}
|
||||
|
||||
cb(null, finalFileName);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user