cjl
2023-11-15 d117d3af15dddc4f07baffa8b5bf6b727c05de7c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
    }
}