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

@RestController
@RequestMapping("/ttsa/ttsascore")
public class BisTtsaScoreController extends BaseController {
    @Autowired
    private IBisTtsaScoreService bisTtsaScoreService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaScore bisTtsaScore) {
        startPage();
        List<BisTtsaScore> list = bisTtsaScoreService.selectBisTtsaScoreList(bisTtsaScore);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaScore bisTtsaScore) {
        return toAjax(bisTtsaScoreService.insertBisTtsaScore(bisTtsaScore));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaScore bisTtsaScore) {
        return toAjax(bisTtsaScoreService.updateBisTtsaScore(bisTtsaScore));
    }

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

    @Log(title = "考试成绩管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsascore:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaScore bisTtsaScore) {
        List<BisTtsaScore> list = bisTtsaScoreService.selectBisTtsaScoreList(bisTtsaScore);
        ExcelUtil<BisTtsaScore> util = new ExcelUtil<BisTtsaScore>(BisTtsaScore.class);
        util.exportExcel(response, list, "考试成绩管理数据");
    }
}
