package com.ruoyi.web.controller.appointment;

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.BomanReservatConfigTime;
import com.ruoyi.system.service.IBomanReservatConfigTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约时段配置Controller
 *
 * @author ruoyi
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/system/time")
public class BomanReservatConfigTimeController extends BaseController
{
    @Autowired
    private IBomanReservatConfigTimeService bomanReservatConfigTimeService;

/**
 * 查询预约时段配置列表
 */
@PreAuthorize("@ss.hasPermi('system:time:list')")
@GetMapping("/list")
    public TableDataInfo list(BomanReservatConfigTime bomanReservatConfigTime)
    {
        startPage();
        List<BomanReservatConfigTime> list = bomanReservatConfigTimeService.selectBomanReservatConfigTimeList(bomanReservatConfigTime);
        return getDataTable(list);
    }

    /**
     * 导出预约时段配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:time:export')")
    @Log(title = "预约时段配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BomanReservatConfigTime bomanReservatConfigTime)
    {
        List<BomanReservatConfigTime> list = bomanReservatConfigTimeService.selectBomanReservatConfigTimeList(bomanReservatConfigTime);
        ExcelUtil<BomanReservatConfigTime> util = new ExcelUtil<BomanReservatConfigTime>(BomanReservatConfigTime.class);
        util.exportExcel(response, list, "预约时段配置数据");
    }

    /**
     * 获取预约时段配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:time:query')")
    @GetMapping(value = "/{reservatConfigTimeId}")
    public AjaxResult getInfo(@PathVariable("reservatConfigTimeId") Long reservatConfigTimeId)
    {
        return success(bomanReservatConfigTimeService.selectBomanReservatConfigTimeByReservatConfigTimeId(reservatConfigTimeId));
    }

    /**
     * 新增预约时段配置
     */
    @PreAuthorize("@ss.hasPermi('system:time:add')")
    @Log(title = "预约时段配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BomanReservatConfigTime bomanReservatConfigTime)
    {
        return toAjax(bomanReservatConfigTimeService.insertBomanReservatConfigTime(bomanReservatConfigTime));
    }

    /**
     * 修改预约时段配置
     */
    @PreAuthorize("@ss.hasPermi('system:time:edit')")
    @Log(title = "预约时段配置", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody BomanReservatConfigTime bomanReservatConfigTime)
    {
        return toAjax(bomanReservatConfigTimeService.updateBomanReservatConfigTime(bomanReservatConfigTime));
    }

    /**
     * 删除预约时段配置
     */
    @PreAuthorize("@ss.hasPermi('system:time:remove')")
    @Log(title = "预约时段配置", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{reservatConfigTimeIds}")
    public AjaxResult remove(@PathVariable Long[] reservatConfigTimeIds)
    {
        return toAjax(bomanReservatConfigTimeService.deleteBomanReservatConfigTimeByReservatConfigTimeIds(reservatConfigTimeIds));
    }
}
