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

/**
 * 危险性较大工程对象表
 */
@RestController
@RequestMapping("/hazard/objenghaza")
public class ObjEngHazaController extends BaseController {
    @Autowired
    private IObjEngHazaService objEngHazaService;

    @GetMapping("/list")
    public TableDataInfo list(ObjEngHaza objEngHaza) {
        startPage();
        List<ObjEngHaza> list = objEngHazaService.selectObjEngHazaList(objEngHaza);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjEngHaza objEngHaza) {
        return toAjax(objEngHazaService.insertObjEngHaza(objEngHaza));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjEngHaza objEngHaza) {
        return toAjax(objEngHazaService.updateObjEngHaza(objEngHaza));
    }

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