회사는 정말 싫어욧

복붙해서 만든 DTO로만 몇군데 수정해주면 된다 (오라클 DB일 경우 사용)


public class Paging {

private List<BoardDTO> list;

private int totalCount;

private int pageSize;

private int currentPage;

private int totalPage;

private int startNo;

private int endNo;

private int startPage;

private int endPage;

public Paging(int totalCount, int pageSize, int currentPage) {

this.totalCount = totalCount;

this.pageSize = pageSize;

this.currentPage = currentPage;

calc();

}


private void calc() {

if(this.totalCount>0){

this.totalPage = (this.totalCount-1)/this.pageSize + 1;

if(this.currentPage<1 || this.currentPage>this.totalPage)

this.currentPage = 1;

this.startNo = (this.currentPage-1) * this.pageSize + 1;

this.endNo = this.startNo + this.pageSize -1;

if(this.endNo>this.totalCount) this.endNo = this.totalCount;

this.startPage = (this.currentPage-1)/this.pageSize * this.pageSize+1;

this.endPage = this.startPage+this.pageSize - 1;

if(this.endPage>this.totalPage) this.endPage=this.totalPage;

}else{

totalCount=0;

}

}


public List<BoardDTO> getList() {

return list;

}


public void setList(List<BoardDTO> list) {

this.list = list;

}


public int getTotalCount() {

return totalCount;

}


public void setTotalCount(int totalCount) {

this.totalCount = totalCount;

calc();

}


public int getPageSize() {

return pageSize;

}


public void setPageSize(int pageSize) {

this.pageSize = pageSize;

calc();

}


public int getCurrentPage() {

return currentPage;

}


public void setCurrentPage(int currentPage) {

this.currentPage = currentPage;

calc();

}


public int getTotalPage() {

return totalPage;

}


public int getStartNo() {

return startNo;

}


public int getEndNo() {

return endNo;

}


public int getStartPage() {

return startPage;

}


public int getEndPage() {

return endPage;

}

}