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.ShopRoom;
import com.huijy.management.service.IShopRoomService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 酒店房间Controller
 *
 * @author lishuwen
 * @date 2021-11-10
 */
@RestController
@RequestMapping("/management/room")
public class ShopRoomController extends BaseController
{
    @Autowired
    private IShopRoomService shopRoomService;

    /**
     * 查询酒店房间列表
     */
    @PreAuthorize("@ss.hasPermi('management:room:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopRoom shopRoom)
    {
        startPage();
        List<ShopRoom> list = shopRoomService.selectShopRoomList(shopRoom);
        return getDataTable(list);
    }

    /**
     * 导出酒店房间列表
     */
    @PreAuthorize("@ss.hasPermi('management:room:export')")
    @Log(title = "酒店房间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShopRoom shopRoom)
    {
        List<ShopRoom> list = shopRoomService.selectShopRoomList(shopRoom);
        ExcelUtil<ShopRoom> util = new ExcelUtil<ShopRoom>(ShopRoom.class);
        return util.exportExcel(list, "酒店房间数据");
    }

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

    /**
     * 新增酒店房间
     */
    @PreAuthorize("@ss.hasPermi('management:room:add')")
    @Log(title = "酒店房间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopRoom shopRoom)
    {
        return toAjax(shopRoomService.insertShopRoom(shopRoom));
    }

    /**
     * 修改酒店房间
     */
    @PreAuthorize("@ss.hasPermi('management:room:edit')")
    @Log(title = "酒店房间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopRoom shopRoom)
    {
        return toAjax(shopRoomService.updateShopRoom(shopRoom));
    }

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