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

@RestController
@RequestMapping("/ttsa/ttsadesignexamrel")
public class BisTtsaDesignExamRelController extends BaseController {
    @Autowired
    private IBisTtsaDesignExamRelService bisTtsaDesignExamRelService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaDesignExamRel bisTtsaDesignExamRel) {
        startPage();
        List<BisTtsaDesignExamRel> list = bisTtsaDesignExamRelService.selectBisTtsaDesignExamRelList(bisTtsaDesignExamRel);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaDesignExamRel bisTtsaDesignExamRel) {
        return toAjax(bisTtsaDesignExamRelService.insertBisTtsaDesignExamRel(bisTtsaDesignExamRel));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaDesignExamRel bisTtsaDesignExamRel) {
        return toAjax(bisTtsaDesignExamRelService.updateBisTtsaDesignExamRel(bisTtsaDesignExamRel));
    }

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

    @Log(title = "指定考试关联管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsadesignexamrel:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaDesignExamRel bisTtsaDesignExamRel) {
        List<BisTtsaDesignExamRel> list = bisTtsaDesignExamRelService.selectBisTtsaDesignExamRelList(bisTtsaDesignExamRel);
        ExcelUtil<BisTtsaDesignExamRel> util = new ExcelUtil<BisTtsaDesignExamRel>(BisTtsaDesignExamRel.class);
        util.exportExcel(response, list, "指定考试关联管理数据");
    }
}
