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.DemCase;
import com.usky.fire.service.DemCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 设备案件 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-10-12
 */
@RestController
@RequestMapping("/demCase")
public class DemCaseController {

    @Autowired
    private DemCaseService demCaseService;

    /**
     * 企业自主管理-历史案件-列表查询
     *
     * @param streetTown  街镇
     * @param companyName 单位名称
     * @param deviceType  设备类型
     * @param id          主键ID
     * @param pageNum     当前页
     * @param pageSize    每页条数
     * @return
     */
    @GetMapping("caseList")
    public ApiResult<CommonPage<DemCase>> caseList(@RequestParam(value = "streetTown", required = false) String streetTown,
                                                   @RequestParam(value = "companyName", required = false) String companyName,
                                                   @RequestParam(value = "deviceType", required = false) String deviceType,
                                                   @RequestParam(value = "id", required = false, defaultValue = "0") Integer id,
                                                   @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                   @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(demCaseService.caseList(streetTown, companyName, deviceType, id, pageNum, pageSize));
    }

    /**
     * 企业自主管理-历史案件-统计
     *
     * @param streetTown 街镇
     * @param companyId  单位ID
     * @return
     */
    @GetMapping("caseStatistics")
    public ApiResult<Map<String, Object>> caseStatistics(@RequestParam(value = "streetTown", required = false) String streetTown,
                                                         @RequestParam(value = "companyId", required = false) String companyId) {
        return ApiResult.success(demCaseService.caseStatistics(streetTown, companyId));
    }


}

