package com.ruoyi.web.controller.reservRecord;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.reservRecord.ReservRecord;
import com.ruoyi.system.service.IReservRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 预约记录Controller
 *
 * @author boman
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/wuYe/reservRecord")
public class ReservRecordController extends BaseController {
    @Autowired
    private IReservRecordService reservRecordService;

    /**
     * 查询预约记录列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReservRecord reservRecord) {
        startPage();
        List<ReservRecord> list = reservRecordService.selectReservRecordList(reservRecord);
        return getDataTable(list);
    }

    /**
     * 导出预约记录列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:export')")
    @Log(title = "预约记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReservRecord reservRecord) {
        List<ReservRecord> list = reservRecordService.selectReservRecordList(reservRecord);
        ExcelUtil<ReservRecord> util = new ExcelUtil<ReservRecord>(ReservRecord.class);
        util.exportExcel(response, list, "预约记录数据");
    }

    /**
     * 获取预约记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:query')")
    @GetMapping(value = "/{reservRecordId}")
    public AjaxResult getInfo(@PathVariable("reservRecordId") Long reservRecordId) {
        return success(reservRecordService.selectReservRecordByReservRecordId(reservRecordId));
    }

    /**
     * 新增预约记录
     */
    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:add')")
    @Log(title = "预约记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReservRecord reservRecord) {
        return toAjax(reservRecordService.insertReservRecord(reservRecord));
    }

    /**
     * 修改预约记录
     */
    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:edit')")
    @Log(title = "预约记录", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ReservRecord reservRecord) {
        return toAjax(reservRecordService.updateReservRecord(reservRecord));
    }

    /**
     * 删除预约记录
     */
    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:remove')")
    @Log(title = "预约记录", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{reservRecordIds}")
    public AjaxResult remove(@PathVariable Long[] reservRecordIds) {
        return toAjax(reservRecordService.deleteReservRecordByReservRecordIds(reservRecordIds));
    }
}
