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

@RestController
@RequestMapping("/sins/objsins")
public class ObjSinsController extends BaseController {
    @Autowired
    private IObjSinsService objSinsService;

    @GetMapping("/list")
    public TableDataInfo list(ObjSins objSins) { startPage(); List<ObjSins> list = objSinsService.selectObjSinsList(objSins); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjSins objSins) { return toAjax(objSinsService.insertObjSins(objSins)); }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjSins objSins) { return toAjax(objSinsService.updateObjSins(objSins)); }

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

    @Log(title = "安全检查方案管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:objsins:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ObjSins objSins) { List<ObjSins> list = objSinsService.selectObjSinsList(objSins); ExcelUtil<ObjSins> util = new ExcelUtil<ObjSins>(ObjSins.class); util.exportExcel(response, list, "安全检查方案管理数据"); }
}
