package com.goldenwater.slaj.acci.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.acci.domain.SawfAcci;
import com.goldenwater.slaj.acci.service.ISawfAcciService;

/**
 * 事故共享信息
 */
@RestController
@RequestMapping("/acci/sawfacci")
public class SawfAcciController extends BaseController {
    @Autowired
    private ISawfAcciService sawfAcciService;

    @GetMapping("/list")
    public TableDataInfo list(SawfAcci sawfAcci) {
        startPage();
        List<SawfAcci> list = sawfAcciService.selectSawfAcciList(sawfAcci);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody SawfAcci sawfAcci) {
        return toAjax(sawfAcciService.insertSawfAcci(sawfAcci));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody SawfAcci sawfAcci) {
        return toAjax(sawfAcciService.updateSawfAcci(sawfAcci));
    }

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