Преглед на файлове

공통 페이징 수정

junekeunsong преди 4 години
родител
ревизия
2bd3f99869

+ 56 - 17
src/main/java/com/lemon/lifecenter/common/LifeCenterPaging.java

@@ -1,28 +1,65 @@
 package com.lemon.lifecenter.common;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
 public class LifeCenterPaging {
-    @Autowired
-    private LifeCenterConfigVO config;
     
-    private int pageSize; // 게시 글 수
-    private int firstPageNo; // 첫 번째 페이지 번호
-    private int prevPageNo; // 이전 페이지 번호
-    private int startPageNo; // 시작 페이지 (페이징 네비 기준)
-    private int pageNo; // 페이지 번호
-    private int endPageNo; // 끝 페이지 (페이징 네비 기준)
-    private int nextPageNo; // 다음 페이지 번호
-    private int finalPageNo; // 마지막 페이지 번호
-    private int totalCount; // 게시 글 전체 수
-    private int groupCount; // 출력되는 페이징 그룹 숫자
-    private String url;
-    private String preFix;
-    private String another;
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    
+    
+    private static LifeCenterConfigVO config;
+    
+    private int pageSize = 0; // 게시 글 수
+    private int firstPageNo = 0; // 첫 번째 페이지 번호
+    private int prevPageNo = 0; // 이전 페이지 번호
+    private int startPageNo = 0; // 시작 페이지 (페이징 네비 기준)
+    private int pageNo = 0; // 페이지 번호
+    private int endPageNo = 0; // 끝 페이지 (페이징 네비 기준)
+    private int nextPageNo = 0; // 다음 페이지 번호
+    private int finalPageNo = 0; // 마지막 페이지 번호
+    private int totalCount = 0; // 게시 글 전체 수
+    private int groupCount = 0; // 출력되는 페이징 그룹 숫자
+    private String url = "";
+    private String preFix = "";
+    private String another = "";
+    private static LifeCenterPaging instance;
+    
+    public static LifeCenterPaging getInstance() {
+        if (instance == null) {
+            config = new LifeCenterConfigVO();
+            instance = new LifeCenterPaging();
+        } else {
+            return instance;
+        }
+        return instance;
+    }
 
     public LifeCenterPaging() {}
     
-    public LifeCenterPaging( int total, int page, String param ) {
+//    public LifeCenterPaging( int total, int page, String param ) {
+//        System.out.println( "3s page : " + page );
+//        System.out.println( "3s total : " + total );
+//        System.out.println( "param : " + param );
+//        
+////        System.out.println( "config.pagePrefix : " + config.pagePrefix );
+////        System.out.println( "config.pageDataSize : " + config.pageDataSize );
+////        System.out.println( "config.pageGroupSize : " + config.pageGroupSize );
+//        
+//        logger.error("config.pagePrefix -- > " + config);
+//        
+//        this.setPreFix( config.pagePrefix );
+//        this.setPageSize( config.pageDataSize );
+//        this.setGroupCount( config.pageGroupSize );
+//        this.setTotalCount( total );
+//        this.setPageNo( page );
+//        this.setUrl( param );
+//        
+//        this.makePaging();
+//    }
+    
+    public void paging(int total, int page, String param) {
         System.out.println( "3s page : " + page );
         System.out.println( "3s total : " + total );
         System.out.println( "param : " + param );
@@ -31,6 +68,8 @@ public class LifeCenterPaging {
 //        System.out.println( "config.pageDataSize : " + config.pageDataSize );
 //        System.out.println( "config.pageGroupSize : " + config.pageGroupSize );
         
+        logger.error("config.pagePrefix -- > " + config);
+        
         this.setPreFix( config.pagePrefix );
         this.setPageSize( config.pageDataSize );
         this.setGroupCount( config.pageGroupSize );
@@ -189,7 +228,7 @@ public class LifeCenterPaging {
      */
     public void setTotalCount(int totalCount) {
         this.totalCount = totalCount;
-        this.makePaging();
+//        this.makePaging();
     }
 
     public int getGroupCount() {

+ 5 - 1
src/main/java/com/lemon/lifecenter/controller/PatientController.java

@@ -6,6 +6,7 @@ import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.DependsOn;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -19,6 +20,7 @@ import com.lemon.lifecenter.service.PatientService;
 
 @Controller
 @RequestMapping("/patient")
+//@DependsOn(value = {"LifeCenterPaging"})
 public class PatientController extends LifeCenterController {
     @Autowired
     private PatientService patientService;
@@ -26,6 +28,8 @@ public class PatientController extends LifeCenterController {
     @Autowired
     private LifeCenterConfigVO config;
     
+    private LifeCenterPaging paging;
+    
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @RequestMapping("/list")
@@ -61,7 +65,7 @@ public class PatientController extends LifeCenterController {
         System.out.println( "PatientController config.pageGroupSize : " + config.pageGroupSize );
         
         String param = "patientName=" + patientName + "&inputState=" + inputState + "&startDate=" + startDate + "&endDate=" + endDate;
-        LifeCenterPaging paging = new LifeCenterPaging( total, page, param );
+        LifeCenterPaging.getInstance().paging(total, page, param);
         
         mv.addObject("inputState", inputState);
         mv.addObject("patientName", patientName);