package com.ruoyi.web.bst;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.orderDevice.domain.OrderDeviceQuery;
import com.ruoyi.bst.orderDevice.domain.OrderDeviceVO;
import com.ruoyi.bst.orderDevice.service.OrderDeviceService;
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;

/**
 * 订单设备Controller
 *
 * @author ruoyi
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/bst/orderDevice")
public class OrderDeviceController extends BaseController
{
    @Autowired
    private OrderDeviceService orderDeviceService;

    /**
     * 查询订单设备列表
     */
    @PreAuthorize("@ss.hasPermi('bst:orderDevice:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderDeviceQuery query)
    {
        startPage();
        startOrderBy();
        query.setScope(true);
        List<OrderDeviceVO> list = orderDeviceService.selectOrderDeviceList(query);
        return getDataTable(list);
    }

    /**
     * 导出订单设备列表
     */
    @PreAuthorize("@ss.hasPermi('bst:orderDevice:export')")
    @Log(title = "订单设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderDeviceQuery query)
    {
        query.setScope(true);
        List<OrderDeviceVO> list = orderDeviceService.selectOrderDeviceList(query);
        ExcelUtil<OrderDeviceVO> util = new ExcelUtil<OrderDeviceVO>(OrderDeviceVO.class);
        util.exportExcel(response, list, "订单设备数据");
    }

    /**
     * 获取订单设备详细信息
     */
    @PreAuthorize("@ss.hasPermi('bst:orderDevice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderDeviceService.selectOrderDeviceById(id, true));
    }

}
