갯수 int t
갯수
int totalRviewCnt = reviewDao.getTotalReviewCnt(productNo);
// 페이징 처리
int pageSize = 10;
int blockSize = 10;
int totalPage = (int)Math.ceil((double)totalReviewCnt/pageSize);
int startRow = (pageNum-1)*pageSize;
int startPage = ((pageNum-1)/blockSize)*blockSize+1;
int endPage = startPage + blockSize – 1;
if(endPage > totalPage) {
endPage = totalPage;
}
List list = reviewDao.getReviewList(productNo, startRow, pageSize);
Map map = new HashMap();
map.put(“list”, list);
map.put(“totalPage”, totalPage);
map.put(“startPage”, startPage);
map.put(“endPage”, endPage);
map.put(“pageNum”, pageNum);
return map;
}
// 리뷰 작성
public int writeReview(Review review) {
return reviewDao.insertReview(review);
}
// 리뷰 수정
public int modifyReview(Review review) {
return reviewDao.updateReview(review);
}
// 리뷰 삭제
public int deleteReview(int reviewNo) {
return reviewDao.deleteReview(reviewNo);
}
// 리뷰 상세보기
public Review getReview(int reviewNo) {
return reviewDao.getReview(reviewNo);
}
// 리뷰 평점 평균
public double getAvgRating(int productNo) {
return reviewDao.getAvgRating(productNo);
}
// 리뷰 갯수
public int getReviewCnt(int productNo) {
return reviewDao.getReviewCnt(productNo);
}
// 리뷰 작성 가능 여부
public boolean canWriteReview(int memberNo, int productNo) {
return reviewDao.selectReviewByMemberNoProductNo(memberNo, productNo) == null;
}
}