huiwon.seo 5 years ago
parent
commit
c57b483cb1
1 changed files with 58 additions and 0 deletions
  1. 58 0
      src/main/java/com/lemon/lifecenter/controller/PatientController.java

+ 58 - 0
src/main/java/com/lemon/lifecenter/controller/PatientController.java

@@ -1,18 +1,22 @@
 package com.lemon.lifecenter.controller;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 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;
 
 import com.lemon.lifecenter.common.LifeCenterConfigVO;
@@ -232,4 +236,58 @@ public class PatientController extends LifeCenterController {
 
         return mv;
     }
+    
+    @RequestMapping( value="/nonFaceStart", method = RequestMethod.POST )
+    @ResponseBody
+    public String nonFaceStart(
+            @RequestParam( value="pId", required = true ) String pId,
+            @RequestParam( value="roomId", required = true ) String roomId,
+            @RequestParam( value="pName", required = true ) String pName,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        
+        String salt = LifeCenterFunction.getSalt();
+        String timeStamp = LifeCenterFunction.getTimestamp();
+        String signature = LifeCenterFunction.getSignature(config.nonFaceApiSecret, salt, timeStamp);
+        
+        String userId = LifeCenterSessionController.getSession(request, "sesId");
+        String userNm = LifeCenterSessionController.getSession(request, "sesName");
+        
+        HashMap<String, String> data = new HashMap<String, String>();
+        data.put("api_key", config.nonFaceApiKey);
+        data.put("salt", salt);
+        data.put("timestamp", timeStamp);
+        data.put("signature", signature);
+        data.put("client_id", config.nonFaceClientId);
+        data.put("member_id", userId);
+        
+        String result = LifeCenterFunction.httpUrlConnection(config.nonFaceApiTokenUrl, data);
+        
+        JSONObject object = new JSONObject(result);
+        String message = "";
+        String token = "";
+        for(String key : object.keySet()) {
+            logger.error("key -- > " + key);
+            if (key.equals("errorCode")) {
+                message = object.getString("message");
+            } else if (key.equals("token")){
+                token = object.getString("token");
+            }
+        }
+        
+        if (!message.equals("")) {
+            //error
+        }
+        String hashData = LifeCenterFunction.getSignature(config.nonFaceApiSecret, config.nonFaceApiKey, roomId + userId); //"1011503101"
+        
+        object.put("api_key", config.nonFaceApiKey);
+        object.put("member_id", userId);
+        object.put("token", token);
+        object.put("room_id", roomId);
+        object.put("member_name", userNm);
+        object.put("classify", "d"); // p이면 환자 d이면 의사
+        object.put("hashData", hashData);
+        logger.error("pid -- > " + hashData);
+        
+        return object.toString();
+    }
 }