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

@RestController
@RequestMapping("/sins/objcase")
public class ObjCaseController extends BaseController {
    @Autowired
    private IObjCaseService objCaseService;

    @GetMapping("/list")
    public TableDataInfo list(ObjCase objCase) { startPage(); List<ObjCase> list = objCaseService.selectObjCaseList(objCase); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjCase objCase) { return toAjax(objCaseService.insertObjCase(objCase)); }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjCase objCase) { return toAjax(objCaseService.updateObjCase(objCase)); }

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

    @Log(title = "执法案件管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:objcase:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ObjCase objCase) { List<ObjCase> list = objCaseService.selectObjCaseList(objCase); ExcelUtil<ObjCase> util = new ExcelUtil<ObjCase>(ObjCase.class); util.exportExcel(response, list, "执法案件管理数据"); }
}
