feat: 모드팩 수정/삭제 API 추가
- PUT /api/admin/modpacks/🆔 변경 로그 수정 - DELETE /api/admin/modpacks/🆔 모드팩 삭제 (DB)
This commit is contained in:
parent
e586520b90
commit
3ab156cd56
1 changed files with 58 additions and 0 deletions
|
|
@ -473,4 +473,62 @@ router.post(
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* PUT /api/admin/modpacks/:id - 모드팩 수정 (변경 로그만)
|
||||
*/
|
||||
router.put("/modpacks/:id", async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const { changelog } = req.body;
|
||||
|
||||
const [result] = await pool.query(
|
||||
`UPDATE modpacks SET changelog = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?`,
|
||||
[changelog, id]
|
||||
);
|
||||
|
||||
if (result.affectedRows === 0) {
|
||||
return res.status(404).json({ error: "모드팩을 찾을 수 없습니다" });
|
||||
}
|
||||
|
||||
console.log(`[Admin] 모드팩 수정 완료: ID ${id}`);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("[Admin] 모드팩 수정 오류:", error);
|
||||
res.status(500).json({ error: "수정 실패" });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* DELETE /api/admin/modpacks/:id - 모드팩 삭제
|
||||
*/
|
||||
router.delete("/modpacks/:id", async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
|
||||
// DB에서 파일 정보 조회
|
||||
const [rows] = await pool.query(`SELECT * FROM modpacks WHERE id = ?`, [
|
||||
id,
|
||||
]);
|
||||
if (rows.length === 0) {
|
||||
return res.status(404).json({ error: "모드팩을 찾을 수 없습니다" });
|
||||
}
|
||||
|
||||
const modpack = rows[0];
|
||||
|
||||
// S3에서 삭제 (deleteFromS3 함수 필요 - 일단 생략, 나중에 추가)
|
||||
// TODO: S3 파일 삭제 구현
|
||||
|
||||
// DB에서 삭제
|
||||
await pool.query(`DELETE FROM modpacks WHERE id = ?`, [id]);
|
||||
|
||||
console.log(
|
||||
`[Admin] 모드팩 삭제 완료: ${modpack.name} v${modpack.version}`
|
||||
);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("[Admin] 모드팩 삭제 오류:", error);
|
||||
res.status(500).json({ error: "삭제 실패" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue