package com.ruoyi.web.controller.reservat.config;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BomanReservatConfig;
import com.ruoyi.system.service.IBomanReservatConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约配置主Controller
 * 
 * @author boman
 * @date 2023-11-02
 */
@RestController
@RequestMapping("/reservat/config")
public class BomanReservatConfigController extends BaseController
{
    @Autowired
    private IBomanReservatConfigService bomanReservatConfigService;

    /**
     * 查询预约配置主列表
     */
    //@PreAuthorize("@ss.hasPermi('system:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(BomanReservatConfig bomanReservatConfig)
    {
        startPage();
        List<BomanReservatConfig> list = bomanReservatConfigService.selectBomanReservatConfigList(bomanReservatConfig);
        return getDataTable(list);
    }

    /**
     * 导出预约配置主列表
     */
    @PreAuthorize("@ss.hasPermi('system:config:export')")
    @Log(title = "预约配置主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BomanReservatConfig bomanReservatConfig)
    {
        List<BomanReservatConfig> list = bomanReservatConfigService.selectBomanReservatConfigList(bomanReservatConfig);
        ExcelUtil<BomanReservatConfig> util = new ExcelUtil<BomanReservatConfig>(BomanReservatConfig.class);
        util.exportExcel(response, list, "预约配置主数据");
    }

    /**
     * 获取预约配置主详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:config:query')")
    @GetMapping(value = "/{reservatConfigId}")
    public AjaxResult getInfo(@PathVariable("reservatConfigId") Long reservatConfigId)
    {
        return success(bomanReservatConfigService.selectBomanReservatConfigByReservatConfigId(reservatConfigId));
    }

    /**
     * 新增预约配置主
     */
    @PreAuthorize("@ss.hasPermi('system:config:add')")
    @Log(title = "预约配置主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BomanReservatConfig bomanReservatConfig)
    {
        return toAjax(bomanReservatConfigService.insertBomanReservatConfig(bomanReservatConfig));
    }

    /**
     * 修改预约配置主
     */
    @PreAuthorize("@ss.hasPermi('system:config:edit')")
    @Log(title = "预约配置主", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody BomanReservatConfig bomanReservatConfig)
    {
        return toAjax(bomanReservatConfigService.updateBomanReservatConfig(bomanReservatConfig));
    }

    /**
     * 删除预约配置主
     */
    @PreAuthorize("@ss.hasPermi('system:config:remove')")
    @Log(title = "预约配置主", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{reservatConfigIds}")
    public AjaxResult remove(@PathVariable Long[] reservatConfigIds)
    {
        return toAjax(bomanReservatConfigService.deleteBomanReservatConfigByReservatConfigIds(reservatConfigIds));
    }
}
