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

@RestController
@RequestMapping("/sins/relsinstoorg")
public class RelSinsToOrgController extends BaseController {
    @Autowired
    private IRelSinsToOrgService relSinsToOrgService;

    @GetMapping("/list")
    public TableDataInfo list(RelSinsToOrg relSinsToOrg) { startPage(); List<RelSinsToOrg> list = relSinsToOrgService.selectRelSinsToOrgList(relSinsToOrg); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody RelSinsToOrg relSinsToOrg) { return toAjax(relSinsToOrgService.insertRelSinsToOrg(relSinsToOrg)); }

    @PutMapping
    public AjaxResult edit(@RequestBody RelSinsToOrg relSinsToOrg) { return toAjax(relSinsToOrgService.updateRelSinsToOrg(relSinsToOrg)); }

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

    @Log(title = "检查方案机构关联管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:relsinstoorg:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, RelSinsToOrg relSinsToOrg) { List<RelSinsToOrg> list = relSinsToOrgService.selectRelSinsToOrgList(relSinsToOrg); ExcelUtil<RelSinsToOrg> util = new ExcelUtil<RelSinsToOrg>(RelSinsToOrg.class); util.exportExcel(response, list, "检查方案机构关联管理数据"); }
}
