package com.srs.web.controller.dormitory;

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.dormitory.domain.DmsOutsideAccommodationApply;
import com.srs.dormitory.service.IDmsOutsideAccommodationApplyService;
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-12-05
 */
@RestController
@RequestMapping("/dormitory/outsideAccommodationApply")
@Api(value = "外宿申请管理", tags = "外宿申请管理")
public class DmsOutsideAccommodationApplyController extends BaseController {
    @Autowired
    private IDmsOutsideAccommodationApplyService dmsOutsideAccommodationApplyService;

    /**
     * 查询外宿申请列表
     */
@PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApply:list')")
@GetMapping("/list")
@ApiOperation("查询外宿申请列表")
    public TableDataInfo list(DmsOutsideAccommodationApply dmsOutsideAccommodationApply)
    {
        startPage();
        List<DmsOutsideAccommodationApply> list = dmsOutsideAccommodationApplyService.selectDmsOutsideAccommodationApplyList(dmsOutsideAccommodationApply);
        return getDataTable(list);
    }

    /**
     * 导出外宿申请列表
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApply:export')")
    @Log(title = "外宿申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出外宿申请列表")
    public void export(HttpServletResponse response, DmsOutsideAccommodationApply dmsOutsideAccommodationApply)
    {
        List<DmsOutsideAccommodationApply> list = dmsOutsideAccommodationApplyService.selectDmsOutsideAccommodationApplyList(dmsOutsideAccommodationApply);
        ExcelUtil<DmsOutsideAccommodationApply> util = new ExcelUtil<DmsOutsideAccommodationApply>(DmsOutsideAccommodationApply.class);
        util.exportExcel(response, list, "外宿申请数据");
    }

    /**
     * 获取外宿申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApply:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取外宿申请详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dmsOutsideAccommodationApplyService.selectDmsOutsideAccommodationApplyById(id));
    }

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

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

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

    /**
     * 删除外宿申请
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApply:remove')")
    @Log(title = "外宿申请", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除外宿申请")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dmsOutsideAccommodationApplyService.deleteDmsOutsideAccommodationApplyByIds(ids));
    }
}
