Browse Source

푸시 수신시 비대면 진료 화면 이동 로직 수정

junekeunsong 4 years ago
parent
commit
f7d4f3f66c

+ 6 - 1
src/main/java/com/lemon/lifecenter/common/LifeCenterInterCeptor.java

@@ -43,6 +43,7 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
         logger.info( "|------------------------------------------------------------------|" );
         logger.info( "|  URL : " + url + "  |  IP : " + LifeCenterFunction.getRemoteAddr(request) + "  |  Port : " + port );
         logger.info( "|------------------------------------------------------------------|" );
+        logger.info( "redirectUrl -- > " + request.getParameter("redirectUrl") );
         
         logger.info( "  sesMobileId : "  + sesMId + "  sesWebId : " + session + "  groupIdx : " + groupIdx );
         
@@ -55,7 +56,11 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
         if( url.contains( "/mobile" ) ) {
             if( !url.equals( "/mobile/login" ) && !url.equals( "/mobile/check" ) ) {
                 if( sesMId == null ) {
-                    response.sendRedirect( "/mobile/login" );
+                    if (request.getParameter("redirectUrl") == null) {
+                        response.sendRedirect( "/mobile/login" );
+                    } else {
+                        response.sendRedirect( "/mobile/login?redirectUrl=" + request.getParameter("redirectUrl") );
+                    }
                     return false;
                 } else {
                     logger.info( "IP : " + LifeCenterFunction.getRemoteAddr( request ) + " ID : " + sesMId.toString() + "  URL : " + url + " Port : " + port );

+ 7 - 2
src/main/java/com/lemon/lifecenter/controller/MobileLoginController.java

@@ -13,6 +13,7 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
@@ -51,13 +52,14 @@ public class MobileLoginController extends LifeCenterController {
     private AcceptService acceptService;
     
     @RequestMapping("/login")
-    public ModelAndView login() {
+    public ModelAndView login(@RequestParam(value="redirectUrl", required=false, defaultValue="") String redirectUrl) {
         List<LocationDTO> locationList = centerService.selectLocation();
         List<CenterInfoDTO> centerList = memberService.selectCenterList();
         
         ModelAndView mv = setMobileMV("login/login");
         mv.addObject("locationList", locationList);
         mv.addObject("centerList", centerList);
+        mv.addObject("redirectUrl", redirectUrl);
         return mv;
     }
     
@@ -65,6 +67,7 @@ public class MobileLoginController extends LifeCenterController {
     @ResponseBody
     public String loginCheck(
             @ModelAttribute("dto") PatientDTO dto,
+            @RequestParam(value="redirectUrl", required=false, defaultValue="") String redirectUrl,
             HttpServletRequest request, HttpServletResponse response) throws Exception {
         
         String resultCode = "99";
@@ -109,6 +112,7 @@ public class MobileLoginController extends LifeCenterController {
             object.put("id", dto.getId());
             object.put("pw", dto.getPw());
             object.put("cc" , String.valueOf(dto.getCenterCode()) );
+            object.put("redirectUrl", redirectUrl);
             
             resultCode = "00";
         }
@@ -122,6 +126,7 @@ public class MobileLoginController extends LifeCenterController {
     public String patientLogout( HttpServletRequest request, HttpServletResponse response ) {
         String remoteIp  = LifeCenterFunction.getRemoteAddr( request );
         String sesMId     = LifeCenterSessionController.getSession( request, "sesMId" );
+        String sesMIdx    = LifeCenterSessionController.getSession( request, "sesMpIdx" );
         
         LifeCenterSessionController.sessionInvalidate( request );
         
@@ -129,7 +134,7 @@ public class MobileLoginController extends LifeCenterController {
         json.put("patientIdx", 1);
         
         logger.error( "[PATIENT LOGOUT] RemoteIP : " + remoteIp + " UserId : " + sesMId );
-//        deviceService.deleteDeviceInfo(Integer.parseInt(sesMId));
+        deviceService.deleteDeviceInfo(Integer.parseInt(sesMIdx));
         
         LifeCenterFunction.scriptMessage(response, "localStorage.clear();location.href='/mobile/login';");
         return "/common/blank";

+ 6 - 3
src/main/java/com/lemon/lifecenter/controller/RestApiController.java

@@ -11,6 +11,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.json.simple.JSONValue;
@@ -79,11 +81,12 @@ public class RestApiController {
      * @return json String
      */
     @RequestMapping(value="/toAction", method = RequestMethod.POST)
-    public String moveToAction(@RequestBody HlRequestDTO dto) {
+    public String moveToAction(@RequestBody HlRequestDTO dto, HttpServletRequest request) {
         
-        String result = "";
+        String ip      = LifeCenterFunction.getRemoteAddr(request);
+        String result  = "";
         String message = "";
-        String token = dto.getToken();
+        String token   = dto.getToken();
         LinkedHashMap<String, Object> object = new LinkedHashMap<>();
         if (!token.equals("")) {
             String apiKey = service.selectApiKey(dto);

+ 9 - 1
src/main/webapp/WEB-INF/jsp/mobile/login/login.jsp

@@ -44,14 +44,21 @@ $( function(){
                 console.log("data -- > " + JSON.stringify(data));
                 var resultCode = data.code;
                 var resultMsg  = data.message;
+                var redirectUrl = data.redirectUrl;
                 
                 if( data.code == "00" ) {
                     localStorage.clear();
                     localStorage.id = data.id;
                     localStorage.pw = $( "#pw" ).val();
                     localStorage.cc = data.cc;
+
+                    if (redirectUrl != "") {
+                        location.href = '/mobile/menu?redirectUrl=' + redirectUrl;
+                    } else {
+                        location.href = '/mobile/menu';
+                    }
+                    
                     
-                    location.href = '/mobile/menu';
                 } else {
                     $("#errMsg").text( resultMsg ).stop().animate({
                         marginLeft: "5px"
@@ -115,6 +122,7 @@ function autoLogin(){
         <div class="container">
             <div class="title">생활치료센터</br>비대면진료 서비스</div>
             <form id="loginForm" action="./check" method="post">
+                <input type="hidden" name="redirectUrl" value="${redirectUrl}">
                 <div class="login_box">
                     <div class="visual">
                         <img src="/resources/images/mobile/login_visual.png" />

+ 51 - 51
src/main/webapp/WEB-INF/jsp/mobile/menu/menu.jsp

@@ -5,56 +5,56 @@
 <jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
 <script type="text/javascript">
 
-// $( function(){
-//     token( "getToken" );
-//     var redirectUrl = "<c:out value='${redirectUrl}' />" ;
-//     if (redirectUrl != "") {
-//         location.href = "./" + redirectUrl;
-//     }
-// });
+$( function(){
+    token( "getToken" );
+    var redirectUrl = "<c:out value='${redirectUrl}' />" ;
+    if (redirectUrl != "") {
+        location.href = "./" + redirectUrl;
+    }
+});
 
-// function getToken(token, deviceType, macAddress) {
-//     var jsonMsg = {
-//         patientIdx : "<c:out value='${patientIdx}' />",
-//         deviceType : deviceType,
-//         deviceToken : token,
-//         macAddress : macAddress
-//     };
+function getToken(token, deviceType, macAddress) {
+    var jsonMsg = {
+        patientIdx : "<c:out value='${patientIdx}' />",
+        deviceType : deviceType,
+        deviceToken : token,
+        macAddress : macAddress
+    };
     
-//     $.ajax({
-//         url      : "/mobile/insertDeviceInfo",
-//         data     : JSON.stringify(jsonMsg),
-//         method   : "POST",
-//         contentType: 'application/json',
-//         success  : function( data ){
-//             console.log(JSON.stringify(data));
-//           if( typeof success == "function" ){
-//             //success( data );
-//           };
-//         },
-//         error : function(jqXHR, exception){
-//           if( typeof error == "function" ) {
-//             //error(jqXHR, exception);
-//           };
-//         }
-//     }).done( function(){
-//         if( typeof done == "function" ){
-//           //done();
-//         };
-//     });
-// }
+    $.ajax({
+        url      : "/mobile/insertDeviceInfo",
+        data     : JSON.stringify(jsonMsg),
+        method   : "POST",
+        contentType: 'application/json',
+        success  : function( data ){
+            console.log(JSON.stringify(data));
+          if( typeof success == "function" ){
+            //success( data );
+          };
+        },
+        error : function(jqXHR, exception){
+          if( typeof error == "function" ) {
+            //error(jqXHR, exception);
+          };
+        }
+    }).done( function(){
+        if( typeof done == "function" ){
+          //done();
+        };
+    });
+}
 
-// function token(callback) {
-//     console.log(callback);
-//     var jsonMsg = {
-//         "type":"command",
-//         "functionType":"token",
-//         "value" : {
-//             "callbackFn" : callback
-//         }
-//     }
-//     toNative(jsonMsg);
-// }
+function token(callback) {
+    console.log(callback);
+    var jsonMsg = {
+        "type":"command",
+        "functionType":"token",
+        "value" : {
+            "callbackFn" : callback
+        }
+    }
+    toNative(jsonMsg);
+}
 </script>
 </head>
 <body>
@@ -99,9 +99,9 @@
                             <li>
                                 <a href="./nonface">비대면 진료(Untact Treatment)</a>
                             </li>
-<!--                             <li> -->
-<!--                                 <a href="./push/list">메시지 수신함(Message received)</a> -->
-<!--                             </li> -->
+                            <li>
+                                <a href="./push/list">메시지 수신함(Message received)</a>
+                            </li>
                             <!-- li>
                                 <a href="javascript:;">생활치료센터 이용 안내</a>
                             </li -->
@@ -186,7 +186,7 @@
                         </a>
                     </li>
                     <li>
-                        <a href="./nonface">
+                        <a href="./nonface" id="nonfaceBtn">
                             <div class="image">
 <!--                                 <div class="new_icon">NEW</div> -->
                                 <img src="/resources/images/mobile/quick_4.png" />

+ 1 - 1
src/main/webapp/WEB-INF/jsp/mobile/nonface/nonface.jsp

@@ -14,7 +14,7 @@ $( function() {
     frm.submit(); */
     
     setTimeout( function(){
-        history.back();
+        location.href = "/mobile/menu";
     }, 1000 );
 });
 </script>