package com.goldenwater.slaj.eng.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.eng.domain.AttEngWaga;
import com.goldenwater.slaj.eng.service.IEngAttrService;

/**
 * 水闸工程属性
 */
@RestController
@RequestMapping("/eng/attr/waga")
public class AttEngWagaController extends BaseController {

    @Autowired
    private IEngAttrService<AttEngWaga> wagaEngAttrService;

    @GetMapping("/list")
    public TableDataInfo list(AttEngWaga attEngWaga) {
        startPage();
        List<AttEngWaga> list = wagaEngAttrService.selectList(attEngWaga);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody AttEngWaga entity) {
        return toAjax(wagaEngAttrService.insert(entity));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody AttEngWaga entity) {
        return toAjax(wagaEngAttrService.update(entity));
    }

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