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.BisTtsaDesign;
import com.goldenwater.slaj.ttsa.service.IBisTtsaDesignService;

@RestController
@RequestMapping("/ttsa/ttsadesign")
public class BisTtsaDesignController extends BaseController {
    @Autowired
    private IBisTtsaDesignService bisTtsaDesignService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaDesign bisTtsaDesign) {
        startPage();
        List<BisTtsaDesign> list = bisTtsaDesignService.selectBisTtsaDesignList(bisTtsaDesign);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaDesign bisTtsaDesign) {
        return toAjax(bisTtsaDesignService.insertBisTtsaDesign(bisTtsaDesign));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaDesign bisTtsaDesign) {
        return toAjax(bisTtsaDesignService.updateBisTtsaDesign(bisTtsaDesign));
    }

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

    @Log(title = "考核指定管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsadesign:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaDesign bisTtsaDesign) {
        List<BisTtsaDesign> list = bisTtsaDesignService.selectBisTtsaDesignList(bisTtsaDesign);
        ExcelUtil<BisTtsaDesign> util = new ExcelUtil<BisTtsaDesign>(BisTtsaDesign.class);
        util.exportExcel(response, list, "考核指定管理数据");
    }
}
