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

@RestController
@RequestMapping("/sins/sawfcredsapr")
public class SawfCredSaprController extends BaseController {
    @Autowired
    private ISawfCredSaprService sawfCredSaprService;

    @GetMapping("/list")
    public TableDataInfo list(SawfCredSapr sawfCredSapr) { startPage(); List<SawfCredSapr> list = sawfCredSaprService.selectSawfCredSaprList(sawfCredSapr); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody SawfCredSapr sawfCredSapr) { return toAjax(sawfCredSaprService.insertSawfCredSapr(sawfCredSapr)); }

    @PutMapping
    public AjaxResult edit(@RequestBody SawfCredSapr sawfCredSapr) { return toAjax(sawfCredSaprService.updateSawfCredSapr(sawfCredSapr)); }

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

    @Log(title = "SAWF信用安全评估管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:sawfcredsapr:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SawfCredSapr sawfCredSapr) { List<SawfCredSapr> list = sawfCredSaprService.selectSawfCredSaprList(sawfCredSapr); ExcelUtil<SawfCredSapr> util = new ExcelUtil<SawfCredSapr>(SawfCredSapr.class); util.exportExcel(response, list, "SAWF信用安全评估管理数据"); }
}
