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.RtFuResource;
import com.srs.routine.service.IRtFuResourceService;
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-21
 */
@RestController
@RequestMapping("/system/resource")
@Api(value = "功能房图片管理", tags = "功能房图片管理")
public class RtFuResourceController extends BaseController {
    @Autowired
    private IRtFuResourceService rtFuResourceService;

    /**
     * 查询功能房图片列表
     */
//@PreAuthorize("@ss.hasPermi('system:resource:list')")
@GetMapping("/list")
@ApiOperation("查询功能房图片列表")
    public TableDataInfo list(RtFuResource rtFuResource)
    {
        startPage();
        List<RtFuResource> list = rtFuResourceService.selectRtFuResourceList(rtFuResource);
        return getDataTable(list);
    }

    /**
     * 导出功能房图片列表
     */
//    @PreAuthorize("@ss.hasPermi('system:resource:export')")
    @Log(title = "功能房图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出功能房图片列表")
    public void export(HttpServletResponse response, RtFuResource rtFuResource)
    {
        List<RtFuResource> list = rtFuResourceService.selectRtFuResourceList(rtFuResource);
        ExcelUtil<RtFuResource> util = new ExcelUtil<RtFuResource>(RtFuResource.class);
        util.exportExcel(response, list, "功能房图片数据");
    }

    /**
     * 获取功能房图片详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:resource:query')")
    @GetMapping(value = "/{resId}")
    @ApiOperation("获取功能房图片详细信息")
    public AjaxResult getInfo(@PathVariable("resId") Long resId)
    {
        return success(rtFuResourceService.selectRtFuResourceByResId(resId));
    }

    /**
     * 新增功能房图片
     */
//    @PreAuthorize("@ss.hasPermi('system:resource:add')")
    @Log(title = "功能房图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增功能房图片")
    public AjaxResult add(@RequestBody RtFuResource rtFuResource)
    {

        return toAjax(rtFuResourceService.insertRtFuResource(rtFuResource));
    }
    /**
     * 新增功能房图片
     */
//    @PreAuthorize("@ss.hasPermi('system:resource:add')")
    @Log(title = "功能房预约图片", businessType = BusinessType.INSERT)
    @PostMapping("/addAll")
    @ApiOperation("新增功能房预约图片")
    public AjaxResult addAll(@RequestBody RtFuResource rtFuResource)
    {
        return toAjax(rtFuResourceService.insertRtFuResource(rtFuResource));
    }

    /**
     * 修改功能房图片
     */
//    @PreAuthorize("@ss.hasPermi('system:resource:edit')")
    @Log(title = "功能房图片", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改功能房图片")
    public AjaxResult edit(@RequestBody RtFuResource rtFuResource)
    {
        return toAjax(rtFuResourceService.updateRtFuResource(rtFuResource));
    }

    /**
     * 删除功能房图片
     */
//    @PreAuthorize("@ss.hasPermi('system:resource:remove')")
    @Log(title = "功能房图片", businessType = BusinessType.DELETE)
    @PostMapping("/{resIds}")
    @ApiOperation("删除功能房图片")
    public AjaxResult remove(@PathVariable Long[] resIds)
    {
        return toAjax(rtFuResourceService.deleteRtFuResourceByResIds(resIds));
    }
}
