初始化
parent
93b176c279
commit
46cf10ff9a
|
@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -24,11 +25,12 @@ import java.util.stream.Collectors;
|
||||||
@RequestMapping("/third")
|
@RequestMapping("/third")
|
||||||
public class ThirdPartyController {
|
public class ThirdPartyController {
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
@RequestMapping("/getAirQuality")
|
@RequestMapping("/getAirQuality")
|
||||||
public void getAirQuality(@RequestParam String cityId, HttpServletResponse response) {
|
public void getAirQuality(@RequestParam String cityId, HttpServletResponse httpResponse) throws IOException {
|
||||||
String apiKey = "02ccc3ea04810432b45399ecb183195d";
|
String apiKey = "02ccc3ea04810432b45399ecb183195d";
|
||||||
String apiUrl = "http://apis.juhe.cn/fapigw/air/historyHours?key="+apiKey+"&cityId="+cityId;
|
String apiUrl = "http://apis.juhe.cn/fapigw/air/historyHours?key="+apiKey+"&cityId="+cityId;
|
||||||
response.sendRedirect(apiUrl);
|
httpResponse.getWriter().write(apiUrl);
|
||||||
|
httpResponse.getWriter().flush();
|
||||||
|
httpResponse.getWriter().close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue