diff --git a/VamPa/src/main/java/com/vam/controller/AdminController.java b/VamPa/src/main/java/com/vam/controller/AdminController.java index fb5b6fd..3eb5a81 100644 --- a/VamPa/src/main/java/com/vam/controller/AdminController.java +++ b/VamPa/src/main/java/com/vam/controller/AdminController.java @@ -13,6 +13,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.vam.model.AuthorVO; import com.vam.model.Criteria; +import com.vam.model.PageDTO; import com.vam.service.AuthorService; @Controller @@ -61,6 +62,9 @@ public class AdminController { model.addAttribute("list", list); + /* 페이지 이동 인터페이스 데이터 */ + model.addAttribute("pageMaker", new PageDTO(cri, authorService.authorGetTotal(cri))); + } /* 작가 등록 */ diff --git a/VamPa/src/main/java/com/vam/mapper/AuthorMapper.java b/VamPa/src/main/java/com/vam/mapper/AuthorMapper.java index 0bbeba3..75a22b7 100644 --- a/VamPa/src/main/java/com/vam/mapper/AuthorMapper.java +++ b/VamPa/src/main/java/com/vam/mapper/AuthorMapper.java @@ -13,4 +13,7 @@ public interface AuthorMapper { /* 작가 목록 */ public List authorGetList(Criteria cri); + /* 작가 총 수 */ + public int authorGetTotal(Criteria cri); + } diff --git a/VamPa/src/main/java/com/vam/model/PageDTO.java b/VamPa/src/main/java/com/vam/model/PageDTO.java new file mode 100644 index 0000000..56e22d3 --- /dev/null +++ b/VamPa/src/main/java/com/vam/model/PageDTO.java @@ -0,0 +1,105 @@ +package com.vam.model; + +public class PageDTO { + + /* 페이지 시작 번호 */ + private int pageStart; + + /* 페이지 끝 번호 */ + private int pageEnd; + + /* 이전, 다음 버튼 존재 유무 */ + private boolean next, prev; + + /* 행 전체 개수 */ + private int total; + + /* 현재페이지 번호(pageNum), 행 표시 수(amount), 검색 키워드(keyword), 검색 종류(type) */ + private Criteria cri; + + /* 생성자(클래스 호출 시 각 변수 값 초기화) */ + public PageDTO(Criteria cri, int total) { + + /* cri, total 초기화 */ + this.cri = cri; + this.total = total; + + /* 페이지 끝 번호 */ + this.pageEnd = (int)(Math.ceil(cri.getPageNum()/10.0))*10; + + /* 페이지 시작 번호 */ + this.pageStart = this.pageEnd - 9; + + /* 전체 마지막 페이지 번호 */ + int realEnd = (int)(Math.ceil(total*1.0/cri.getAmount())); + + /* 페이지 끝 번호 유효성 체크 */ + if(realEnd < pageEnd) { + this.pageEnd = realEnd; + } + + /* 이전 버튼 값 초기화 */ + this.prev = this.pageStart > 1; + + /* 다음 버튼 값 초기화 */ + this.next = this.pageEnd < realEnd; + + } + + public int getPageStart() { + return pageStart; + } + + public void setPageStart(int pageStart) { + this.pageStart = pageStart; + } + + public int getPageEnd() { + return pageEnd; + } + + public void setPageEnd(int pageEnd) { + this.pageEnd = pageEnd; + } + + public boolean isNext() { + return next; + } + + public void setNext(boolean next) { + this.next = next; + } + + public boolean isPrev() { + return prev; + } + + public void setPrev(boolean prev) { + this.prev = prev; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public Criteria getCri() { + return cri; + } + + public void setCri(Criteria cri) { + this.cri = cri; + } + + @Override + public String toString() { + return "PageDTO [pageStart=" + pageStart + ", pageEnd=" + pageEnd + ", next=" + next + ", prev=" + prev + + ", total=" + total + ", cri=" + cri + "]"; + } + + + +} diff --git a/VamPa/src/main/java/com/vam/service/AuthorService.java b/VamPa/src/main/java/com/vam/service/AuthorService.java index 9c504da..ab8493c 100644 --- a/VamPa/src/main/java/com/vam/service/AuthorService.java +++ b/VamPa/src/main/java/com/vam/service/AuthorService.java @@ -13,4 +13,7 @@ public interface AuthorService { /* 작가 목록 */ public List authorGetList(Criteria cri) throws Exception; + /* 작가 총 수 */ + public int authorGetTotal(Criteria cri) throws Exception; + } diff --git a/VamPa/src/main/java/com/vam/service/AuthorServiceImpl.java b/VamPa/src/main/java/com/vam/service/AuthorServiceImpl.java index bd59d92..6aeb2fe 100644 --- a/VamPa/src/main/java/com/vam/service/AuthorServiceImpl.java +++ b/VamPa/src/main/java/com/vam/service/AuthorServiceImpl.java @@ -35,5 +35,12 @@ public class AuthorServiceImpl implements AuthorService { return authorMapper.authorGetList(cri); } + + /* 작가 총 수 */ + @Override + public int authorGetTotal(Criteria cri) throws Exception { + log.info("(service)authorGetTotal()......." + cri); + return authorMapper.authorGetTotal(cri); + } } diff --git a/VamPa/src/main/resources/com/vam/mapper/AuthorMapper.xml b/VamPa/src/main/resources/com/vam/mapper/AuthorMapper.xml index 4f93a16..a48cbe7 100644 --- a/VamPa/src/main/resources/com/vam/mapper/AuthorMapper.xml +++ b/VamPa/src/main/resources/com/vam/mapper/AuthorMapper.xml @@ -35,4 +35,17 @@ + + + \ No newline at end of file diff --git a/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp b/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp index 3df803e..4f8982a 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp @@ -42,7 +42,44 @@ - + + + +
+ + + +
+ +
+ + + +
+ <%@include file="../includes/admin/footer.jsp" %> @@ -65,6 +102,20 @@ $(document).ready(function(){ } }); + +let moveForm = $('#moveForm'); + +/* 페이지 이동 버튼 */ +$(".pageMaker_btn a").on("click", function(e){ + + e.preventDefault(); + + moveForm.find("input[name='pageNum']").val($(this).attr("href")); + + moveForm.submit(); + +}); + diff --git a/VamPa/src/main/webapp/resources/css/admin/authorManage.css b/VamPa/src/main/webapp/resources/css/admin/authorManage.css index 78ee2fb..920f021 100644 --- a/VamPa/src/main/webapp/resources/css/admin/authorManage.css +++ b/VamPa/src/main/webapp/resources/css/admin/authorManage.css @@ -140,6 +140,40 @@ ul{ + /* 페이지 버튼 인터페이스 */ +.pageMaker_wrap{ + text-align: center; + margin-top: 30px; + margin-bottom: 40px; +} +.pageMaker_wrap a{ + color : black; +} +.pageMaker{ + list-style: none; + display: inline-block; +} +.pageMaker_btn { + float: left; + width: 40px; + height: 40px; + line-height: 40px; + margin-left: 20px; +} +.next, .prev { + border: 1px solid #ccc; + padding: 0 10px; +} +.next a, .prev a { + color: #ccc; +} +.active{ /* 현재 페이지 버튼 */ + border : 2px solid black; + font-weight:400; +} + + + /* footer navai 영역 */ diff --git a/VamPa/src/test/java/com/vam/mapper/AuthorMapperTests.java b/VamPa/src/test/java/com/vam/mapper/AuthorMapperTests.java index 908d49c..e679dce 100644 --- a/VamPa/src/test/java/com/vam/mapper/AuthorMapperTests.java +++ b/VamPa/src/test/java/com/vam/mapper/AuthorMapperTests.java @@ -35,6 +35,7 @@ public class AuthorMapperTests { */ /* 작가 목록 테스트 */ + /* @Test public void authorGetListTest() throws Exception{ @@ -48,6 +49,21 @@ public class AuthorMapperTests { } } + */ + + /* 작가 총 수 */ + @Test + public void authorGetTotalTest() throws Exception{ + + Criteria cri = new Criteria(); + cri.setKeyword("엘런"); + + int total = mapper.authorGetTotal(cri); + + System.out.println("total........." + total); + + + } diff --git a/VamPa/target/classes/com/vam/mapper/AuthorMapper.xml b/VamPa/target/classes/com/vam/mapper/AuthorMapper.xml index 4f93a16..a48cbe7 100644 --- a/VamPa/target/classes/com/vam/mapper/AuthorMapper.xml +++ b/VamPa/target/classes/com/vam/mapper/AuthorMapper.xml @@ -35,4 +35,17 @@ + + + \ No newline at end of file diff --git a/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java b/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java index 9e29b5a..f77ee63 100644 --- a/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java +++ b/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java @@ -13,6 +13,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.vam.model.AuthorVO; import com.vam.model.Criteria; +import com.vam.model.PageDTO; import com.vam.service.AuthorService; @Controller @@ -61,6 +62,9 @@ public class AdminController { model.addAttribute("list", list); + /* 페이지 이동 인터페이스 데이터 */ + model.addAttribute("pageMaker", new PageDTO(cri, authorService.authorGetTotal(cri))); + } /* 작가 등록 */ diff --git a/VamPa_MySQL/src/main/java/com/vam/mapper/AuthorMapper.java b/VamPa_MySQL/src/main/java/com/vam/mapper/AuthorMapper.java index ab0e942..2852b6c 100644 --- a/VamPa_MySQL/src/main/java/com/vam/mapper/AuthorMapper.java +++ b/VamPa_MySQL/src/main/java/com/vam/mapper/AuthorMapper.java @@ -13,4 +13,7 @@ public interface AuthorMapper { /* 작가 목록 */ public List authorGetList(Criteria cri); + /* 작가 총 수 */ + public int authorGetTotal(Criteria cri); + } diff --git a/VamPa_MySQL/src/main/java/com/vam/model/PageDTO.java b/VamPa_MySQL/src/main/java/com/vam/model/PageDTO.java new file mode 100644 index 0000000..682f7aa --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/model/PageDTO.java @@ -0,0 +1,104 @@ +package com.vam.model; + +public class PageDTO { + + /* 페이지 시작 번호 */ + private int pageStart; + + /* 페이지 끝 번호 */ + private int pageEnd; + + /* 이전, 다음 버튼 존재 유무 */ + private boolean next, prev; + + /* 행 전체 개수 */ + private int total; + + /* 현재페이지 번호(pageNum), 행 표시 수(amount), 검색 키워드(keyword), 검색 종류(type) */ + private Criteria cri; + + /* 생성자(클래스 호출 시 각 변수 값 초기화) */ + public PageDTO(Criteria cri, int total) { + + /* cri, total 초기화 */ + this.cri = cri; + this.total = total; + + /* 페이지 끝 번호 */ + this.pageEnd = (int)(Math.ceil(cri.getPageNum()/10.0))*10; + + /* 페이지 시작 번호 */ + this.pageStart = this.pageEnd - 9; + + /* 전체 마지막 페이지 번호 */ + int realEnd = (int)(Math.ceil(total*1.0/cri.getAmount())); + + /* 페이지 끝 번호 유효성 체크 */ + if(realEnd < pageEnd) { + this.pageEnd = realEnd; + } + + /* 이전 버튼 값 초기화 */ + this.prev = this.pageStart > 1; + + /* 다음 버튼 값 초기화 */ + this.next = this.pageEnd < realEnd; + + } + + public int getPageStart() { + return pageStart; + } + + public void setPageStart(int pageStart) { + this.pageStart = pageStart; + } + + public int getPageEnd() { + return pageEnd; + } + + public void setPageEnd(int pageEnd) { + this.pageEnd = pageEnd; + } + + public boolean isNext() { + return next; + } + + public void setNext(boolean next) { + this.next = next; + } + + public boolean isPrev() { + return prev; + } + + public void setPrev(boolean prev) { + this.prev = prev; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public Criteria getCri() { + return cri; + } + + public void setCri(Criteria cri) { + this.cri = cri; + } + + @Override + public String toString() { + return "PageDTO [pageStart=" + pageStart + ", pageEnd=" + pageEnd + ", next=" + next + ", prev=" + prev + + ", total=" + total + ", cri=" + cri + "]"; + } + + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/service/AuthorService.java b/VamPa_MySQL/src/main/java/com/vam/service/AuthorService.java index 5c3ce72..e8ca9b7 100644 --- a/VamPa_MySQL/src/main/java/com/vam/service/AuthorService.java +++ b/VamPa_MySQL/src/main/java/com/vam/service/AuthorService.java @@ -13,4 +13,7 @@ public interface AuthorService { /* 작가 목록 */ public List authorGetList(Criteria cri) throws Exception; + /* 작가 총 수 */ + public int authorGetTotal(Criteria cri) throws Exception; + } diff --git a/VamPa_MySQL/src/main/java/com/vam/service/AuthorServiceImpl.java b/VamPa_MySQL/src/main/java/com/vam/service/AuthorServiceImpl.java index 214a12f..54266f5 100644 --- a/VamPa_MySQL/src/main/java/com/vam/service/AuthorServiceImpl.java +++ b/VamPa_MySQL/src/main/java/com/vam/service/AuthorServiceImpl.java @@ -36,4 +36,11 @@ public class AuthorServiceImpl implements AuthorService { return authorMapper.authorGetList(cri); } + /* 작가 총 수 */ + @Override + public int authorGetTotal(Criteria cri) throws Exception { + log.info("(service)authorGetTotal()......." + cri); + return authorMapper.authorGetTotal(cri); + } + } diff --git a/VamPa_MySQL/src/main/resources/com/vam/mapper/AuthorMapper.xml b/VamPa_MySQL/src/main/resources/com/vam/mapper/AuthorMapper.xml index d03b3a7..60e7b45 100644 --- a/VamPa_MySQL/src/main/resources/com/vam/mapper/AuthorMapper.xml +++ b/VamPa_MySQL/src/main/resources/com/vam/mapper/AuthorMapper.xml @@ -25,4 +25,17 @@ + + + \ No newline at end of file diff --git a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp index 3df803e..4f8982a 100644 --- a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp +++ b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp @@ -42,7 +42,44 @@ - + + + +
+ + + +
+ +
+ + + +
+ <%@include file="../includes/admin/footer.jsp" %> @@ -65,6 +102,20 @@ $(document).ready(function(){ } }); + +let moveForm = $('#moveForm'); + +/* 페이지 이동 버튼 */ +$(".pageMaker_btn a").on("click", function(e){ + + e.preventDefault(); + + moveForm.find("input[name='pageNum']").val($(this).attr("href")); + + moveForm.submit(); + +}); + diff --git a/VamPa_MySQL/src/main/webapp/resources/css/admin/authorManage.css b/VamPa_MySQL/src/main/webapp/resources/css/admin/authorManage.css index 78ee2fb..920f021 100644 --- a/VamPa_MySQL/src/main/webapp/resources/css/admin/authorManage.css +++ b/VamPa_MySQL/src/main/webapp/resources/css/admin/authorManage.css @@ -140,6 +140,40 @@ ul{ + /* 페이지 버튼 인터페이스 */ +.pageMaker_wrap{ + text-align: center; + margin-top: 30px; + margin-bottom: 40px; +} +.pageMaker_wrap a{ + color : black; +} +.pageMaker{ + list-style: none; + display: inline-block; +} +.pageMaker_btn { + float: left; + width: 40px; + height: 40px; + line-height: 40px; + margin-left: 20px; +} +.next, .prev { + border: 1px solid #ccc; + padding: 0 10px; +} +.next a, .prev a { + color: #ccc; +} +.active{ /* 현재 페이지 버튼 */ + border : 2px solid black; + font-weight:400; +} + + + /* footer navai 영역 */ diff --git a/VamPa_MySQL/src/test/java/com/vam/mapper/AuthorMapperTests.java b/VamPa_MySQL/src/test/java/com/vam/mapper/AuthorMapperTests.java index a8fa574..83f6a8e 100644 --- a/VamPa_MySQL/src/test/java/com/vam/mapper/AuthorMapperTests.java +++ b/VamPa_MySQL/src/test/java/com/vam/mapper/AuthorMapperTests.java @@ -35,6 +35,7 @@ public class AuthorMapperTests { */ /* 작가 목록 테스트 */ + /* @Test public void authorGetListTest() throws Exception{ @@ -48,5 +49,20 @@ public class AuthorMapperTests { } } + */ + + /* 작가 총 수 */ + @Test + public void authorGetTotalTest() throws Exception{ + + Criteria cri = new Criteria(); + cri.setKeyword("엘런"); + + int total = mapper.authorGetTotal(cri); + + System.out.println("total........." + total); + + + } } diff --git a/VamPa_MySQL/target/classes/com/vam/mapper/AuthorMapper.xml b/VamPa_MySQL/target/classes/com/vam/mapper/AuthorMapper.xml index d03b3a7..60e7b45 100644 --- a/VamPa_MySQL/target/classes/com/vam/mapper/AuthorMapper.xml +++ b/VamPa_MySQL/target/classes/com/vam/mapper/AuthorMapper.xml @@ -25,4 +25,17 @@ + + + \ No newline at end of file