package com.srs.web.controller.routine;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.srs.routine.domain.vo.RtFuInserSoltVo;
import com.srs.routine.domain.vo.RtFuResSoltVo;
import com.srs.routine.domain.vo.RtfuRuleVo;
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.RtFuSolt;
import com.srs.routine.service.IRtFuSoltService;
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-19
 */
@RestController
@RequestMapping("/routine/solt")
@Api(value = "一站式社区模块-功能房规则管理", tags = "功能房规则管理")
public class RtFuSoltController extends BaseController {
    @Autowired
    private IRtFuSoltService rtFuSoltService;

    /**
     * 查询功能房开放时间段列表
     */
//@PreAuthorize("@ss.hasPermi('routine:solt:list')")
@GetMapping("/list")
@ApiOperation("一站式社区模块-功能房规则管理--查询功能房开放时间段列表")
    public TableDataInfo list(RtFuSolt rtFuSolt)
    {
        startPage();
        List<RtfuRuleVo> list = rtFuSoltService.getList(rtFuSolt);
        return getDataTable(list);
    }

    /**
     * 导出功能房开放时间段列表
     */
//    @PreAuthorize("@ss.hasPermi('routine:solt:export')")
    @Log(title = "功能房开放时间段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("一站式社区模块-功能房规则管理--导出功能房开放时间段列表")
    public void export(HttpServletResponse response, RtFuSolt rtFuSolt)
    {
        List<RtFuSolt> list = rtFuSoltService.selectRtFuSoltList(rtFuSolt);
        ExcelUtil<RtFuSolt> util = new ExcelUtil<RtFuSolt>(RtFuSolt.class);
        util.exportExcel(response, list, "功能房开放时间段数据");
    }

    /**
     * 获取功能房开放时间段详细信息
     */
//    @PreAuthorize("@ss.hasPermi('routine:solt:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("一站式社区模块-功能房规则管理--获取功能房开放时间段详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rtFuSoltService.selectRtFuSoltById(id));
    }

    /**
     * 新增功能房开放时间段
     */
//    @PreAuthorize("@ss.hasPermi('routine:solt:add')")
    @Log(title = "功能房开放时间段", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("一站式社区模块-功能房规则管理--新增功能房开放时间段")
    public AjaxResult add(@RequestBody RtFuSolt rtFuSolt)
    {
        return toAjax(rtFuSoltService.insertRtFuSolt(rtFuSolt));
    }

    /**
     * 修改功能房开放时间段
     */
//    @PreAuthorize("@ss.hasPermi('routine:solt:edit')")
    @Log(title = "功能房开放时间段", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("一站式社区模块-功能房规则管理--修改功能房开放时间段")
    public AjaxResult edit(@RequestBody RtFuSolt rtFuSolt)
    {
        return toAjax(rtFuSoltService.updateRtFuSolt(rtFuSolt));
    }


    @PostMapping("/InsertAll")
    @ApiOperation("一站式社区模块-功能房规则管理--功能房规则")
    public AjaxResult InsertAll(@RequestBody List<RtFuInserSoltVo> rtFuInserSoltVos){
        return rtFuSoltService.insertSoltAll(rtFuInserSoltVos);
    }

    /**
     * 删除功能房开放时间段
     */
//    @PreAuthorize("@ss.hasPermi('routine:solt:remove')")
    @Log(title = "功能房开放时间段", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("一站式社区模块-功能房规则管理--删除功能房开放时间段")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtFuSoltService.deleteRtFuSoltByIds(ids));
    }
}
