package com.huashe.park.application.web.controller.bd;


import com.huashe.common.domain.AjaxResult;
import com.huashe.park.core.service.IBdDevcTrailService;
import com.huashe.park.domain.entity.BdDevcTrail;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
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 ruoyi
 * @date 2024-11-07
 */
@RestController
@RequestMapping("/bd/devcTrail")
public class BdDevcTrailController extends BaseController {
    @Autowired
    private IBdDevcTrailService bdDevcTrailService;

    /**
     * 查询设备轨迹列表
     */
    @PreAuthorize("@ss.hasPermi('bd:devcTrail:list')")
    @GetMapping("/list")
    public TableDataInfo list(BdDevcTrail bdDevcTrail) {
        startPage();
        List<BdDevcTrail> list = bdDevcTrailService.selectBdDevcTrailList(bdDevcTrail);
        return getDataTable(list);
    }

    /**
     * 导出设备轨迹列表
     */
    @PreAuthorize("@ss.hasPermi('bd:devcTrail:export')")
    @Log(title = "设备轨迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BdDevcTrail bdDevcTrail) {
        List<BdDevcTrail> list = bdDevcTrailService.selectBdDevcTrailList(bdDevcTrail);
        ExcelUtil<BdDevcTrail> util = new ExcelUtil<BdDevcTrail>(BdDevcTrail.class);
        util.exportExcel(response, list, "设备轨迹数据");
    }

    /**
     * 获取设备轨迹详细信息
     */
    @PreAuthorize("@ss.hasPermi('bd:devcTrail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(bdDevcTrailService.selectBdDevcTrailById(id));
    }

    /**
     * 新增设备轨迹
     */
    @PreAuthorize("@ss.hasPermi('bd:devcTrail:add')")
    @Log(title = "设备轨迹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BdDevcTrail bdDevcTrail) {
        return toAjax(bdDevcTrailService.insertBdDevcTrail(bdDevcTrail));
    }

    /**
     * 修改设备轨迹
     */
    @PreAuthorize("@ss.hasPermi('bd:devcTrail:edit')")
    @Log(title = "设备轨迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BdDevcTrail bdDevcTrail) {
        return toAjax(bdDevcTrailService.updateBdDevcTrail(bdDevcTrail));
    }

    /**
     * 删除设备轨迹
     */
    @PreAuthorize("@ss.hasPermi('bd:devcTrail:remove')")
    @Log(title = "设备轨迹", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bdDevcTrailService.deleteBdDevcTrailByIds(ids));
    }
}
