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

/**
 * 危险源对象
 */
@RestController
@RequestMapping("/hazard/objhaz")
public class ObjHazController extends BaseController {
    @Autowired
    private IObjHazService objHazService;

    @GetMapping("/list")
    public TableDataInfo list(ObjHaz objHaz) {
        startPage();
        List<ObjHaz> list = objHazService.selectObjHazList(objHaz);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjHaz objHaz) {
        return toAjax(objHazService.insertObjHaz(objHaz));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjHaz objHaz) {
        return toAjax(objHazService.updateObjHaz(objHaz));
    }

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