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.HazardSource;
import com.goldenwater.slaj.hazard.service.IHazardSourceService;

/**
 * 危险源风险
 */
@RestController
@RequestMapping("/hazard/hazardsource")
public class HazardSourceController extends BaseController {
    @Autowired
    private IHazardSourceService hazardSourceService;

    @GetMapping("/list")
    public TableDataInfo list(HazardSource hazardSource) {
        startPage();
        List<HazardSource> list = hazardSourceService.selectHazardSourceList(hazardSource);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody HazardSource hazardSource) {
        return toAjax(hazardSourceService.insertHazardSource(hazardSource));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody HazardSource hazardSource) {
        return toAjax(hazardSourceService.updateHazardSource(hazardSource));
    }

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