|
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.lemon.lifecenter.dto.AppVersionDTO;
|
|
|
+import com.lemon.lifecenter.dto.DeviceInfoDTO;
|
|
|
import com.lemon.lifecenter.service.RestApiService;
|
|
|
|
|
|
@RestController
|
|
@@ -46,4 +47,90 @@ public class RestApiController {
|
|
|
data.put("code", code);
|
|
|
return data;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 디바이스 정보 저장
|
|
|
+ * @param dto
|
|
|
+ * patientIdx : 환자등록 고유번호
|
|
|
+ * deviceType : 안드로이드 : AND, 아이폰 : IOS
|
|
|
+ * deviceToken : 푸시 수신을 위한 토큰
|
|
|
+ * macAddress : 디바이스 맥 어드레스
|
|
|
+ * return code
|
|
|
+ * 00 : 성공
|
|
|
+ * 01 : 파라메터를 모두 받지 못함
|
|
|
+ * 02 : 디바이스 토큰 저장 실패
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/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");
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.error("patientIdx -- > " + dto.getPatientIdx());
|
|
|
+ logger.error("deviceType -- > " + dto.getDeviceType());
|
|
|
+ logger.error("deviceToken -- > " + dto.getDeviceToken());
|
|
|
+ logger.error("macAddress -- > " + dto.getMacAddress());
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|