package com.moral.api.controller;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Date;
|
import java.util.Map;
|
|
import com.moral.api.service.CityAqiMonthlyService;
|
import com.moral.constant.ResponseCodeEnum;
|
import com.moral.constant.ResultMessage;
|
|
@RestController
|
@RequestMapping("announcement")
|
@CrossOrigin(origins = "*", maxAge = 3600)
|
public class AirQualityNoticeController {
|
|
@Autowired
|
private CityAqiMonthlyService cityAqiMonthlyService;
|
|
/**
|
* @param regionCode 地级市code
|
*/
|
@GetMapping("airQualityRanking")
|
public ResultMessage airQualityRankingAnnouncement(Integer regionCode, @DateTimeFormat(pattern = "yyyy-MM") Date time) {
|
if (regionCode == null || time == null) {
|
return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
|
}
|
Map<String, Object> response = cityAqiMonthlyService.airQualityRankingAnnouncement(regionCode, time);
|
return ResultMessage.ok(response);
|
}
|
}
|