package com.goldenwater.slaj.hazard.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.slaj.hazard.domain.TBusiHazardReport;
import com.goldenwater.slaj.hazard.service.ITBusiHazardReportService;

/**
 * 危险源上报
 */
@RestController
@RequestMapping("/hazard/tbusihazardreport")
public class TBusiHazardReportController extends BaseController {
    @Autowired
    private ITBusiHazardReportService tBusiHazardReportService;

    @GetMapping("/list")
    public TableDataInfo list(TBusiHazardReport tBusiHazardReport) {
        startPage();
        List<TBusiHazardReport> list = tBusiHazardReportService.selectTBusiHazardReportList(tBusiHazardReport);
        return getDataTable(list);
    }

    @GetMapping("/{guid}")
    public AjaxResult getInfo(@PathVariable String guid) {
        return AjaxResult.success(tBusiHazardReportService.selectTBusiHazardReportByGuid(guid));
    }

    @PostMapping
    public AjaxResult add(@RequestBody TBusiHazardReport tBusiHazardReport) {
        return toAjax(tBusiHazardReportService.insertTBusiHazardReport(tBusiHazardReport));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody TBusiHazardReport tBusiHazardReport) {
        return toAjax(tBusiHazardReportService.updateTBusiHazardReport(tBusiHazardReport));
    }

    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(tBusiHazardReportService.deleteTBusiHazardReportByGuids(guids));
    }
}
