websocketSerivce/src/main/java/org/example/controller/ApiController.java
@@ -14,6 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.List; /** @@ -71,4 +75,28 @@ return HttpClientRequest.doGet(EStockType.IN.getStockUrl()) + "/new-stock?key=" + (EStockType.IN.getStockKey() + "&country_id=14"); } @RequestMapping("/stock") @ResponseBody public String doGet(@RequestParam("pid") String pid){ String apiUrl = "http://api-in-2.js-stock.top/stock?pid="+pid+"&key=eVKtHt7aG4m6ozwWL9qG"; try { URL url = new URL(apiUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return response.toString(); } catch (Exception e) { e.printStackTrace(); } return null; } } websocketSerivce/src/main/java/org/example/server/impl/ISiteNewsServiceImpl.java
@@ -67,10 +67,7 @@ conv(jsonObject,journalism); Journalism selectById = journalismMapper.selectById(journalism.getId()); if(jsonObject.has("img")){ String s = convertBase64ToImage(jsonObject.getString("img"), PropertiesUtil.getProperty("ftp.address") + newsId + ".jpg"); File file = new File(s); FTPUtil ftpUtil = new FTPUtil(PropertiesUtil.getProperty("ftp.server.ip"), 21, PropertiesUtil.getProperty("ftp.user"),PropertiesUtil.getProperty("ftp.pass") ); ftpUtil.uploadFile(PropertiesUtil.getProperty("ftp.address"), file); convertBase64ToImage(jsonObject.getString("img"), PropertiesUtil.getProperty("ftp.address") + newsId + ".jpg"); journalism.setImg(PropertiesUtil.getProperty("ftp.server.http.prefix")+newsId+".jpg"); } if(null == selectById){ websocketSerivce/src/main/resources/application.properties
@@ -9,7 +9,7 @@ ftp.user=ftp_stock ftp.pass=123456 ftp.address =/www/wwwroot/ftp_stock/ ftp.server.http.prefix=https://img.112100.net/ ftp.server.http.prefix=https://img.is4vc.com/ #ftp.server.ip=47.56.200.145 #ftp.user=ofsuccess #ftp.pass=fdymdM34HHsS8iB6