@@ -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)));
|
||||
|
||||
}
|
||||
|
||||
/* 작가 등록 */
|
||||
|
||||
@@ -13,4 +13,7 @@ public interface AuthorMapper {
|
||||
/* 작가 목록 */
|
||||
public List<AuthorVO> authorGetList(Criteria cri);
|
||||
|
||||
/* 작가 총 수 */
|
||||
public int authorGetTotal(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
105
VamPa/src/main/java/com/vam/model/PageDTO.java
Normal file
105
VamPa/src/main/java/com/vam/model/PageDTO.java
Normal file
@@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -13,4 +13,7 @@ public interface AuthorService {
|
||||
/* 작가 목록 */
|
||||
public List<AuthorVO> authorGetList(Criteria cri) throws Exception;
|
||||
|
||||
/* 작가 총 수 */
|
||||
public int authorGetTotal(Criteria cri) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,17 @@
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 작가 수 -->
|
||||
<select id="authorGetTotal" resultType="int">
|
||||
|
||||
select count(*) from vam_author
|
||||
|
||||
<if test="keyword != null">
|
||||
|
||||
where authorname like '%' || #{keyword} || '%'
|
||||
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -42,7 +42,44 @@
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 페이지 이동 인터페이스 영역 -->
|
||||
<div class="pageMaker_wrap" >
|
||||
|
||||
<ul class="pageMaker">
|
||||
|
||||
<!-- 이전 버튼 -->
|
||||
<c:if test="${pageMaker.prev}">
|
||||
<li class="pageMaker_btn prev">
|
||||
<a href="${pageMaker.pageStart - 1}">이전</a>
|
||||
</li>
|
||||
</c:if>
|
||||
|
||||
<!-- 페이지 번호 -->
|
||||
<c:forEach begin="${pageMaker.pageStart}" end="${pageMaker.pageEnd}" var="num">
|
||||
<li class="pageMaker_btn ${pageMaker.cri.pageNum == num ? "active":""}">
|
||||
<a href="${num}">${num}</a>
|
||||
</li>
|
||||
</c:forEach>
|
||||
|
||||
<!-- 다음 버튼 -->
|
||||
<c:if test="${pageMaker.next}">
|
||||
<li class="pageMaker_btn next">
|
||||
<a href="${pageMaker.pageEnd + 1 }">다음</a>
|
||||
</li>
|
||||
</c:if>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<form id="moveForm" action="/admin/authorManage" method="get">
|
||||
<input type="hidden" name="pageNum" value="${pageMaker.cri.pageNum}">
|
||||
<input type="hidden" name="amount" value="${pageMaker.cri.amount}">
|
||||
<input type="hidden" name="keyword" value="${pageMaker.cri.keyword}">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<%@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();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -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 영역 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,4 +35,17 @@
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 작가 수 -->
|
||||
<select id="authorGetTotal" resultType="int">
|
||||
|
||||
select count(*) from vam_author
|
||||
|
||||
<if test="keyword != null">
|
||||
|
||||
where authorname like '%' || #{keyword} || '%'
|
||||
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -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)));
|
||||
|
||||
}
|
||||
|
||||
/* 작가 등록 */
|
||||
|
||||
@@ -13,4 +13,7 @@ public interface AuthorMapper {
|
||||
/* 작가 목록 */
|
||||
public List<AuthorVO> authorGetList(Criteria cri);
|
||||
|
||||
/* 작가 총 수 */
|
||||
public int authorGetTotal(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
104
VamPa_MySQL/src/main/java/com/vam/model/PageDTO.java
Normal file
104
VamPa_MySQL/src/main/java/com/vam/model/PageDTO.java
Normal file
@@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,4 +13,7 @@ public interface AuthorService {
|
||||
/* 작가 목록 */
|
||||
public List<AuthorVO> authorGetList(Criteria cri) throws Exception;
|
||||
|
||||
/* 작가 총 수 */
|
||||
public int authorGetTotal(Criteria cri) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,4 +25,17 @@
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 작가 수 -->
|
||||
<select id="authorGetTotal" resultType="int">
|
||||
|
||||
select count(*) from vam_author
|
||||
|
||||
<if test="keyword != null">
|
||||
|
||||
where authorname like concat('%', #{keyword}, '%');
|
||||
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -42,7 +42,44 @@
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 페이지 이동 인터페이스 영역 -->
|
||||
<div class="pageMaker_wrap" >
|
||||
|
||||
<ul class="pageMaker">
|
||||
|
||||
<!-- 이전 버튼 -->
|
||||
<c:if test="${pageMaker.prev}">
|
||||
<li class="pageMaker_btn prev">
|
||||
<a href="${pageMaker.pageStart - 1}">이전</a>
|
||||
</li>
|
||||
</c:if>
|
||||
|
||||
<!-- 페이지 번호 -->
|
||||
<c:forEach begin="${pageMaker.pageStart}" end="${pageMaker.pageEnd}" var="num">
|
||||
<li class="pageMaker_btn ${pageMaker.cri.pageNum == num ? "active":""}">
|
||||
<a href="${num}">${num}</a>
|
||||
</li>
|
||||
</c:forEach>
|
||||
|
||||
<!-- 다음 버튼 -->
|
||||
<c:if test="${pageMaker.next}">
|
||||
<li class="pageMaker_btn next">
|
||||
<a href="${pageMaker.pageEnd + 1 }">다음</a>
|
||||
</li>
|
||||
</c:if>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<form id="moveForm" action="/admin/authorManage" method="get">
|
||||
<input type="hidden" name="pageNum" value="${pageMaker.cri.pageNum}">
|
||||
<input type="hidden" name="amount" value="${pageMaker.cri.amount}">
|
||||
<input type="hidden" name="keyword" value="${pageMaker.cri.keyword}">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<%@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();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -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 영역 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,4 +25,17 @@
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 작가 수 -->
|
||||
<select id="authorGetTotal" resultType="int">
|
||||
|
||||
select count(*) from vam_author
|
||||
|
||||
<if test="keyword != null">
|
||||
|
||||
where authorname like concat('%', #{keyword}, '%');
|
||||
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user