package com.jjt.biz.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.enums.BusinessType;
import com.jjt.biz.domain.TwinDeviceAll;
import com.jjt.biz.service.ITwinDeviceAllService;
import com.jjt.common.utils.poi.ExcelUtil;

/**
 * 全厂设备管理Controller
 *
 * @author wukai
 * @date 2025-03-06
 */
@Api(tags="全厂设备管理")
@RestController
@RequestMapping("/biz/all")
public class TwinDeviceAllController extends BaseController{
    @Resource
    private ITwinDeviceAllService twinDeviceAllService;

    /**
     * 查询全厂设备管理列表
     */
    @ApiOperation("查询全厂设备管理列表")
    @PreAuthorize("@ss.hasPermi('biz:all:list')")
    @GetMapping("/list")
    public AjaxResult list(TwinDeviceAll twinDeviceAll)
    {
        List<TwinDeviceAll> list = twinDeviceAllService.selectTwinDeviceAllList(twinDeviceAll);
        return success(list);
    }

    /**
     * 导出全厂设备管理列表
     */
    @ApiOperation("导出全厂设备管理列表")
    @PreAuthorize("@ss.hasPermi('biz:all:export')")
    @Log(title = "全厂设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinDeviceAll twinDeviceAll)
    {
        List<TwinDeviceAll> list = twinDeviceAllService.selectTwinDeviceAllList(twinDeviceAll);
        ExcelUtil<TwinDeviceAll> util = new ExcelUtil<TwinDeviceAll>(TwinDeviceAll.class);
        util.exportExcel(response, list, "全厂设备管理数据");
    }

    /**
     * 获取全厂设备管理详细信息
     */
    @ApiOperation("获取全厂设备管理详细信息")
    @PreAuthorize("@ss.hasPermi('biz:all:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return success(twinDeviceAllService.selectTwinDeviceAllByDeviceId(deviceId));
    }

    /**
     * 新增全厂设备管理
     */
    @ApiOperation("新增全厂设备管理")
    @PreAuthorize("@ss.hasPermi('biz:all:add')")
    @Log(title = "全厂设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinDeviceAll twinDeviceAll)
    {
        return toAjax(twinDeviceAllService.insertTwinDeviceAll(twinDeviceAll));
    }

    /**
     * 修改全厂设备管理
     */
    @ApiOperation("修改全厂设备管理")
    @PreAuthorize("@ss.hasPermi('biz:all:edit')")
    @Log(title = "全厂设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinDeviceAll twinDeviceAll)
    {
        return toAjax(twinDeviceAllService.updateTwinDeviceAll(twinDeviceAll));
    }

    /**
     * 删除全厂设备管理
     */
    @ApiOperation("删除全厂设备管理")
    @PreAuthorize("@ss.hasPermi('biz:all:remove')")
    @Log(title = "全厂设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(twinDeviceAllService.deleteTwinDeviceAllByDeviceIds(deviceIds));
    }
}
