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

@RestController
@RequestMapping("/ttsa/ttsaexamplan")
public class BisTtsaExamPlanController extends BaseController {
    @Autowired
    private IBisTtsaExamPlanService bisTtsaExamPlanService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaExamPlan bisTtsaExamPlan) {
        startPage();
        List<BisTtsaExamPlan> list = bisTtsaExamPlanService.selectBisTtsaExamPlanList(bisTtsaExamPlan);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaExamPlan bisTtsaExamPlan) {
        return toAjax(bisTtsaExamPlanService.insertBisTtsaExamPlan(bisTtsaExamPlan));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaExamPlan bisTtsaExamPlan) {
        return toAjax(bisTtsaExamPlanService.updateBisTtsaExamPlan(bisTtsaExamPlan));
    }

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

    @Log(title = "考核计划管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsaexamplan:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaExamPlan bisTtsaExamPlan) {
        List<BisTtsaExamPlan> list = bisTtsaExamPlanService.selectBisTtsaExamPlanList(bisTtsaExamPlan);
        ExcelUtil<BisTtsaExamPlan> util = new ExcelUtil<BisTtsaExamPlan>(BisTtsaExamPlan.class);
        util.exportExcel(response, list, "考核计划管理数据");
    }
}
