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.ObjAcci;
import com.goldenwater.slaj.acci.service.IObjAcciService;

/**
 * 事故对象
 */
@RestController
@RequestMapping("/acci/objacci")
public class ObjAcciController extends BaseController {
    @Autowired
    private IObjAcciService objAcciService;

    @GetMapping("/list")
    public TableDataInfo list(ObjAcci objAcci) {
        startPage();
        List<ObjAcci> list = objAcciService.selectObjAcciList(objAcci);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjAcci objAcci) {
        return toAjax(objAcciService.insertObjAcci(objAcci));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjAcci objAcci) {
        return toAjax(objAcciService.updateObjAcci(objAcci));
    }

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