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

@RestController
@RequestMapping("/ttsa/objttsaexamappl")
public class ObjTtsaExamApplController extends BaseController {
    @Autowired
    private IObjTtsaExamApplService objTtsaExamApplService;

    @GetMapping("/list")
    public TableDataInfo list(ObjTtsaExamAppl objTtsaExamAppl) {
        startPage();
        List<ObjTtsaExamAppl> list = objTtsaExamApplService.selectObjTtsaExamApplList(objTtsaExamAppl);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjTtsaExamAppl objTtsaExamAppl) {
        return toAjax(objTtsaExamApplService.insertObjTtsaExamAppl(objTtsaExamAppl));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjTtsaExamAppl objTtsaExamAppl) {
        return toAjax(objTtsaExamApplService.updateObjTtsaExamAppl(objTtsaExamAppl));
    }

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

    @Log(title = "批量考核申请管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:objttsaexamappl:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ObjTtsaExamAppl objTtsaExamAppl) {
        List<ObjTtsaExamAppl> list = objTtsaExamApplService.selectObjTtsaExamApplList(objTtsaExamAppl);
        ExcelUtil<ObjTtsaExamAppl> util = new ExcelUtil<ObjTtsaExamAppl>(ObjTtsaExamAppl.class);
        util.exportExcel(response, list, "批量考核申请管理数据");
    }
}
