Open chessta0126 opened 1 year ago
공지사항 / 게시판의 글 목록, 글 상세, 글쓰기 관련 기능은
http://localhost:8080/post/postList?postType={postType}
List<Post> postList = postBO.getPostListByPostType(postType);
글쓰기와 수정하기는 같은 페이지 화면 공유
[x] @GetMapping("/post_create_view")
GetMapping 쿼리스트링으로 파라미터 받아오기
[x] postType : 공지사항 / 자유게시판 여부
[x] isUpdate : 글쓰기 / 글 수정 여부
[x] postId : 글 수정 시 어떤 글 수정?
http://localhost:8080/post/post_create_view?postType={postType}&isUpdate={isUpdate}&postId={postId}
model에 담아 내려주기
[x] layout에 넘겨줄 jsp 주소
[x] postType (어느 게시판)
[x] user (작성자) : session의 userId로 User 객체 꺼내온다
[x] isUpdate : 글 수정(update)인지, 글 작성(insert)인지 파악(화면 공유)
if(isUpdate) { // 글 수정일 경우 model.addAttribute("isUpdate",true); model.addAttribute("postId",postId); } else { model.addAttribute("isUpdate",false); model.addAttribute("postId",0); }
[x] return "template/layout";
[x] @GetMapping("/post_detail_view")
http://localhost:8080/post/post_detail_view?postType={postType}&postId=${postId}
[x] postId (어떤 글)
[x] layout에 넘겨줄 jsp 주소 (post/postDetail)
[x] post : 파라미터인 postId로 글 객체 전체 정보를 가져와서 내려줌 post.getUserId();로 작성자 정보 가져오되, 보안을 위해 이름과 id만 내려준다.
[x] postUserName
[x] postUserId 댓글 가져오기 (댓글쓴이-댓글이 매칭되어 있는 commentView 형태의 List)
[x] commentViewList (글에 해당하는 댓글 전체)
Map<String, Object> result = new HashMap<>();
result.put("postType", post.getPostType()); result.put("postId", post.getId());
어떤 글인지 (postId), 누가 썼는지(postUserId) 알아야 지움
[x] @DeleteMapping("/delete")
[x] 파라미터 postId로 Post 객체 가져오기 -> postType 뽑아내기
[x] DB delete
삭제 성공 후
[x] Json 내려줄 map 객체 생성(result)
[x] 성공 시 내려줄 결과 담기 : result.put("result", true);
[x] 삭제 후 이동할 페이지의 파라미터로 쓰일 postType을 result에 담아 보내기
[x] return result;
[x] @Service
[x] @Autowired private PostDAO postDAO;
[x] @Autowired private CommentBO commentBO;
메서드
[x] 글 목록 가져오기(select) : List
파라미터 : postType
[x] 글 가져오기(select) : Post
파라미터 : postId
[x] 글 작성(insert) : void
파라미터 : post 형태로 보내기
[x] 글 수정(Update) : void
파라미터 : postId, postUpdatedTitle, updatedContent
[x] 글 삭제(delete) : void
파라미터 : postId, postUserId
[x] 글(post) 삭제
[x] 댓글(comment) 전체 삭제
[ ] 좋아요(like) 삭제
[ ] 조회수(view) 삭제
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="DAO 경로">
postList 가져오기 (select)
post 가져오기 (select)
글 작성 (insert)
글 수정 (update)
글 삭제 (delete)
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:forEach items="${postList}" var="post"></c:forEach>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<td><fmt:formatDate value="${post.createdAt}" pattern="yyyy-MM-dd"/></td>
공지사항 / 게시판의 글 목록, 글 상세, 글쓰기 관련 기능은
PostController
1. 글 목록 화면
2. 글 쓰기(insert), 수정하기(update)
글쓰기와 수정하기는 같은 페이지 화면 공유
[x] @GetMapping("/post_create_view")
GetMapping 쿼리스트링으로 파라미터 받아오기
[x] postType : 공지사항 / 자유게시판 여부
[x] isUpdate : 글쓰기 / 글 수정 여부
[x] postId : 글 수정 시 어떤 글 수정?
model에 담아 내려주기
[x] layout에 넘겨줄 jsp 주소
[x] postType (어느 게시판)
[x] user (작성자) : session의 userId로 User 객체 꺼내온다
[x] isUpdate : 글 수정(update)인지, 글 작성(insert)인지 파악(화면 공유)
[x] return "template/layout";
3. 글 상세 화면(글, 댓글 내려주기)
[x] @GetMapping("/post_detail_view")
GetMapping 쿼리스트링으로 파라미터 받아오기
[x] postType (어느 게시판)
[x] postId (어떤 글)
model에 담아 내려주기
[x] layout에 넘겨줄 jsp 주소 (post/postDetail)
[x] post : 파라미터인 postId로 글 객체 전체 정보를 가져와서 내려줌 post.getUserId();로 작성자 정보 가져오되, 보안을 위해 이름과 id만 내려준다.
[x] postUserName
[x] postUserId 댓글 가져오기 (댓글쓴이-댓글이 매칭되어 있는 commentView 형태의 List)
[x] commentViewList (글에 해당하는 댓글 전체)
PostRestController
1. 글 쓰기 (/post/create)
2. 글 수정 (/post/update)
3. 글 삭제 (/post/delete)
어떤 글인지 (postId), 누가 썼는지(postUserId) 알아야 지움
[x] @DeleteMapping("/delete")
[x] 파라미터 postId로 Post 객체 가져오기 -> postType 뽑아내기
[x] DB delete
삭제 성공 후
[x] Json 내려줄 map 객체 생성(result)
[x] 성공 시 내려줄 결과 담기 : result.put("result", true);
[x] 삭제 후 이동할 페이지의 파라미터로 쓰일 postType을 result에 담아 보내기
[x] return result;
Post (model)
PostBO
[x] @Service
[x] @Autowired private PostDAO postDAO;
[x] @Autowired private CommentBO commentBO;
메서드
[x] 글 목록 가져오기(select) : List
파라미터 : postType
[x] 글 가져오기(select) : Post
파라미터 : postId
[x] 글 작성(insert) : void
파라미터 : post 형태로 보내기
[x] 글 수정(Update) : void
파라미터 : postId, postUpdatedTitle, updatedContent
[x] 글 삭제(delete) : void
파라미터 : postId, postUserId
[x] 글(post) 삭제
[x] 댓글(comment) 전체 삭제
[ ] 좋아요(like) 삭제
[ ] 조회수(view) 삭제
PostDAO
postMapper.xml
postList 가져오기 (select)
post 가져오기 (select)
글 작성 (insert)
글 수정 (update)
글 삭제 (delete)
jsp
PostList.jsp (글 목록)
postList 받아와서 반복문으로 글 목록 뿌리기
PostCreate.jsp (글쓰기)
Githubissues.