junekeunsong 4 éve
szülő
commit
9ef582d207

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

@@ -37,7 +37,8 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
         logger.info( "  sesMobileId : "  + sesMId + "  sesWebId : " + session + "  groupIdx : " + groupIdx );
         
         if ( url.contains( "/error" ) || url.contains( "/nonface/wait" ) || 
-             url.contains( "/store" ) || url.contains( "/favicon.ico" )  || url.contains( "/mobile/getAppVersion" ) ) {
+             url.contains( "/store" ) || url.contains( "/favicon.ico" )  || url.contains( "/mobile/getAppVersion" ) ||
+             url.contains("/lifeCenter/api") ) {
             return true;
         }
         

+ 128 - 0
src/main/java/com/lemon/lifecenter/controller/DeviceController.java

@@ -0,0 +1,128 @@
+package com.lemon.lifecenter.controller;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.lemon.lifecenter.dto.AppVersionDTO;
+import com.lemon.lifecenter.dto.DeviceInfoDTO;
+import com.lemon.lifecenter.service.DeviceService;
+
+@RestController
+public class DeviceController {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    
+    @Autowired
+    private DeviceService deviceService;
+    
+    @RequestMapping(value="/mobile/getAppVersion", method = RequestMethod.POST)
+    public HashMap<String, String> appVersion(@RequestBody AppVersionDTO dto) {
+        HashMap<String, String> data = new HashMap<String, String>();
+        
+        String code = "99";
+        String deviceType = dto.getDeviceType();
+        if (deviceType.equals("")) {
+            code = "01";
+        } else {
+            dto = deviceService.selectAppVersion(deviceType);
+            if (dto == null) {
+                code = "02";
+            } else {
+                code = "00";
+                data.put("version", dto.getVersion());
+                data.put("downloadUrl", dto.getDownloadUrl());
+            }
+            
+        }
+        data.put("code", code);
+        return data;
+    }
+    
+    /**
+     * 디바이스 정보 저장
+     * @param dto
+     * patientIdx : 환자등록 고유번호
+     * deviceType : 안드로이드 : AND, 아이폰 : IOS
+     * deviceToken : 푸시 수신을 위한 토큰
+     * macAddress : 디바이스 맥 어드레스
+     * return code
+     * 00 : 성공
+     * 01 : 파라메터를 모두 받지 못함
+     * 02 : 디바이스 토큰 저장 실패
+     */
+    @RequestMapping(value="/mobile/insertDeviceInfo", method=RequestMethod.POST)
+    public Map<String, String> setDeviceInfo(@RequestBody DeviceInfoDTO dto) {
+        HashMap<String, String> result = new HashMap<>();
+        String code = "99";
+        
+        int patientIdx = dto.getPatientIdx();
+        String deviceType = dto.getDeviceType();
+        String deviceToken = dto.getDeviceToken();
+        String macAddress = dto.getMacAddress();
+        
+        if (patientIdx == 0 || deviceType.equals("") || deviceToken.equals("") || macAddress.equals("")) {
+            code = "01";
+            result.put("code", code);
+            result.put("message", "Lack of parameters");
+            return result;
+        }
+        
+        int cnt = deviceService.selectDeviceInfoCount(dto);
+        int rCnt = 0;
+        if (cnt == 0) {
+            deviceService.insertDeviceInfo(dto);
+            rCnt = dto.getQueryCount();
+        } else {
+            rCnt = deviceService.updatedeviceInfo(dto);
+        }
+        
+        if (rCnt == 0) {
+            code = "02";
+            result.put("code", code);
+            result.put("message", "Token storage failure");
+        } else {
+            code = "00";
+            result.put("code", code);
+            result.put("message", "success");
+        }
+        
+        return result;
+    }
+    
+    /**
+     * 디바이스 정보 제거
+     * @param dto
+     * patientIdx : 환자등록 고유번호
+     * @return
+     * code
+     * 00 : 성공
+     * 01 : 파라메터가 없음
+     */
+    @RequestMapping(value="/deleteDeviceInfo", method=RequestMethod.POST, produces = "application/json; charset=utf-8")
+    public Map<String, String> deleteDeviceInfo(@RequestBody DeviceInfoDTO dto) {
+        int patientIdx = dto.getPatientIdx();
+        HashMap<String, String> result = new HashMap<String, String>();
+        String code = "99";
+        String message = "";
+        if (patientIdx == 0) {
+            code = "01";
+            message = "Lack of parameters";
+        } else {
+            int cnt = deviceService.deleteDeviceInfo(patientIdx);
+            code = "00";
+            message = "success";
+        }
+        
+        result.put("code", code);
+        result.put("message", message);
+        
+        return result;
+    }
+}

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

@@ -114,7 +114,7 @@ public class MobileLoginController extends LifeCenterController {
         json.put("patientIdx", 1);
         
         logger.error( "[PATIENT LOGOUT] RemoteIP : " + remoteIp + " UserId : " + sesMId );
-//        restApiService.deleteDeviceInfo(Integer.parseInt(sesMId));
+        restApiService.deleteDeviceInfo(Integer.parseInt(sesMId));
         
         LifeCenterFunction.scriptMessage(response, "localStorage.clear();location.href='/mobile/login';");
         return "/common/blank";

+ 1 - 106
src/main/java/com/lemon/lifecenter/controller/RestApiController.java

@@ -19,114 +19,9 @@ import com.lemon.lifecenter.dto.DeviceInfoDTO;
 import com.lemon.lifecenter.service.RestApiService;
 
 @RestController
+@RequestMapping("/lifeCenter/api")
 public class RestApiController {
     
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     
-    @Autowired
-    private RestApiService restApiService;
-    
-    @RequestMapping(value="/mobile/getAppVersion", method = RequestMethod.POST)
-    public HashMap<String, String> appVersion(@RequestBody AppVersionDTO dto) {
-        HashMap<String, String> data = new HashMap<String, String>();
-        
-        String code = "99";
-        String deviceType = dto.getDeviceType();
-        if (deviceType.equals("")) {
-            code = "01";
-        } else {
-            dto = restApiService.selectAppVersion(deviceType);
-            if (dto == null) {
-                code = "02";
-            } else {
-                code = "00";
-                data.put("version", dto.getVersion());
-                data.put("downloadUrl", dto.getDownloadUrl());
-            }
-            
-        }
-        data.put("code", code);
-        return data;
-    }
-    
-    /**
-     * 디바이스 정보 저장
-     * @param dto
-     * patientIdx : 환자등록 고유번호
-     * deviceType : 안드로이드 : AND, 아이폰 : IOS
-     * deviceToken : 푸시 수신을 위한 토큰
-     * macAddress : 디바이스 맥 어드레스
-     * return code
-     * 00 : 성공
-     * 01 : 파라메터를 모두 받지 못함
-     * 02 : 디바이스 토큰 저장 실패
-     */
-    @RequestMapping(value="/mobile/insertDeviceInfo", method=RequestMethod.POST)
-    public Map<String, String> setDeviceInfo(@RequestBody DeviceInfoDTO dto) {
-        HashMap<String, String> result = new HashMap<>();
-        String code = "99";
-        
-        int patientIdx = dto.getPatientIdx();
-        String deviceType = dto.getDeviceType();
-        String deviceToken = dto.getDeviceToken();
-        String macAddress = dto.getMacAddress();
-        
-        if (patientIdx == 0 || deviceType.equals("") || deviceToken.equals("") || macAddress.equals("")) {
-            code = "01";
-            result.put("code", code);
-            result.put("message", "Lack of parameters");
-            return result;
-        }
-        
-        int cnt = restApiService.selectDeviceInfoCount(dto);
-        int rCnt = 0;
-        if (cnt == 0) {
-            restApiService.insertDeviceInfo(dto);
-            rCnt = dto.getQueryCount();
-        } else {
-            rCnt = restApiService.updatedeviceInfo(dto);
-        }
-        
-        if (rCnt == 0) {
-            code = "02";
-            result.put("code", code);
-            result.put("message", "Token storage failure");
-        } else {
-            code = "00";
-            result.put("code", code);
-            result.put("message", "success");
-        }
-        
-        return result;
-    }
-    
-    /**
-     * 디바이스 정보 제거
-     * @param dto
-     * patientIdx : 환자등록 고유번호
-     * @return
-     * code
-     * 00 : 성공
-     * 01 : 파라메터가 없음
-     */
-    @RequestMapping(value="/deleteDeviceInfo", method=RequestMethod.POST, produces = "application/json; charset=utf-8")
-    public Map<String, String> deleteDeviceInfo(@RequestBody DeviceInfoDTO dto) {
-        int patientIdx = dto.getPatientIdx();
-        HashMap<String, String> result = new HashMap<String, String>();
-        String code = "99";
-        String message = "";
-        if (patientIdx == 0) {
-            code = "01";
-            message = "Lack of parameters";
-        } else {
-            int cnt = restApiService.deleteDeviceInfo(patientIdx);
-            code = "00";
-            message = "success";
-        }
-        
-        result.put("code", code);
-        result.put("message", message);
-        
-        return result;
-    }
 }

+ 17 - 0
src/main/java/com/lemon/lifecenter/mapper/DeviceMapper.java

@@ -0,0 +1,17 @@
+package com.lemon.lifecenter.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import com.lemon.lifecenter.dto.AppVersionDTO;
+import com.lemon.lifecenter.dto.DeviceInfoDTO;
+
+@Repository
+@Mapper
+public interface DeviceMapper {
+    public AppVersionDTO selectAppVersion(String deviceType);
+    public int selectDeviceInfoCount(DeviceInfoDTO dto);
+    public void insertDeviceInfo(DeviceInfoDTO dto);
+    public int updatedeviceInfo(DeviceInfoDTO dto);
+    public int deleteDeviceInfo(int patientIdx);
+}

+ 0 - 5
src/main/java/com/lemon/lifecenter/mapper/RestApiMapper.java

@@ -9,9 +9,4 @@ import com.lemon.lifecenter.dto.DeviceInfoDTO;
 @Repository
 @Mapper
 public interface RestApiMapper {
-    public AppVersionDTO selectAppVersion(String deviceType);
-    public int selectDeviceInfoCount(DeviceInfoDTO dto);
-    public void insertDeviceInfo(DeviceInfoDTO dto);
-    public int updatedeviceInfo(DeviceInfoDTO dto);
-    public int deleteDeviceInfo(int patientIdx);
 }

+ 34 - 0
src/main/java/com/lemon/lifecenter/service/DeviceService.java

@@ -0,0 +1,34 @@
+package com.lemon.lifecenter.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.lemon.lifecenter.dto.AppVersionDTO;
+import com.lemon.lifecenter.dto.DeviceInfoDTO;
+import com.lemon.lifecenter.mapper.DeviceMapper;
+
+@Service
+public class DeviceService {
+    @Autowired
+    private DeviceMapper mapper;
+    
+    public AppVersionDTO selectAppVersion(String deviceType) {
+        return mapper.selectAppVersion(deviceType);
+    }
+    
+    public int selectDeviceInfoCount(DeviceInfoDTO dto) {
+        return mapper.selectDeviceInfoCount(dto);
+    }
+    
+    public void insertDeviceInfo(DeviceInfoDTO dto) {
+        mapper.insertDeviceInfo(dto);
+    }
+    
+    public int updatedeviceInfo(DeviceInfoDTO dto) {
+        return mapper.updatedeviceInfo(dto);
+    }
+    
+    public int deleteDeviceInfo(int patientIdx) {
+        return mapper.deleteDeviceInfo(patientIdx);
+    }
+}

+ 0 - 19
src/main/java/com/lemon/lifecenter/service/RestApiService.java

@@ -12,23 +12,4 @@ public class RestApiService {
     @Autowired
     private RestApiMapper mapper;
     
-    public AppVersionDTO selectAppVersion(String deviceType) {
-        return mapper.selectAppVersion(deviceType);
-    }
-    
-    public int selectDeviceInfoCount(DeviceInfoDTO dto) {
-        return mapper.selectDeviceInfoCount(dto);
-    }
-    
-    public void insertDeviceInfo(DeviceInfoDTO dto) {
-        mapper.insertDeviceInfo(dto);
-    }
-    
-    public int updatedeviceInfo(DeviceInfoDTO dto) {
-        return mapper.updatedeviceInfo(dto);
-    }
-    
-    public int deleteDeviceInfo(int patientIdx) {
-        return mapper.deleteDeviceInfo(patientIdx);
-    }
 }

+ 0 - 48
src/main/resources/mybatis/mapper/api/api.xml

@@ -2,52 +2,4 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="com.lemon.lifecenter.mapper.RestApiMapper">
-    <select id="selectAppVersion" parameterType="String" resultType="appVersionDTO">
-        <![CDATA[
-            SELECT VERSION AS version,
-                   DOWNLOAD_URL AS downloadUrl
-              FROM APP_VERSION
-             WHERE DEVICE_TYPE = #{deviceType}
-        ]]>
-    </select>
-        <select id="selectDeviceInfoCount" parameterType="DeviceInfoDTO" resultType="int">
-        <![CDATA[
-            SELECT COUNT(*) AS CNT
-              FROM PUSH_DEVICE_INFO
-             WHERE 1 = 1
-               AND PATIENT_IDX = #{patientIdx}
-        ]]>
-    </select>
-    
-    <insert id="insertDeviceInfo" parameterType="DeviceInfoDTO">
-        <selectKey keyProperty="queryCount" resultType="int" order="AFTER">
-            <![CDATA[
-                SELECT COUNT(*) queryCount FROM PUSH_DEVICE_INFO WHERE PATIENT_IDX = #{patientIdx}
-            ]]>
-        </selectKey>
-        <![CDATA[
-            INSERT INTO PUSH_DEVICE_INFO
-                        (PATIENT_IDX,   DEVICE_TYPE,   DEVICE_KEY,     MAC_ADDRESS,   CREATE_DATE)
-                 VALUES (#{patientIdx}, #{deviceType}, #{deviceToken}, #{macAddress}, NOW())
-        ]]>
-    </insert>
-    <update id="updatedeviceInfo" parameterType="DeviceInfoDTO">
-        <![CDATA[
-            UPDATE PUSH_DEVICE_INFO
-               SET UPDATE_DATE  = NOW(),
-                   DEVICE_TYPE  = #{deviceType},
-                   DEVICE_KEY   = #{deviceToken},
-                   MAC_ADDRESS  = #{macAddress}
-             WHERE PATIENT_IDX  = #{patientIdx}
-        ]]>
-    </update>
-    
-    <delete id="deleteDeviceInfo" parameterType="int">
-        <![CDATA[
-            UPDATE PUSH_DEVICE_INFO
-               SET UPDATE_DATE = NOW(),
-                   DEVICE_KEY = ''
-             WHERE PATIENT_IDX = #{patientIdx}
-        ]]>
-    </delete>
 </mapper>

+ 53 - 0
src/main/resources/mybatis/mapper/device/device.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.lemon.lifecenter.mapper.DeviceMapper">
+    <select id="selectAppVersion" parameterType="String" resultType="appVersionDTO">
+        <![CDATA[
+            SELECT VERSION AS version,
+                   DOWNLOAD_URL AS downloadUrl
+              FROM APP_VERSION
+             WHERE DEVICE_TYPE = #{deviceType}
+        ]]>
+    </select>
+        <select id="selectDeviceInfoCount" parameterType="DeviceInfoDTO" resultType="int">
+        <![CDATA[
+            SELECT COUNT(*) AS CNT
+              FROM PUSH_DEVICE_INFO
+             WHERE 1 = 1
+               AND PATIENT_IDX = #{patientIdx}
+        ]]>
+    </select>
+    
+    <insert id="insertDeviceInfo" parameterType="DeviceInfoDTO">
+        <selectKey keyProperty="queryCount" resultType="int" order="AFTER">
+            <![CDATA[
+                SELECT COUNT(*) queryCount FROM PUSH_DEVICE_INFO WHERE PATIENT_IDX = #{patientIdx}
+            ]]>
+        </selectKey>
+        <![CDATA[
+            INSERT INTO PUSH_DEVICE_INFO
+                        (PATIENT_IDX,   DEVICE_TYPE,   DEVICE_KEY,     MAC_ADDRESS,   CREATE_DATE)
+                 VALUES (#{patientIdx}, #{deviceType}, #{deviceToken}, #{macAddress}, NOW())
+        ]]>
+    </insert>
+    <update id="updatedeviceInfo" parameterType="DeviceInfoDTO">
+        <![CDATA[
+            UPDATE PUSH_DEVICE_INFO
+               SET UPDATE_DATE  = NOW(),
+                   DEVICE_TYPE  = #{deviceType},
+                   DEVICE_KEY   = #{deviceToken},
+                   MAC_ADDRESS  = #{macAddress}
+             WHERE PATIENT_IDX  = #{patientIdx}
+        ]]>
+    </update>
+    
+    <delete id="deleteDeviceInfo" parameterType="int">
+        <![CDATA[
+            UPDATE PUSH_DEVICE_INFO
+               SET UPDATE_DATE = NOW(),
+                   DEVICE_KEY = ''
+             WHERE PATIENT_IDX = #{patientIdx}
+        ]]>
+    </delete>
+</mapper>

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

@@ -5,52 +5,52 @@
 <jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
 <script type="text/javascript">
 
-// $( function(){
-//     token( "getToken" );
-// });
+$( function(){
+    token( "getToken" );
+});
 
-// 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>