package com.srs.web.controller.routine;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.srs.dormitory.domain.DmsOutsideAccommodationApply;
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.RtEnlistmentReserve;
import com.srs.routine.service.IRtEnlistmentReserveService;
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/enlistmentReserve")
@Api(value = "应征入伍保留学籍申请管理", tags = "应征入伍保留学籍申请管理")
public class RtEnlistmentReserveController extends BaseController {
    @Autowired
    private IRtEnlistmentReserveService rtEnlistmentReserveService;

    /**
     * 查询应征入伍保留学籍申请列表
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:list')")
    @GetMapping("/list")
    @ApiOperation("查询应征入伍保留学籍申请列表")
    public TableDataInfo list(RtEnlistmentReserve rtEnlistmentReserve) {
        startPage();
        List<RtEnlistmentReserve> list = rtEnlistmentReserveService.selectRtEnlistmentReserveList(rtEnlistmentReserve);
        return getDataTable(list);
    }

    /**
     * 导出应征入伍保留学籍申请列表
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:export')")
    @Log(title = "应征入伍保留学籍申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出应征入伍保留学籍申请列表")
    public void export(HttpServletResponse response, RtEnlistmentReserve rtEnlistmentReserve) {
        List<RtEnlistmentReserve> list = rtEnlistmentReserveService.selectRtEnlistmentReserveList(rtEnlistmentReserve);
        ExcelUtil<RtEnlistmentReserve> util = new ExcelUtil<RtEnlistmentReserve>(RtEnlistmentReserve.class);
        util.exportExcel(response, list, "应征入伍保留学籍申请数据");
    }

    /**
     * 获取应征入伍保留学籍申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取应征入伍保留学籍申请详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(rtEnlistmentReserveService.selectRtEnlistmentReserveById(id));
    }

    /**
     * 获取应征入伍保留学籍申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:query')")
    @GetMapping(value = "/process/{processInstanceId}")
    @ApiOperation("获取应征入伍保留学籍申请详细信息")
    public AjaxResult getInfoByProcessInstanceId(@PathVariable("processInstanceId") String processInstanceId) {
        return success(rtEnlistmentReserveService.selectRtEnlistmentReserveByProcessInstanceId(processInstanceId));
    }

    /**
     * 新增应征入伍保留学籍申请
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:add')")
    @Log(title = "应征入伍保留学籍申请", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增应征入伍保留学籍申请")
    public AjaxResult add(@RequestBody RtEnlistmentReserve rtEnlistmentReserve) {
        return success(rtEnlistmentReserveService.insertRtEnlistmentReserve(rtEnlistmentReserve));
    }

    /**
     * 修改应征入伍保留学籍申请
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:edit')")
    @Log(title = "应征入伍保留学籍申请", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改应征入伍保留学籍申请")
    public AjaxResult edit(@RequestBody RtEnlistmentReserve rtEnlistmentReserve) {
        return toAjax(rtEnlistmentReserveService.updateRtEnlistmentReserve(rtEnlistmentReserve));
    }

    /**
     * 删除应征入伍保留学籍申请
     */
    @PreAuthorize("@ss.hasPermi('routine:enlistmentReserve:remove')")
    @Log(title = "应征入伍保留学籍申请", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除应征入伍保留学籍申请")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(rtEnlistmentReserveService.deleteRtEnlistmentReserveByIds(ids));
    }


    /**
     * 新增外宿申请
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApply:add')")
    @Log(title = "外宿申请", businessType = BusinessType.INSERT)
    @PostMapping("/outsideAccommodationApply/add")
    @ApiOperation("新增外宿申请")
    public AjaxResult add(@RequestBody DmsOutsideAccommodationApply dmsOutsideAccommodationApply)
    {
        return success(rtEnlistmentReserveService.insertDmsOutsideAccommodationApply(dmsOutsideAccommodationApply));
    }

    /**
     * 修改外宿申请
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApply:edit')")
    @Log(title = "外宿申请", businessType = BusinessType.UPDATE)
    @PostMapping("/outsideAccommodationApply/update")
    @ApiOperation("修改外宿申请")
    public AjaxResult edit(@RequestBody DmsOutsideAccommodationApply dmsOutsideAccommodationApply)
    {
        return toAjax(rtEnlistmentReserveService.updateDmsOutsideAccommodationApply(dmsOutsideAccommodationApply));
    }
}
