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

/**
 * 危险源
 */
@RestController
@RequestMapping("/hazard/objhazard")
public class ObjHazardController extends BaseController {
    @Autowired
    private IObjHazardService objHazardService;

    @GetMapping("/list")
    public TableDataInfo list(ObjHazard objHazard) {
        startPage();
        List<ObjHazard> list = objHazardService.selectObjHazardList(objHazard);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjHazard objHazard) {
        return toAjax(objHazardService.insertObjHazard(objHazard));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjHazard objHazard) {
        return toAjax(objHazardService.updateObjHazard(objHazard));
    }

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