package idc.comment.command;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import idc.model.IdcMemberDBDTO;
import java.util.ArrayList;

public class commentListCmd implements CommentCmd{
	
	public void execute(HttpServletRequest request, HttpServletResponse response) {

		CommentDAO dao = new CommentDAO();
		ArrayList<CommentDTO>sendList;
		ArrayList<CommentDTO>receivedList;
		
		int pageCnt = 0;
		int r_pageCnt = 0;
		
		String curPage = request.getParameter("curPage");
		
		if(curPage == null || curPage == ""){
			curPage = "1";
		}
		
		//세션에서 아이디값을 불러온다
		IdcMemberDBDTO d1to = (IdcMemberDBDTO)request.getSession().getAttribute("member");
		String id = d1to.getId();

		sendList = dao.getCommentList(curPage, id);		
		request.setAttribute("sendList", sendList);
		
		pageCnt = dao.commentPageCnt(id);
		request.setAttribute("pageCnt", pageCnt);
				
		String r_curPage = request.getParameter("r_curPage");
		if(r_curPage == null || r_curPage == ""){
			r_curPage = "1";
		}
		
		receivedList = dao.getReceivedList(r_curPage, id);		
		request.setAttribute("receivedList", receivedList);
		
		r_pageCnt = dao.receivedPageCnt(id);
		request.setAttribute("r_pageCnt", r_pageCnt);

	}

}
