package com.usky.fire.controller.web;

import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.fire.domain.JcjAjxx;
import com.usky.fire.service.JcjAjxxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZYJ
 * @since 2023-01-17
 */
@RestController
@RequestMapping("/jcjAjxx")
public class JcjAjxxController {
    @Autowired
    private JcjAjxxService jcjAjxxService;

    /**
     * 接警每个柱状图详情信息展示
     *
     * @param streetTown     街镇（4个）
     * @param startDate      开始时间 格式：yyyy-MM-dd HH:mm:ss
     * @param endDate        结束时间 格式：yyyy-MM-dd HH:mm:ss
     * @param caseType       案件类型
     * @param pageNum        当前页
     * @param pageSize       每页条数
     * @return
     *
     */
    @GetMapping("jcjAjxxList")
    public ApiResult<CommonPage<JcjAjxx>> jcjAjxxList(@RequestParam(value="streetTown") String streetTown,
                                               @RequestParam(value = "startDate", required = false) String startDate,
                                               @RequestParam(value = "endDate", required = false) String endDate,
                                               @RequestParam(value = "caseType") String caseType,
                                               @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                               @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize){
        return ApiResult.success(jcjAjxxService.jcjAjxxList(streetTown, startDate, endDate, caseType, pageNum, pageSize));
    }


    /**
     * 接警处置柱状图统计
     */
    @GetMapping("jcjAjxxStatistics")
    public ApiResult<Map<String,Object>> jcjAjxxStatistics(@RequestParam(value="streetTown") String streetTown,
                                                           @RequestParam(value = "startDate", required = false) String startDate,
                                                           @RequestParam(value = "endDate", required = false) String endDate){
        return ApiResult.success(jcjAjxxService.jcjAjxxStatistics(streetTown, startDate, endDate));
    }

}

