Skip to content

Commit

Permalink
게시물 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wjxor committed Jul 15, 2021
1 parent dc7ef6f commit 26f560d
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,35 @@ private boolean deleteArticle(int id) {
return false;

}

@RequestMapping("/usr/article/doModify")
@ResponseBody
public Map<String, Object> doModify(int id, String title, String body) {
Article selArticle = null;

for (Article article : articles) {
if (article.getId() == id) {
selArticle = article;
break;
}
}

Map<String, Object> rs = new HashMap<>();

if (selArticle == null) {
rs.put("resultCode", "F-1");
rs.put("msg", String.format("%d번 게시물은 존재하지 않습니다.", id));

return rs;
}

selArticle.setTitle(title);
selArticle.setBody(body);

rs.put("resultCode", "S-1");
rs.put("msg", String.format("%d번 게시물이 수정되었습니다.", id));
rs.put("id", id);

return rs;
}
}

0 comments on commit 26f560d

Please sign in to comment.