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

/**
 * 水利危险源
 */
@RestController
@RequestMapping("/hazard/mwrhaz")
public class MwrHazController extends BaseController {
    @Autowired
    private IMwrHazService mwrHazService;

    @GetMapping("/list")
    public TableDataInfo list(MwrHaz mwrHaz) {
        startPage();
        List<MwrHaz> list = mwrHazService.selectMwrHazList(mwrHaz);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody MwrHaz mwrHaz) {
        return toAjax(mwrHazService.insertMwrHaz(mwrHaz));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody MwrHaz mwrHaz) {
        return toAjax(mwrHazService.updateMwrHaz(mwrHaz));
    }

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