|
@@ -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;
|
|
|
+ }
|
|
|
+}
|