package com.huijy.web.controller.management;

import java.util.List;
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.huijy.common.annotation.Log;
import com.huijy.common.core.controller.BaseController;
import com.huijy.common.core.domain.AjaxResult;
import com.huijy.common.enums.BusinessType;
import com.huijy.management.domain.ShopRoomOrder;
import com.huijy.management.service.IShopRoomOrderService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 酒店房间预订Controller
 *
 * @author lishuwen
 * @date 2021-11-10
 */
@RestController
@RequestMapping("/management/order")
public class ShopRoomOrderController extends BaseController
{
    @Autowired
    private IShopRoomOrderService shopRoomOrderService;

    /**
     * 查询酒店房间预订列表
     */
    @PreAuthorize("@ss.hasPermi('management:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopRoomOrder shopRoomOrder)
    {
        startPage();
        List<ShopRoomOrder> list = shopRoomOrderService.selectShopRoomOrderList(shopRoomOrder);
        return getDataTable(list);
    }

    /**
     * 导出酒店房间预订列表
     */
    @PreAuthorize("@ss.hasPermi('management:order:export')")
    @Log(title = "酒店房间预订", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShopRoomOrder shopRoomOrder)
    {
        List<ShopRoomOrder> list = shopRoomOrderService.selectShopRoomOrderList(shopRoomOrder);
        ExcelUtil<ShopRoomOrder> util = new ExcelUtil<ShopRoomOrder>(ShopRoomOrder.class);
        return util.exportExcel(list, "酒店房间预订数据");
    }

    /**
     * 获取酒店房间预订详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shopRoomOrderService.selectShopRoomOrderById(id));
    }

    /**
     * 新增酒店房间预订
     */
    @PreAuthorize("@ss.hasPermi('management:order:add')")
    @Log(title = "酒店房间预订", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopRoomOrder shopRoomOrder)
    {
        return toAjax(shopRoomOrderService.insertShopRoomOrder(shopRoomOrder));
    }

    /**
     * 修改酒店房间预订
     */
    @PreAuthorize("@ss.hasPermi('management:order:edit')")
    @Log(title = "酒店房间预订", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopRoomOrder shopRoomOrder)
    {
        return toAjax(shopRoomOrderService.updateShopRoomOrder(shopRoomOrder));
    }

    /**
     * 删除酒店房间预订
     */
    @PreAuthorize("@ss.hasPermi('management:order:remove')")
    @Log(title = "酒店房间预订", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopRoomOrderService.deleteShopRoomOrderByIds(ids));
    }
}
