package com.goomood.phm.controller;

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.goomood.common.annotation.Log;
import com.goomood.common.core.controller.BaseController;
import com.goomood.common.core.domain.AjaxResult;
import com.goomood.common.enums.BusinessType;
import com.goomood.phm.domain.BasicDeviceInfo;
import com.goomood.phm.service.IBasicDeviceInfoService;
import com.goomood.common.utils.poi.ExcelUtil;
import com.goomood.common.core.page.TableDataInfo;

/**
 * 设备信息Controller
 * 
 * @author goomood
 * @date 2024-11-16
 */
@RestController
@RequestMapping("/basic/deviceInfo")
public class BasicDeviceInfoController extends BaseController
{
    @Autowired
    private IBasicDeviceInfoService basicDeviceInfoService;

    /**
     * 查询设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('basic:deviceInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicDeviceInfo basicDeviceInfo)
    {
        startPage();
        List<BasicDeviceInfo> list = basicDeviceInfoService.selectBasicDeviceInfoList(basicDeviceInfo);
        return getDataTable(list);
    }

    /**
     * 导出设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('basic:deviceInfo:export')")
    @Log(title = "设备信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicDeviceInfo basicDeviceInfo)
    {
        List<BasicDeviceInfo> list = basicDeviceInfoService.selectBasicDeviceInfoList(basicDeviceInfo);
        ExcelUtil<BasicDeviceInfo> util = new ExcelUtil<BasicDeviceInfo>(BasicDeviceInfo.class);
        util.exportExcel(response, list, "设备信息数据");
    }

    /**
     * 获取设备信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:deviceInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basicDeviceInfoService.selectBasicDeviceInfoById(id));
    }

    /**
     * 新增设备信息
     */
    @PreAuthorize("@ss.hasPermi('basic:deviceInfo:add')")
    @Log(title = "设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicDeviceInfo basicDeviceInfo)
    {
        return toAjax(basicDeviceInfoService.insertBasicDeviceInfo(basicDeviceInfo));
    }

    /**
     * 修改设备信息
     */
    @PreAuthorize("@ss.hasPermi('basic:deviceInfo:edit')")
    @Log(title = "设备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicDeviceInfo basicDeviceInfo)
    {
        return toAjax(basicDeviceInfoService.updateBasicDeviceInfo(basicDeviceInfo));
    }

    /**
     * 删除设备信息
     */
    @PreAuthorize("@ss.hasPermi('basic:deviceInfo:remove')")
    @Log(title = "设备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basicDeviceInfoService.deleteBasicDeviceInfoByIds(ids));
    }
}
