package com.srs.web.controller.stureg;

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.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.stureg.domain.CheckRoom;
import com.srs.stureg.service.ICheckRoomService;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 入住信息Controller
 * 
 * @author 邓
 * @date 2023-05-20
 */
@RestController
@RequestMapping("/stureg/checkroom")
public class CheckRoomController extends BaseController
{
    @Autowired
    private ICheckRoomService checkRoomService;

    /**
     * 查询入住信息列表
     */
//    @PreAuthorize("@ss.hasPermi('stureg:checkroom:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckRoom checkRoom)
    {
        startPage();
        List<CheckRoom> list = checkRoomService.selectCheckRoomList(checkRoom);
        return getDataTable(list);
    }

    /**
     * 导出入住信息列表
     */
//    @PreAuthorize("@ss.hasPermi('stureg:checkroom:export')")
    @Log(title = "入住信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckRoom checkRoom)
    {
        List<CheckRoom> list = checkRoomService.selectCheckRoomList(checkRoom);
        ExcelUtil<CheckRoom> util = new ExcelUtil<CheckRoom>(CheckRoom.class);
        util.exportExcel(response, list, "入住信息数据");
    }

    /**
     * 获取入住信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:checkroom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(checkRoomService.selectCheckRoomById(id));
    }

    /**
     * 新增入住信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:checkroom:add')")
    @Log(title = "入住信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckRoom checkRoom)
    {
        return toAjax(checkRoomService.insertCheckRoom(checkRoom));
    }

    /**
     * 修改入住信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:checkroom:edit')")
    @Log(title = "入住信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody CheckRoom checkRoom)
    {
        return toAjax(checkRoomService.updateCheckRoom(checkRoom));
    }

    /**
     * 删除入住信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:checkroom:remove')")
    @Log(title = "入住信息", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(checkRoomService.deleteCheckRoomByIds(ids));
    }
}
