diff --git a/20240922/weather/src/main/java/com/rehome/weather/controller/WeatherController.java b/20240922/weather/src/main/java/com/rehome/weather/controller/WeatherController.java index 683bd36..a6ca01e 100644 --- a/20240922/weather/src/main/java/com/rehome/weather/controller/WeatherController.java +++ b/20240922/weather/src/main/java/com/rehome/weather/controller/WeatherController.java @@ -74,4 +74,17 @@ public class WeatherController { public Map getLocalWeatherByCity(@RequestParam("city") String city){ return weatherService.getLocalWeatherByCity(city); } + /** + * @date 2021-04-29 11:45 + * @description: 根据城市查询天气数据,查本地数据库 + * @Param: null + */ + @CrossOrigin + @RequestMapping(value = "/getLocalWeather",method = RequestMethod.GET) + public Map getLocalWeather(){ + //惠阳 or 2220 + //惠州 or 2218 + String city = "惠阳"; + return weatherService.getLocalWeatherByCity(city); + } } diff --git a/20240922/weather/src/main/java/com/rehome/weather/dao/WeatherFutureRepository.java b/20240922/weather/src/main/java/com/rehome/weather/dao/WeatherFutureRepository.java index bed1f51..a523206 100644 --- a/20240922/weather/src/main/java/com/rehome/weather/dao/WeatherFutureRepository.java +++ b/20240922/weather/src/main/java/com/rehome/weather/dao/WeatherFutureRepository.java @@ -11,7 +11,7 @@ public interface WeatherFutureRepository extends JpaRepository findByDate(String date); - @Query(value = "select * from weather_future wf where wf.city = ?1 ORDER BY id DESC LIMIT 0,1", nativeQuery = true) + @Query(value = "select * from weather_future wf where wf.city = ?1 ORDER BY id DESC LIMIT 0,5", nativeQuery = true) Optional> findAllByCity(String city); } diff --git a/20240922/weather/src/main/resources/application.yml b/20240922/weather/src/main/resources/application.yml index 7e84fa3..3bdd688 100644 --- a/20240922/weather/src/main/resources/application.yml +++ b/20240922/weather/src/main/resources/application.yml @@ -1,13 +1,13 @@ server: - port: 28902 + port: 8080 spring: datasource: type: com.zaxxer.hikari.HikariDataSource #driverClassName: com.mysql.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver #url: jdbc:mysql://192.168.1.21:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false - #url: jdbc:mysql://127.0.0.1:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false - url: jdbc:mysql://192.168.1.24:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false + url: jdbc:mysql://127.0.0.1:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false + #url: jdbc:mysql://192.168.1.24:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false username: root password: Skyinno251, jpa: