package com.goldenwater.slaj.sins.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.common.utils.poi.ExcelUtil;
import com.goldenwater.slaj.sins.domain.AttEngRes;
import com.goldenwater.slaj.sins.service.IAttEngResService;

@RestController
@RequestMapping("/sins/attengres")
public class AttEngResController extends BaseController {
    @Autowired
    private IAttEngResService attEngResService;

    @GetMapping("/list")
    public TableDataInfo list(AttEngRes attEngRes) { startPage(); List<AttEngRes> list = attEngResService.selectAttEngResList(attEngRes); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody AttEngRes attEngRes) { return toAjax(attEngResService.insertAttEngRes(attEngRes)); }

    @PutMapping
    public AjaxResult edit(@RequestBody AttEngRes attEngRes) { return toAjax(attEngResService.updateAttEngRes(attEngRes)); }

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

    @Log(title = "水库工程属性管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:attengres:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, AttEngRes attEngRes) { List<AttEngRes> list = attEngResService.selectAttEngResList(attEngRes); ExcelUtil<AttEngRes> util = new ExcelUtil<AttEngRes>(AttEngRes.class); util.exportExcel(response, list, "水库工程属性管理数据"); }
}
