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.DmsOutsideAccommodationApproval;
import com.srs.dormitory.service.IDmsOutsideAccommodationApprovalService;
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/outsideAccommodationApproval")
@Api(value = "外宿申请审批记录管理", tags = "外宿申请审批记录管理")
public class DmsOutsideAccommodationApprovalController extends BaseController {
    @Autowired
    private IDmsOutsideAccommodationApprovalService dmsOutsideAccommodationApprovalService;

    /**
     * 查询外宿申请审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApproval:list')")
    @GetMapping("/list")
    @ApiOperation("查询外宿申请审批记录列表")
    public TableDataInfo list(DmsOutsideAccommodationApproval dmsOutsideAccommodationApproval) {
        startPage();
        List<DmsOutsideAccommodationApproval> list = dmsOutsideAccommodationApprovalService.selectDmsOutsideAccommodationApprovalList(dmsOutsideAccommodationApproval);
        return getDataTable(list);
    }

    /**
     * 导出外宿申请审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApproval:export')")
    @Log(title = "外宿申请审批记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出外宿申请审批记录列表")
    public void export(HttpServletResponse response, DmsOutsideAccommodationApproval dmsOutsideAccommodationApproval) {
        List<DmsOutsideAccommodationApproval> list = dmsOutsideAccommodationApprovalService.selectDmsOutsideAccommodationApprovalList(dmsOutsideAccommodationApproval);
        ExcelUtil<DmsOutsideAccommodationApproval> util = new ExcelUtil<DmsOutsideAccommodationApproval>(DmsOutsideAccommodationApproval.class);
        util.exportExcel(response, list, "外宿申请审批记录数据");
    }

    /**
     * 获取外宿申请审批记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApproval:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取外宿申请审批记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(dmsOutsideAccommodationApprovalService.selectDmsOutsideAccommodationApprovalById(id));
    }

    /**
     * 新增外宿申请审批记录
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApproval:add')")
    @Log(title = "外宿申请审批记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增外宿申请审批记录")
    public AjaxResult add(@RequestBody DmsOutsideAccommodationApproval dmsOutsideAccommodationApproval) {
        return toAjax(dmsOutsideAccommodationApprovalService.insertDmsOutsideAccommodationApproval(dmsOutsideAccommodationApproval));
    }

    /**
     * 新增或修改外宿申请审批记录
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApproval:add')")
    @Log(title = "外宿申请审批记录", businessType = BusinessType.INSERT)
    @PostMapping("/addOrUpdate")
    @ApiOperation("新增或修改外宿申请审批记录")
    public AjaxResult addOrUpdateAccommodationApproval(@RequestBody DmsOutsideAccommodationApproval dmsOutsideAccommodationApproval) {
        return toAjax(dmsOutsideAccommodationApprovalService.addOrUpdateAccommodationApproval(dmsOutsideAccommodationApproval));
    }

    /**
     * 修改外宿申请审批记录
     */
    @PreAuthorize("@ss.hasPermi('dormitory:outsideAccommodationApproval:edit')")
    @Log(title = "外宿申请审批记录", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改外宿申请审批记录")
    public AjaxResult edit(@RequestBody DmsOutsideAccommodationApproval dmsOutsideAccommodationApproval) {
        return toAjax(dmsOutsideAccommodationApprovalService.updateDmsOutsideAccommodationApproval(dmsOutsideAccommodationApproval));
    }

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