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.RelEngOrg;
import com.goldenwater.slaj.sins.service.IRelEngOrgService;

@RestController
@RequestMapping("/sins/relengorg")
public class RelEngOrgController extends BaseController {
    @Autowired
    private IRelEngOrgService relEngOrgService;

    @GetMapping("/list")
    public TableDataInfo list(RelEngOrg relEngOrg) { startPage(); List<RelEngOrg> list = relEngOrgService.selectRelEngOrgList(relEngOrg); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody RelEngOrg relEngOrg) { return toAjax(relEngOrgService.insertRelEngOrg(relEngOrg)); }

    @PutMapping
    public AjaxResult edit(@RequestBody RelEngOrg relEngOrg) { return toAjax(relEngOrgService.updateRelEngOrg(relEngOrg)); }

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

    @Log(title = "工程机构关联管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:relengorg:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, RelEngOrg relEngOrg) { List<RelEngOrg> list = relEngOrgService.selectRelEngOrgList(relEngOrg); ExcelUtil<RelEngOrg> util = new ExcelUtil<RelEngOrg>(RelEngOrg.class); util.exportExcel(response, list, "工程机构关联管理数据"); }
}
