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.RtFuAudit;
import com.srs.routine.service.IRtFuAuditService;
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 2024-07-24
 */
@RestController
@RequestMapping("/routine/audit")
@Api(value = "一站式社区模块-功能房预约审核管理", tags = "一站式社区模块-功能房预约审核管理")
public class RtFuAuditController extends BaseController {
    @Autowired
    private IRtFuAuditService rtFuAuditService;

    /**
     * 查询功能房预约审核列表
     */
@PreAuthorize("@ss.hasPermi('routine:audit:list')")
@GetMapping("/list")
@ApiOperation("一站式社区模块-功能房预约审核管理--查询功能房预约审核列表")
    public TableDataInfo list(RtFuAudit rtFuAudit)
    {
        startPage();
        List<RtFuAudit> list = rtFuAuditService.selectRtFuAuditList(rtFuAudit);
        return getDataTable(list);
    }

    /**
     * 导出功能房预约审核列表
     */
    @PreAuthorize("@ss.hasPermi('routine:audit:export')")
    @Log(title = "功能房预约审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("一站式社区模块-功能房预约审核管理--导出功能房预约审核列表")
    public void export(HttpServletResponse response, RtFuAudit rtFuAudit)
    {
        List<RtFuAudit> list = rtFuAuditService.selectRtFuAuditList(rtFuAudit);
        ExcelUtil<RtFuAudit> util = new ExcelUtil<RtFuAudit>(RtFuAudit.class);
        util.exportExcel(response, list, "功能房预约审核数据");
    }

    /**
     * 获取功能房预约审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:audit:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("一站式社区模块-功能房预约审核管理--获取功能房预约审核详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rtFuAuditService.selectRtFuAuditById(id));
    }

    /**
     * 新增功能房预约审核
     */
    @PreAuthorize("@ss.hasPermi('routine:audit:add')")
    @Log(title = "功能房预约审核", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("一站式社区模块-功能房预约审核管理--新增功能房预约审核")
    public AjaxResult add(@RequestBody RtFuAudit rtFuAudit)
    {
        rtFuAudit.setAuditor(getUsername());
        rtFuAudit.setDepart(getLoginUser().getUser().getDept().getDeptName());
        return toAjax(rtFuAuditService.insertRtFuAudit(rtFuAudit));
    }

    /**
     * 修改功能房预约审核
     */
    @PreAuthorize("@ss.hasPermi('routine:audit:edit')")
    @Log(title = "功能房预约审核", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("一站式社区模块-功能房预约审核管理--修改功能房预约审核")
    public AjaxResult edit(@RequestBody RtFuAudit rtFuAudit)
    {
        rtFuAudit.setAuditor(getUsername());
        rtFuAudit.setDepart(getLoginUser().getUser().getDept().getDeptCode());
        return toAjax(rtFuAuditService.updateRtFuAudit(rtFuAudit));
    }

    /**
     * 删除功能房预约审核
     */
    @PreAuthorize("@ss.hasPermi('routine:audit:remove')")
    @Log(title = "功能房预约审核", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("一站式社区模块-功能房预约审核管理--删除功能房预约审核")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtFuAuditService.deleteRtFuAuditByIds(ids));
    }
}
