天气服务调整

master
wenfei 6 months ago
parent 92b64d460a
commit 924942f065

@ -74,4 +74,17 @@ public class WeatherController {
public Map getLocalWeatherByCity(@RequestParam("city") String city){ public Map getLocalWeatherByCity(@RequestParam("city") String city){
return weatherService.getLocalWeatherByCity(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);
}
} }

@ -11,7 +11,7 @@ public interface WeatherFutureRepository extends JpaRepository<WeatherFuture, In
//方法名称必须要遵循驼峰式命名规则findBy关键字+属性名称(首字母大写)+查询条件(首字母大写) //方法名称必须要遵循驼峰式命名规则findBy关键字+属性名称(首字母大写)+查询条件(首字母大写)
Optional<WeatherFuture> findByDate(String date); Optional<WeatherFuture> 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<List<WeatherFuture>> findAllByCity(String city); Optional<List<WeatherFuture>> findAllByCity(String city);
} }

@ -1,13 +1,13 @@
server: server:
port: 28902 port: 8080
spring: spring:
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
#driverClassName: com.mysql.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver #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 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://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://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://192.168.1.24:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root username: root
password: Skyinno251, password: Skyinno251,
jpa: jpa:

Loading…
Cancel
Save