package com.goldenwater.slaj.stan.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.stan.domain.ObjPuno;
import com.goldenwater.slaj.stan.service.IObjPunoService;

@RestController
@RequestMapping("/stan/objpuno")
public class ObjPunoController extends BaseController {
    @Autowired
    private IObjPunoService objPunoService;

    @GetMapping("/list")
    public TableDataInfo list(ObjPuno objPuno) { startPage(); List<ObjPuno> list = objPunoService.selectObjPunoList(objPuno); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjPuno objPuno) { return toAjax(objPunoService.insertObjPuno(objPuno)); }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjPuno objPuno) { return toAjax(objPunoService.updateObjPuno(objPuno)); }

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

    @Log(title = "处罚对象管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('stan:objpuno:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ObjPuno objPuno) { List<ObjPuno> list = objPunoService.selectObjPunoList(objPuno); ExcelUtil<ObjPuno> util = new ExcelUtil<ObjPuno>(ObjPuno.class); util.exportExcel(response, list, "处罚对象管理数据"); }
}
