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

/**
 * 预约Controller
 *
 * @author ruoyi
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/system/reservat")
public class BomanReservatController extends BaseController
{
    @Autowired
    private IBomanReservatService bomanReservatService;

/**
 * 查询预约列表
 */
@PreAuthorize("@ss.hasPermi('system:reservat:list')")
@GetMapping("/list")
    public TableDataInfo list(BomanReservat bomanReservat)
    {
        startPage();
        List<BomanReservat> list = bomanReservatService.selectBomanReservatList(bomanReservat);
        return getDataTable(list);
    }

    /**
     * 导出预约列表
     */
    @PreAuthorize("@ss.hasPermi('system:reservat:export')")
    @Log(title = "预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BomanReservat bomanReservat)
    {
        List<BomanReservat> list = bomanReservatService.selectBomanReservatList(bomanReservat);
        ExcelUtil<BomanReservat> util = new ExcelUtil<BomanReservat>(BomanReservat.class);
        util.exportExcel(response, list, "预约数据");
    }

    /**
     * 获取预约详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:reservat:query')")
    @GetMapping(value = "/{reservatId}")
    public AjaxResult getInfo(@PathVariable("reservatId") Long reservatId)
    {
        return success(bomanReservatService.selectBomanReservatByReservatId(reservatId));
    }

    /**
     * 新增预约
     */
    @PreAuthorize("@ss.hasPermi('system:reservat:add')")
    @Log(title = "预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BomanReservat bomanReservat)
    {
        return toAjax(bomanReservatService.insertBomanReservat(bomanReservat));
    }

    /**
     * 修改预约
     */
    @PreAuthorize("@ss.hasPermi('system:reservat:edit')")
    @Log(title = "预约", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody BomanReservat bomanReservat)
    {
        return toAjax(bomanReservatService.updateBomanReservat(bomanReservat));
    }

    /**
     * 删除预约
     */
    @PreAuthorize("@ss.hasPermi('system:reservat:remove')")
    @Log(title = "预约", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{reservatIds}")
    public AjaxResult remove(@PathVariable Long[] reservatIds)
    {
        return toAjax(bomanReservatService.deleteBomanReservatByReservatIds(reservatIds));
    }
}
