Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit f6cfd2f1 authored by 65160111's avatar 65160111
Browse files

Edit report url image

parent 8a289fb9
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,8 @@ router.get("/", authMiddleware, (req, res) => {
const floor = req.query.floor; // optional: ชั้นที่เลือก
const room = req.query.room; // optional: ห้องที่เลือก
const BASE_URL = "https://repairsys.th2.melon.cloud"; // ✅ ใช้ URL จริงของ Melon Cloud
let conditions = ["(reports.title LIKE ? OR reports.description LIKE ?)"];
let params = [`%${search}%`, `%${search}%`];
......@@ -75,7 +77,9 @@ router.get("/", authMiddleware, (req, res) => {
results.forEach(report => {
if (report.image_url) {
report.image_url = `http://localhost:8080${report.image_url}`;
report.image_url = `${BASE_URL}${report.image_url}`;
} else {
report.image_url = null; // 🔥 ป้องกันกรณีไม่มีรูปภาพ
}
});
......@@ -89,6 +93,8 @@ router.get("/", authMiddleware, (req, res) => {
// 🔹 Get Single Report by ID
router.get("/:id", authMiddleware, (req, res) => {
const BASE_URL = "https://repairsys.th2.melon.cloud"; // ✅ ใช้ URL จริงของ Melon Cloud
db.query(`
SELECT reports.*, users.username, rooms.room_name, rooms.floor
FROM reports
......@@ -102,13 +108,15 @@ router.get("/:id", authMiddleware, (req, res) => {
const report = results[0];
if (report.image_url) {
// ลบช่องว่างที่ไม่จำเป็นออก
report.image_url = `http://localhost:8080${report.image_url}`;
report.image_url = `${BASE_URL}${report.image_url}`;
} else {
report.image_url = null; // 🔥 ป้องกันกรณีไม่มีรูปภาพ
}
res.json(report);
});
});
});
// 🔹 Update Report (แก้ไขเฉพาะ Title, Description)
router.put("/:id", authMiddleware, (req, res) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment