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

@RestController
@RequestMapping("/sins/wiunberebad")
public class BisWiunBereBadController extends BaseController {
    @Autowired
    private IBisWiunBereBadService bisWiunBereBadService;

    @GetMapping("/list")
    public TableDataInfo list(BisWiunBereBad bisWiunBereBad) { startPage(); List<BisWiunBereBad> list = bisWiunBereBadService.selectBisWiunBereBadList(bisWiunBereBad); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisWiunBereBad bisWiunBereBad) { return toAjax(bisWiunBereBadService.insertBisWiunBereBad(bisWiunBereBad)); }

    @PutMapping
    public AjaxResult edit(@RequestBody BisWiunBereBad bisWiunBereBad) { return toAjax(bisWiunBereBadService.updateBisWiunBereBad(bisWiunBereBad)); }

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

    @Log(title = "不良行为记录管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:wiunberebad:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisWiunBereBad bisWiunBereBad) { List<BisWiunBereBad> list = bisWiunBereBadService.selectBisWiunBereBadList(bisWiunBereBad); ExcelUtil<BisWiunBereBad> util = new ExcelUtil<BisWiunBereBad>(BisWiunBereBad.class); util.exportExcel(response, list, "不良行为记录管理数据"); }
}
