package com.srs.web.controller.routine;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.routine.domain.RtEnlistmentReserveApproval;
import com.srs.routine.service.IRtEnlistmentReserveApprovalService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 保留学籍审批记录Controller
 *
 * @author srs
 * @date 2025-10-31
 */
@RestController
@RequestMapping("/routine/enlistmentReserveApproval")
@Api(value = "保留学籍审批记录管理", tags = "保留学籍审批记录管理")
public class RtEnlistmentReserveApprovalController extends BaseController {
    @Autowired
    private IRtEnlistmentReserveApprovalService rtEnlistmentReserveApprovalService;

    /**
     * 查询保留学籍审批记录列表
     */
@PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:list')")
@GetMapping("/list")
@ApiOperation("查询保留学籍审批记录列表")
    public TableDataInfo list(RtEnlistmentReserveApproval rtEnlistmentReserveApproval)
    {
        startPage();
        List<RtEnlistmentReserveApproval> list = rtEnlistmentReserveApprovalService.selectRtEnlistmentReserveApprovalList(rtEnlistmentReserveApproval);
        return getDataTable(list);
    }

    /**
     * 导出保留学籍审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:export')")
    @Log(title = "保留学籍审批记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出保留学籍审批记录列表")
    public void export(HttpServletResponse response, RtEnlistmentReserveApproval rtEnlistmentReserveApproval)
    {
        List<RtEnlistmentReserveApproval> list = rtEnlistmentReserveApprovalService.selectRtEnlistmentReserveApprovalList(rtEnlistmentReserveApproval);
        ExcelUtil<RtEnlistmentReserveApproval> util = new ExcelUtil<RtEnlistmentReserveApproval>(RtEnlistmentReserveApproval.class);
        util.exportExcel(response, list, "保留学籍审批记录数据");
    }

    /**
     * 获取保留学籍审批记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取保留学籍审批记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rtEnlistmentReserveApprovalService.selectRtEnlistmentReserveApprovalById(id));
    }

    /**
     * 新增保留学籍审批记录
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:add')")
    @Log(title = "保留学籍审批记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增保留学籍审批记录")
    public AjaxResult add(@RequestBody RtEnlistmentReserveApproval rtEnlistmentReserveApproval)
    {
        return toAjax(rtEnlistmentReserveApprovalService.insertRtEnlistmentReserveApproval(rtEnlistmentReserveApproval));
    }

    /**
     * 根据学生姓名、学号、审批人ID判断，存在则更新，不存在则新增
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:add')")
    @Log(title = "保留学籍审批记录", businessType = BusinessType.INSERT)
    @PostMapping("/insertOrUpdateByStuAndApprover")
    @ApiOperation("新增\\修改保留学籍审批记录")
    public AjaxResult insertOrUpdateByStuAndApprover(@RequestBody RtEnlistmentReserveApproval rtEnlistmentReserveApproval)
    {
        return toAjax(rtEnlistmentReserveApprovalService.insertOrUpdateByStuAndApprover(rtEnlistmentReserveApproval));
    }

    /**
     * 修改保留学籍审批记录
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:edit')")
    @Log(title = "保留学籍审批记录", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改保留学籍审批记录")
    public AjaxResult edit(@RequestBody RtEnlistmentReserveApproval rtEnlistmentReserveApproval)
    {
        return toAjax(rtEnlistmentReserveApprovalService.updateRtEnlistmentReserveApproval(rtEnlistmentReserveApproval));
    }

    /**
     * 删除保留学籍审批记录
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserveApproval:remove')")
    @Log(title = "保留学籍审批记录", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除保留学籍审批记录")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtEnlistmentReserveApprovalService.deleteRtEnlistmentReserveApprovalByIds(ids));
    }
}
