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

/**
 * 灌区工程属性
 */
@RestController
@RequestMapping("/eng/attr/irr")
public class AttEngIrrController extends BaseController {

    @Autowired
    private IEngAttrService<AttEngIrr> irrEngAttrService;

    @GetMapping("/list")
    public TableDataInfo list(AttEngIrr attEngIrr) {
        startPage();
        List<AttEngIrr> list = irrEngAttrService.selectList(attEngIrr);
        return getDataTable(list);
    }

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

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

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

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