Skip to content

Commit

Permalink
feat : 오답 포스트잇 설명, 중요도 수정 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
mic050r committed Dec 15, 2023
1 parent 3a112b8 commit 899d47a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions routes/wrong.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ router.get("/:id", (req, res) => {
});
});

// 오답 포스트잇 설명, 중요도 수정
router.put("/:id", async (req, res) => {
try {
const { id } = req.params;
const { importance, description } = req.body;
const conn = await pool.getConnection();
const result = await conn.query(
"UPDATE Wrong SET importance = ? , description =? WHERE id = ?",
[importance, description, id]
);
conn.release();

if (result.affectedRows === 0) {
res.status(404).json({ error: "데이터를 찾을 수 없습니다." });
} else {
res.json({ message: "데이터가 성공적으로 업데이트되었습니다." });
}
} catch (err) {
console.error("데이터 업데이트 오류:", err);
res.status(500).json({ error: "데이터 업데이트 오류" });
}
});

// 오답 포스트잇 중요도 태그 별 GET API
router.get("/importance", (req, res) => {
const { token, importance } = req.query;
Expand Down

0 comments on commit 899d47a

Please sign in to comment.