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.RtStuLeaveOperationRecords;
import com.srs.routine.service.IRtStuLeaveOperationRecordsService;
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 LSD
 * @date 2024-03-30
 */
@RestController
@RequestMapping("/routine/leaveOperationRecords")
@Api(value = "请假操作记录管理", tags = "日常事务-审核记录")
public class RtStuLeaveOperationRecordsController extends BaseController {
    @Autowired
    private IRtStuLeaveOperationRecordsService rtStuLeaveOperationRecordsService;

    /**
     * 查询请假操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('routine:leaveOperationRecords:list')")
    @GetMapping("/list")
    @ApiOperation("查询请假操作记录列表")
    public TableDataInfo list(RtStuLeaveOperationRecords rtStuLeaveOperationRecords) {
        startPage();
        List<RtStuLeaveOperationRecords> list = rtStuLeaveOperationRecordsService.selectRtStuLeaveOperationRecordsList(rtStuLeaveOperationRecords);
        return getDataTable(list);
    }

    /**
     * 导出请假操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('routine:leaveOperationRecords:export')")
    @Log(title = "请假操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出请假操作记录列表")
    public void export(HttpServletResponse response, RtStuLeaveOperationRecords rtStuLeaveOperationRecords) {
        List<RtStuLeaveOperationRecords> list = rtStuLeaveOperationRecordsService.selectRtStuLeaveOperationRecordsList(rtStuLeaveOperationRecords);
        ExcelUtil<RtStuLeaveOperationRecords> util = new ExcelUtil<RtStuLeaveOperationRecords>(RtStuLeaveOperationRecords.class);
        util.exportExcel(response, list, "请假操作记录数据");
    }

    /**
     * 获取请假操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:leaveOperationRecords:query')")
    @GetMapping(value = "/{operationRecordsId}")
    @ApiOperation("获取请假操作记录详细信息")
    public AjaxResult getInfo(@PathVariable("operationRecordsId") Long operationRecordsId) {
        return success(rtStuLeaveOperationRecordsService.selectRtStuLeaveOperationRecordsByOperationRecordsId(operationRecordsId));
    }

    /**
     * 新增请假操作记录
     */
    @PreAuthorize("@ss.hasPermi('routine:leaveOperationRecords:add')")
    @Log(title = "请假操作记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增请假操作记录")
    public AjaxResult add(@RequestBody RtStuLeaveOperationRecords rtStuLeaveOperationRecords) {
        return toAjax(rtStuLeaveOperationRecordsService.insertRtStuLeaveOperationRecords(rtStuLeaveOperationRecords));
    }

    /**
     * 修改请假操作记录
     */
    @PreAuthorize("@ss.hasPermi('routine:leaveOperationRecords:edit')")
    @Log(title = "请假操作记录", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改请假操作记录")
    public AjaxResult edit(@RequestBody RtStuLeaveOperationRecords rtStuLeaveOperationRecords) {
        return toAjax(rtStuLeaveOperationRecordsService.updateRtStuLeaveOperationRecords(rtStuLeaveOperationRecords));
    }

    /**
     * 删除请假操作记录
     */
    @PreAuthorize("@ss.hasPermi('routine:leaveOperationRecords:remove')")
    @Log(title = "请假操作记录", businessType = BusinessType.DELETE)
    @PostMapping("/{operationRecordsIds}")
    @ApiOperation("删除请假操作记录")
    public AjaxResult remove(@PathVariable Long[] operationRecordsIds) {
        return toAjax(rtStuLeaveOperationRecordsService.deleteRtStuLeaveOperationRecordsByOperationRecordsIds(operationRecordsIds));
    }
}
