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

/**
 * 农村供水工程属性
 */
@RestController
@RequestMapping("/eng/attr/cws")
public class AttEngCwsController extends BaseController {

    @Autowired
    private IEngAttrService<AttEngCws> cwsEngAttrService;

    @GetMapping("/list")
    public TableDataInfo list(AttEngCws attEngCws) {
        startPage();
        List<AttEngCws> list = cwsEngAttrService.selectList(attEngCws);
        return getDataTable(list);
    }

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

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

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

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