package com.tofly.xrtygis.custom.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.service.CustomPollSourceService;
import com.tofly.xrtygis.entity.Pollsource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/customPollSource")
@Api(tags = "自定义污染源相关接口")
public class CustomPollSourceController {
    private final CustomPollSourceService customPollSourceService;

    @PostMapping("/turnOnTheAlarm")
    @ApiOperation("污染源报警上传")
    public ResultRespone turnOnTheAlarm(@RequestParam(value = "fileList", required = false) List<MultipartFile> fileList, Pollsource poll, String dto) {
        return ResultRespone.success(customPollSourceService.turnOnTheAlarm(fileList, poll,dto));
    }

    @DeleteMapping("/deletePoll")
    @ApiOperation("污染源删除")
    public ResultRespone deletePoll(String ids) {
        return ResultRespone.success(customPollSourceService.deletePoll(ids));
    }

    @GetMapping("/getFilePath")
    @ApiOperation("获取文件路径")
    public ResultRespone getFilePath(Long id) {
        return ResultRespone.success(customPollSourceService.getFilePath(id));
    }

    @GetMapping("/viewPollSource")
    @ApiOperation("查看用户污染源信息")
    public ResultRespone viewPollSource(Page page, String address, String iswarn) {
        return ResultRespone.success(customPollSourceService.viewPollSource(page, address, iswarn));
    }

    @GetMapping("/closeWarn")
    @ApiOperation("关闭报警")
    @ApiImplicitParam(name = "id", value = "污染源id", required = true, dataType = "long")
    public ResultRespone closeWarn(String id) {
        return ResultRespone.success(customPollSourceService.closeWarn(id));
    }

    @GetMapping("/getInfo")
    @ApiOperation("获取污染源详情")
    @ApiImplicitParam(name = "id", value = "污染源id", required = true, dataType = "long")
    public ResultRespone getInfo(Long id) {
        return ResultRespone.success(customPollSourceService.getInfo(id));
    }


    @GetMapping("/viewAll")
    @ApiOperation("查看全部污染源信息")
    public ResultRespone getAllPollSource(Page page, String address, String iswarn,String start,String end,String pollIds) {
        return ResultRespone.success(customPollSourceService.getAllPollSource(page, address, iswarn,start,end,pollIds));
    }

    @GetMapping("/getpollUte")
    @ApiOperation("查看污染物类别")
    public ResultRespone getpollUte(){
        return ResultRespone.success(customPollSourceService.getpollUte());
    }
}
