diff --git a/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java b/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java index 984eee3..2ddbd87 100644 --- a/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java +++ b/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java @@ -21,8 +21,8 @@ @Component @Path("/voicememos") public class VoicememosRest implements ApplicationContextAware { - Voicememos voicememos = Voicememos.getInstance(); - Accounts accounts = Accounts.getInstance(); + private Voicememos voicememos = Voicememos.getInstance(); + private Accounts accounts = Accounts.getInstance(); private ApplicationContext applicationContext; @Override @@ -41,10 +41,10 @@ { voicememos.createVoicememo("vid", "test", 1, "url", 3, 3, "a", "a"); - voicememos.createVoicememo("vid1", "test", 1, "url", 34.4346,135.1647, "a", "a"); - voicememos.createVoicememo("vid2", "test", 1, "url", 34.4347,135.1645, "a", "a"); - voicememos.createVoicememo("vid3", "test", 1, "url", 34.4348,135.1646, "b", "a"); - voicememos.createVoicememo("vid4", "test", 1, "url", 34.4345,135.1648, "c", "a"); + voicememos.createVoicememo("vid1", "test", 1, "url", 34.4346, 135.1647, "a", "a"); + voicememos.createVoicememo("vid2", "test", 1, "url", 34.4347, 135.1645, "a", "a"); + voicememos.createVoicememo("vid3", "test", 1, "url", 34.4348, 135.1646, "b", "a"); + voicememos.createVoicememo("vid4", "test", 1, "url", 34.4345, 135.1648, "c", "a"); } @GET @@ -58,10 +58,25 @@ voicememos.getVoicememos()) { double latitude = v.getLatitude(); double longitude = v.getLongitude(); - if (latmax > latitude && latitude > latmin && longmax > longitude && longitude > longmin) { - vidlist.add(v); + if (longmax > longmin) { + if (latmax > latitude && latitude > latmin && longmax > longitude && longitude > longmin) { + vidlist.add(v); + } + } else { + if (longitude > 0) { + if (latmax > latitude && latitude > latmin && longitude > longmin) { + vidlist.add(v); + } + } + if (longitude < 0) { + if (latmax > latitude && latitude > latmin && longmax > longitude) { + vidlist.add(v); + } + } } } + + return vidlist; } @@ -80,7 +95,7 @@ String vid = createVid(); String path = ""; try { - path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps";; + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps"; path = Base64Decode.saveAsFile(vid, path, data); } catch (IOException e) { e.printStackTrace(); @@ -110,7 +125,7 @@ } String server_token = account.getToken(); if (client_token.equals(server_token)) { - Voicememo voicememo = voicememos.getVoicememo(vid); + final Voicememo voicememo = voicememos.getVoicememo(vid); return voicememo; }