package com.goldenwater.slaj.ttsa.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.ttsa.domain.BisTtsaApplWiun;
import com.goldenwater.slaj.ttsa.service.IBisTtsaApplWiunService;

@RestController
@RequestMapping("/ttsa/ttsaapplwiun")
public class BisTtsaApplWiunController extends BaseController {
    @Autowired
    private IBisTtsaApplWiunService bisTtsaApplWiunService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaApplWiun bisTtsaApplWiun) {
        startPage();
        List<BisTtsaApplWiun> list = bisTtsaApplWiunService.selectBisTtsaApplWiunList(bisTtsaApplWiun);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaApplWiun bisTtsaApplWiun) {
        return toAjax(bisTtsaApplWiunService.insertBisTtsaApplWiun(bisTtsaApplWiun));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaApplWiun bisTtsaApplWiun) {
        return toAjax(bisTtsaApplWiunService.updateBisTtsaApplWiun(bisTtsaApplWiun));
    }

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

    @Log(title = "申请安全元素管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsaapplwiun:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaApplWiun bisTtsaApplWiun) {
        List<BisTtsaApplWiun> list = bisTtsaApplWiunService.selectBisTtsaApplWiunList(bisTtsaApplWiun);
        ExcelUtil<BisTtsaApplWiun> util = new ExcelUtil<BisTtsaApplWiun>(BisTtsaApplWiun.class);
        util.exportExcel(response, list, "申请安全元素管理数据");
    }
}
